Files @ fa66316f8aca
Branch filter:

Location: symposion_app/symposion/markdown_parser.py

Hiroshi Miura
form key ordering: detect django version

- Django 1.6 and before use SortedDict instead of OrderedDict
It detect version and return proper dict for key ordering.
- field deletion is done by reorder funcion.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
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)