From: Gerry L. <gjl...@gm...> - 2010-09-13 21:49:38
|
Started looking into this one and I think I uncovered a somewhat related bug. If a child element's tail is assigned, then neither the text nor tail show up in the output. For example: import markdown from markdown.inlinepatterns import Pattern class MyPattern(Pattern): def handleMatch(self, m): el = markdown.etree.Element('p') el.text = markdown.AtomicString('an *atomic*') c1 = markdown.etree.SubElement(el, 'span') c1.text = markdown.AtomicString('*string*') c1.tail = markdown.AtomicString('`not code`') return el class MyExtension(markdown.Extension): def extendMarkdown(self, md, md_globals): patt = MyPattern(r'::(.*?)::') md.inlinePatterns.insert(0, 'foobar', patt) ext = MyExtension(None) md = markdown.Markdown(extensions=[ext], output_format="xhtml1") html = md.convert('here is ::mypattern::') print html The resulting output is: <p>here is <p>an *atomic* </p> </p> As opposed to: <p>here is <p>an *atomic*<span>*string*</span>`not code`</p> </p> This is probably out in the weeds as far as usage goes. Also, I'm surprised that this doesn't cause normal usage issues- surely the tree parser receives similar input in normal use situations(ie when parsing a file of Markdown text). An element with a child with text and tail can't be that unusual. Anyway, I'll be investigating it a bit more. Regards- Gerry LaMontagne |