njvack/markdown-to-json

List has no Attribute Items

Closed this issue · 2 comments

x4dr commented
#stuff  
##Test  
a  
b   

breaks with

  File "/usr/bin/md_to_json", line 11, in <module>
    load_entry_point('markdown-to-json==1.0.0', 'console_scripts', 'md_to_json')()
  File "/usr/lib/python3.8/site-packages/markdown_to_json/scripts/md_to_json.py", line 86, in main
    return jsonify_markdown(
  File "/usr/lib/python3.8/site-packages/markdown_to_json/scripts/md_to_json.py", line 68, in jsonify_markdown
    rendered = renderer.stringify_dict(nested)
  File "/usr/lib/python3.8/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'

expectations
{"stuff": "Test":["a","b"]}
or
{"stuff": "Test":["a\nb"]}
or
{"stuff": "Test":["a \nb "]} if whitespace is preserved

njvack commented

I think this would probably render to

{"stuff": {"Test": "a\nb"}}

a and b aren't a list…

The markdown above isn't valid as far as CommonMark is concerned.

With the right whitespace, the tests passes. With markpickle library, which uses mistune as the markdown parser, it also has problems with this file unless the spacing is perfect.

So I learned that Markdown is more sensitive to whitespace than I thought.

https://github.com/njvack/markdown-to-json/blob/master/tests/test_example_files.py#L23