17 lines
313 B
Python
17 lines
313 B
Python
import logging
|
|
|
|
import bleach
|
|
import markdown
|
|
|
|
|
|
logger = logging.getLogger('MARKDOWN')
|
|
logger.setLevel(logging.INFO)
|
|
|
|
tags = bleach.sanitizer.ALLOWED_TAGS[:]
|
|
tags.extend(['p', 'pre'])
|
|
|
|
|
|
def parse(text):
|
|
md = markdown.markdown(text, extensions=['extra'])
|
|
text = bleach.clean(md, tags=tags)
|
|
return text
|