clayrisser / sphinx-markdown-parser

write markdown inside of docutils & sphinx projects
https://codejam.ninja
Other
19 stars 8 forks source link

building docs containing a table fails #7

Closed FlorianLudwig closed 4 years ago

FlorianLudwig commented 4 years ago

Adding a table breaks my build.

Software Versions

Sphinx==2.2.0 sphinx-markdown-parser==0.1.7

Markdown

| A | B |
| - | - |
| C | D |

config

As in readme.

html_theme = "sphinx_rtd_theme"
extensions = []
source_suffix = [".rst"]

def setup(app):
    app.add_source_suffix('.md', 'markdown')
    app.add_source_parser(MarkdownParser)
    app.add_config_value('markdown_parser_config', {
        'auto_toc_tree_section': 'Content',
        'enable_auto_doc_ref': True,
        'enable_auto_toc_tree': True,
        'enable_eval_rst': True,
        'enable_inline_math': True,
        'enable_math': True,
    }, True)

traceback

Traceback (most recent call last):
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/application.py", line 346, in build
    self.builder.build_update()
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update
    len(to_build))
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 535, in write
    self._write_serial(sorted(docnames))
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 545, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/builders/html.py", line 616, in write_doc
    self.docwriter.write(doctree, destination)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/sphinx/writers/html.py", line 59, in translate
    self.document.walkabout(visitor)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 2 more times]
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 191, in walkabout
    visitor.dispatch_departure(self)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 1925, in dispatch_departure
    return method(node)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/writers/_html_base.py", line 593, in depart_colspec
    total_width = sum(node['colwidth'] for node in self.colspecs)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/writers/_html_base.py", line 593, in <genexpr>
    total_width = sum(node['colwidth'] for node in self.colspecs)
  File "/home/f.ludwig/.local/share/virtualenvs/guide-hDdsnpEh/lib/python3.7/site-packages/docutils/nodes.py", line 585, in __getitem__
    return self.attributes[key]
KeyError: 'colwidth'
clayrisser commented 4 years ago

Thank you for filing this issue. Can you send me a link to a demo where it fails?

FlorianLudwig commented 4 years ago

I did:

  1. sphinx-quickstart
  2. installed sphinx-markdown-parser
  3. added stuff from readme into conf.py
  4. added table to index.md

Result: foo.zip

FlorianLudwig commented 4 years ago

@codejamninja could you reproduce the problem?

clayrisser commented 4 years ago

Sorry for taking so long to get back to you.

I took a look at your example, but I'm not sure how to install it. There is no requirements.txt. I need to be able to reproduce the exact packages you are using. You can create a requirements.txt by running the following.

pip3 freeze > requirements.txt
FlorianLudwig commented 4 years ago

Hi @codejamninja I just did a clean install on that day, so it should be all the newest versions.

I recreated it and got the same error:

markdown-bug.zip

# unzip
cd markdown-bug
pipenv install 
# or
pip install -r requirements.txt
cd docs
make html
clayrisser commented 4 years ago

Ok, thanks. I was able to reproduce the error. I'm putting the follow log output here for reference. I will see what I can do. The error is coming from docutils, so the generated docutils tree must be invalid in some way.

# Sphinx version: 2.2.1
# Python version: 3.7.5rc1 (CPython)
# Docutils version: 0.15.2 release
# Jinja2 version: 2.10.3
# Last messages:
#   
#   looking for now-outdated files...
#   none found
#   pickling environment...
#   done
#   checking consistency...
#   done
#   preparing documents...
#   done
#   writing output... [100%] index
# Loaded extensions:
#   sphinx.ext.mathjax (2.2.1) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.1) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.1) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (1.0.2) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.3) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.2) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/alabaster/__init__.py
Traceback (most recent call last):
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/application.py", line 346, in build
    self.builder.build_update()
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update
    len(to_build))
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 535, in write
    self._write_serial(sorted(docnames))
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 545, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/builders/html.py", line 616, in write_doc
    self.docwriter.write(doctree, destination)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/sphinx/writers/html.py", line 59, in translate
    self.document.walkabout(visitor)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 178, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 1 more time]
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 191, in walkabout
    visitor.dispatch_departure(self)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 1925, in dispatch_departure
    return method(node)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/writers/_html_base.py", line 593, in depart_colspec
    total_width = sum(node['colwidth'] for node in self.colspecs)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/writers/_html_base.py", line 593, in <genexpr>
    total_width = sum(node['colwidth'] for node in self.colspecs)
  File "/home/codejamninja/Downloads/markdown-bug/env/lib/python3.7/site-packages/docutils/nodes.py", line 585, in __getitem__
    return self.attributes[key]
KeyError: 'colwidth'
infinity0 commented 4 years ago

This should be fixed by the most recent commits, please close.