Understanding of JSON output
rplCloud opened this issue · 3 comments
Hi all,
I try to get JSON output using this library.
I tried the Python library and the cmark command line tool with the same results. HTML and AST looks ok for me:
cmark <<< '*hello!*'<p><em>hello!</em></p>cmark -a <<< '*hello!*'[document]
Title:
Info:
Destination:
Sourcepos: [[1, 1], [1, 8]]
Info:
Literal:
Children:
-> [document]
-> Title:
-> Info:
...
But I do not understand the JSON output:
cmark -aj <<< '*hello!*'{"is_fenced": false, "t": "document", "sourcepos": [[1, 1], [1, 8]], "fence_length": 0, "open": false, "last_line_blank": false}Honestly, I have no idea what this all about...
I expect some like this:
[ "paragraph" , [
[ "emph" , {} , [
[ "text" , {} , [ "hello"
...Can you give me some hints what I am oing wrong?
Regards,
Reto
It looks like it's printing out the internal structure for the Node class. See https://github.com/jgm/commonmark.js/blob/master/lib/node.js#L70
We could change this to be more user-friendly.
After reproducing the problem, it looks like the ASTtoJSON function is broken. I will look into it. Thanks for letting me know.
I've come up with a fix and made a pull request, which will get merged soon.