From: edA-qa mort-ora-y <ed...@di...> - 2014-01-05 06:35:39
|
I'm trying to write an extension which translates code blocks into the Wordpress [sourcecode] form. I used codehilite as an example, but my code never finds any "pre" blocks. If I remove the 'pre' matching and print all blocks in the loop I never see a 'pre' in the list. Yet the final HTML generated does indeed have the pre/code blocks there. class WPSource(markdown.treeprocessors.Treeprocessor): def run(self,root): blocks = root.getiterator('pre') for block in blocks: print(block) if len(children) == 1 and children[0].tag == 'code': print( children[0].text ) class WPExtension(markdown.Extension): def __init__(self,configs): pass def extendMarkdown(self, md, md_globals): sourcer = WPSource(md) md.treeprocessors.add("wpsource", sourcer, "_end" ) md.registerExtension(self) md = markdown.Markdown( extensions = [ 'meta', 'fenced_code', WPExtension({}) ] ) -- edA-qa mort-ora-y Leaf Creator Leaf - the language we always wanted http://leaflang.org/ |