markdown-to-json icon indicating copy to clipboard operation
markdown-to-json copied to clipboard

not supporting table

Open noraj opened this issue 6 years ago • 5 comments

What are you using a markdown parser?

It seems to be strict markdown without github or gitlab flavor support, table are no supported:

$ md_to_json index.md
Traceback (most recent call last):
  File "/home/noraj/.local/share/virtualenvs/table-iZ6bjDlQ/bin/md_to_json", line 10, in <module>
    sys.exit(main())
  File "/home/noraj/.local/share/virtualenvs/table-iZ6bjDlQ/lib/python3.7/site-packages/markdown_to_json/scripts/md_to_json.py", line 89, in main
    indent)
  File "/home/noraj/.local/share/virtualenvs/table-iZ6bjDlQ/lib/python3.7/site-packages/markdown_to_json/scripts/md_to_json.py", line 68, in jsonify_markdown
    rendered = renderer.stringify_dict(nested)
  File "/home/noraj/.local/share/virtualenvs/table-iZ6bjDlQ/lib/python3.7/site-packages/markdown_to_json/markdown_to_json.py", line 114, in stringify_dict
    for k, v in d.items()
AttributeError: 'list' object has no attribute 'items'

My source is something like that:

Contest                             | Date                                  | Location                  | Links
---                                 | ---                                   | ---                       | ---
SigSeg V1                           | Sat, 01 Dec. 2018  Sun, 02 Dec. 2018 | Paris, IdF, France        | [website][sigsegv1]
Hack&#46;lu CTF 2018                | Tue, 16 Oct. 2018  Thu, 18 Oct. 2018 | On-line                   | [CTFTime][ctftimeHacklu2018] - [website][hacklu]
picoCTF 2018                        | Fri, 28 Sep. 2018  Fri, 12 Oct. 2018 | On-line                   | [CTFTime][ctftimePicoCTF2018] - [website][picoCTF]

[sigsegv1]:https://sigsegv1.rtfm.re/
[ctftimeHacklu2018]:https://ctftime.org/event/699
[hacklu]:https://arcade.fluxfingers.net/
[ctftimePicoCTF2018]:https://ctftime.org/event/681
[picoCTF]:https://picoctf.com/

noraj avatar Jan 27 '19 21:01 noraj

I'm using commonmark, which indeed does not support tables.

What sort of json output would you expect? I guess... maybe nested arrays?

njvack avatar Jun 04 '19 01:06 njvack

Something like this I guess,

{[
{"Contest":"A", "Date":"B", "Location":"C"},
{"Contest":"D", "Date":"E", "Location":"F"},
{"Contest":"G", "Date":"H", "Location":"I"}
]}

noraj avatar Jun 04 '19 18:06 noraj

That makes sense. But until the commonmark python library supports table syntax we're not gonna be able to do it.

njvack avatar Jun 04 '19 19:06 njvack

Actually: This might be a path forward: https://github.com/GovReady/CommonMark-py-Extensions

njvack avatar Jun 04 '19 19:06 njvack

Yeah if you want to be strict about Markdown syntax using commonmark, the path is to enable it via extensions.

noraj avatar Jun 04 '19 19:06 noraj