Files @ b694901831b2
Branch filter:

Location: symposion_app/symposion/markdown_parser.py

Patrick Altman
Remove migrations

These migrations were written for South. Now that we have Django 1.7,
we will just use Django migrations once we hit a 1.0 release.
from html5lib import html5parser, sanitizer

import markdown


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)