Changeset - 55ec9b745a98
[Not reviewed]
0 0 1
Luke Hatcher - 12 years ago 2012-07-18 23:20:51
lukeman@gmail.com
add our more liberal markdown parser to symposion
1 file changed with 17 insertions and 0 deletions:
0 comments (0 inline, 0 general)
symposion/markdown_parser.py
Show inline comments
 
new file 100644
 
import html5lib
 
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)
0 comments (0 inline, 0 general)