rolandshoemaker / CommonMark-py

Depreciated in favor of rtfd/CommonMark-py
Other
125 stars 12 forks source link

CommonMark.dumpAST: 'Block' object has no attribute 'title' #16

Open hyperknot opened 9 years ago

hyperknot commented 9 years ago

Running CommonMark.dumpAST terminates in a AttributeError.

/usr/local/lib/python2.7/site-packages/CommonMark/CommonMark.pyc in dumpAST(obj, ind)
    117     indChar = ("\t" * ind) + "-> " if ind else ""
    118     print(indChar + "[" + obj.t + "]")
--> 119     if not obj.title == "":
    120         print("\t" + indChar + "Title: " + obj.title)
    121     if not obj.info == "":

AttributeError: 'Block' object has no attribute 'title'
jvtrudel commented 9 years ago

The following script work perfectly! So this bug has something to do with ASTtoJSON.

import CommonMark
import json
parser = CommonMark.DocParser()
renderer = CommonMark.HTMLRenderer()
ast = parser.parse("Hello *World*")
html = renderer.render(ast)
# json = CommonMark.ASTtoJSON(ast)
CommonMark.dumpAST(ast) # pretty print generated AST structure
jvtrudel commented 9 years ago

Why not just deepcopy the block passed in ASTtoJSON? Is there some memory or performance issue that would prevent that bug fix?