diff --git a/requirements/base.txt b/requirements/base.txt index 5a955d0d..830c9b29 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,7 +6,7 @@ django-sitetree>=1.7.0 django-taggit==0.18.0 django-timezone-field>=2.0 easy-thumbnails==2.3 -html5lib==0.9999999 +bleach markdown==2.6.5 pytz==2015.7 django-ical==1.4 diff --git a/symposion/markdown_parser.py b/symposion/markdown_parser.py index b3eaa53c..d92a5020 100644 --- a/symposion/markdown_parser.py +++ b/symposion/markdown_parser.py @@ -1,17 +1,14 @@ from __future__ import unicode_literals +import bleach import markdown +tags = bleach.sanitizer.ALLOWED_TAGS[:] +tags.extend(['p', 'pre']) + + def parse(text): - - # First run through the Markdown parser - text = markdown.markdown(text, extensions=["extra"], safe_mode=False) - - # Sanitize using html5lib - # bits = [] - # parser = html5parser.HTMLParser(tokenizer=sanitizer.HTMLSanitizer) - # for token in parser.parseFragment(text).childNodes: - # bits.append(token.toxml()) - # return "".join(bits) + md = markdown.markdown(text, extensions=['extra']) + text = bleach.clean(md, tags=tags) return text