symposion icon indicating copy to clipboard operation
symposion copied to clipboard

html5lib 0.999 pinning causes a markdown parser error

Open daaray opened this issue 9 years ago • 3 comments

The pinned requirement causes the markdown parser to throw errors:

  File "/home/daaray/.virtualenvs/conf_site/local/lib/python2.7/site-packages/sy
mposion/markdown_parser.py", line 15, in parse
    for token in parser.parseFragment(text).childNodes:
AttributeError: childNodes

This is due to https://github.com/html5lib/html5lib-python/pull/45.

We need to either revert the pin to 0.95 or modify the parser by specifying the tree builder:

from html5lib import html5parser, sanitizer, getTreeBuilder

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, tree=getTreeBuilder("dom"))
    for token in parser.parseFragment(text).childNodes:
        bits.append(token.toxml())
    return "".join(bits)

daaray avatar Mar 12 '15 03:03 daaray

@daaray Could you send PR for this issue?

miurahr avatar Jun 28 '15 02:06 miurahr

fixed by 11f697d13757be5505898ae2f5444c394ab3b5ae

miurahr avatar Oct 17 '15 01:10 miurahr

Can this issue be closed? It seems to be fixed.

ossanna16 avatar Dec 22 '15 13:12 ossanna16