jgrassler / mkdocs-pandoc

[unmaintained] mkdocs -> pandoc converter: use this fork https://github.com/twardoch/mkdocs-combine
Apache License 2.0
107 stars 39 forks source link

AttributeError: 'list' object has no attribute 'values' #9

Closed hugoruscitti closed 8 years ago

hugoruscitti commented 8 years ago

Hi, i got an error when start to using mkdocs2pandoc:

➤ git remote -v
origin  https://github.com/hugoruscitti/pilas-manual (fetch)
origin  https://github.com/hugoruscitti/pilas-manual (push)
~/p/pilas-manual (master=)
➤ mkdocs2pandoc > example.pd
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs2pandoc", line 9, in <module>
    load_entry_point('mkdocs-pandoc==0.2.5', 'console_scripts', 'mkdocs2pandoc')()
  File "/usr/local/lib/python2.7/site-packages/mkdocs_pandoc/cli/mkdocs2pandoc.py", line 80, in main
    for line in pconv.convert():
  File "/usr/local/lib/python2.7/site-packages/mkdocs_pandoc/pandoc_converter.py", line 95, in convert
    pages = self.flatten_pages(self.config['pages'])
  File "/usr/local/lib/python2.7/site-packages/mkdocs_pandoc/pandoc_converter.py", line 73, in flatten_pages
    if type(list(page.values())[0]) is str:
AttributeError: 'list' object has no attribute 'values'

and an empty output file:

➤ du -s example.pd
0   example.pd
jgrassler commented 8 years ago

You are formatting your pages: array in a format not documented on http://www.mkdocs.org/user-guide/writing-your-docs/: you are using flat lists and not hashes as in the documentation. Since I didn't know that was even a thing for mkdocs I haven't implemented support for it so far.

I'll implement support for the flat list kind of pages: array. Until then you can work around the problem by using the key-value style documented here: http://www.mkdocs.org/user-guide/writing-your-docs/#multilevel-documentation

hugoruscitti commented 8 years ago

Wow, thanks!!! it's works great now!!

mydocs epub 2016-02-05 13-10-26

Thanks !!!

jgrassler commented 8 years ago

Please don't close this just yet, I still need to fix the problem on my side :-)

There is a fix already, but I haven't gotten around to testing it properly, yet. If you'd like to try it on your old mkdocs.yml feel free: https://github.com/jgrassler/mkdocs-pandoc/tree/issue/9

jgrassler commented 8 years ago

Fixed in version 0.2.6.