Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not supporting table #7

Closed
noraj opened this issue Jan 27, 2019 · 6 comments
Closed

not supporting table #7

noraj opened this issue Jan 27, 2019 · 6 comments

Comments

@noraj
Copy link

noraj commented Jan 27, 2019

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/
@njvack
Copy link
Owner

njvack commented Jun 4, 2019

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

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

@noraj
Copy link
Author

noraj commented Jun 4, 2019

Something like this I guess,

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

@njvack
Copy link
Owner

njvack commented Jun 4, 2019

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

@njvack njvack closed this as completed Jun 4, 2019
@njvack
Copy link
Owner

njvack commented Jun 4, 2019

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

@njvack njvack reopened this Jun 4, 2019
@noraj
Copy link
Author

noraj commented Jun 4, 2019

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

@matthewdeanmartin
Copy link
Collaborator

njvack here said #11 said it isn't on the road map.

markpickle does support that.

example https://github.com/matthewdeanmartin/markpickle/blob/main/test/test_deserialize/test_dicts_as_tables.py#L16

If that is all you want, then it can be done in a single function: https://stackoverflow.com/questions/66185838/convert-markdown-table-to-json-with-python

I'm closing to be consistent with issue 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants