Running CommonMark.ASTtoJSON(ast) on the same tree twice returns different results: the first time it works, but the second time throws an exception. See an example, below.
import CommonMark
parser = CommonMark.DocParser()
ast = parser.parse("Some random text\n\n### A heading\nSome more text")
But if the same command is immediately issued again, it fails:
CommonMark.ASTtoJSON(ast)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/ipython-0.14.dev-py2.7.egg/IPython/core/interactiveshell.py", line 2759, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-9-e31549bab177>", line 1, in <module>
CommonMark.ASTtoJSON(ast)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/CommonMark/CommonMark.py", line 113, in ASTtoJSON
return json.dumps(prepare(block), default=lambda o: o.__dict__) # sort_keys=True) # indent=4)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/CommonMark/CommonMark.py", line 90, in prepare
if block.parent:
AttributeError: 'Block' object has no attribute 'parent'
This occurs using CommonMark 0.5.4 as installed from pypi. The same error message occurs regardless of whether I use Python 2.7.3 or Python 3.4.2, Mac OS.
Running CommonMark.ASTtoJSON(ast) on the same tree twice returns different results: the first time it works, but the second time throws an exception. See an example, below.
The first time, it serializes correctly:
But if the same command is immediately issued again, it fails:
This occurs using CommonMark 0.5.4 as installed from pypi. The same error message occurs regardless of whether I use Python 2.7.3 or Python 3.4.2, Mac OS.