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

mkdocs2pandoc exits with error "ValueError: invalid width 0 (must be > 0)" #13

Closed r0ckarong closed 8 years ago

r0ckarong commented 8 years ago

I'm on Ubuntu 15.04 with Python 2.7.10, mkdocs 0.15.3 and using a slightly modified mkdocs-material theme.

When I run the tool, it exits with this error:

Traceback (most recent call last):
  File "/usr/local/bin/mkdocs2pandoc", line 9, in <module>
    load_entry_point('mkdocs-pandoc==0.2.6', 'console_scripts', 'mkdocs2pandoc')()
  File "/home/maggus/.local/lib/python2.7/site-packages/mkdocs_pandoc/cli/mkdocs2pandoc.py", line 80, in main
    for line in pconv.convert():
  File "/home/maggus/.local/lib/python2.7/site-packages/mkdocs_pandoc/pandoc_converter.py", line 165, in convert
    lines = mkdocs_pandoc.filters.tables.TableFilter().run(lines)
  File "/home/maggus/.local/lib/python2.7/site-packages/mkdocs_pandoc/filters/tables.py", line 177, in run
    ret.extend(self.convert_table(block))
  File "/home/maggus/.local/lib/python2.7/site-packages/mkdocs_pandoc/filters/tables.py", line 163, in convert_table
    lines.extend(self.wrap_row(widths, row))
  File "/home/maggus/.local/lib/python2.7/site-packages/mkdocs_pandoc/filters/tables.py", line 208, in wrap_row
    row[i] = tw.wrap(textwrap.dedent(row[i]))
  File "/usr/lib/python2.7/textwrap.py", line 329, in wrap
    return self._wrap_chunks(chunks)
  File "/usr/lib/python2.7/textwrap.py", line 258, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width 0 (must be > 0)

Any ideas?

jgrassler commented 8 years ago

First shot (not much time right now): it may be something I have introduced with the fix for https://github.com/jgrassler/mkdocs-pandoc/issues/11. If you like you can try it with mkdocs-pandoc 0.2.5 (git revision 0a0c6b2a6548e169dd4b93cf3ac9503097dca4b6) Can you share your documentation, or failing that, a minimum example to reproduce the problem? If it helps with building the minimum example: the problem occurs in one of your tables (I can tell as much from the backtrace).

r0ckarong commented 8 years ago

I did exclusion principle testing and found that it was some malformatted tables. The content originally came from DokuWiki and was converted using a converter script that produced "broken" tables.

The ones breaking the tool looked like this:

 | IAM Node                                                | Database Node | Engine Node |
 | ----------                                                | --------------- | ------------- |
 | RAM|8GB or higher|32GB or higher|16GB or higher|         
 | CPUs/cores|2 or higher|4 or higher|4 or higher|          
 | Hard Disk|50GB or higher|200GB* or higher|50GB or higher|

As you can see with some major whitespace. I removed that everything works fine for now. Will do more testing. Thanks.