Skip to content

Markdown tables break texinfo builder because of float colspec #540

@n-peugnet

Description

@n-peugnet

Describe the bug

context
When I run make texinfo using markdown tables...

expectation
Build should succeed.

bug
But instead it fails with:

Exception occurred:
  File "/home/nicolas/GoogleDrive/Projets/Club1/sphinx-myst-table-texinfo/.venv/lib/python3.9/site-packages/sphinx/writers/texinfo.py", line 1014, in visit_colspec
    self.body.append('{%s} ' % ('x' * (n + 2)))
TypeError: can't multiply sequence by non-int of type 'float'

problem
This is a problem because it prevents from building info pages.

cause
MyST seems to generate incorrect colspecs, containing floats, when Sphinx texinfo builder seems to expect ints:

<colspec colwidth="50.0"/>
<colspec colwidth="50.0"/>

Maybe this should be fixed in Sphinx instead, by making sure n is an int here:

https://github.com/sphinx-doc/sphinx/blob/223b1a94f2cd1d2af6297fa419ab96758ddd31e2/sphinx/writers/texinfo.py#L1014

Reproduce the bug

Here is a reproducer:

virtualenv .venv
. .venv/bin/activate
pip install sphinx myst-parser
sphinx-quickstart --sep -p test -a test -v test -r test -l en --extensions myst_parser
rm source/index.rst
echo '# Hello world!

```{toctree}
---
maxdepth: 2
caption: test
---

```

| col1 | col2 |
|------|------|
| val1 | val2 |
' > source/index.md
make texinfo

List your environment

  • Debian bookworm
  • Python 3.9.12

all python programs installed via pip in a virtualenv:

alabaster==0.7.12
attrs==21.4.0
Babel==2.9.1
certifi==2021.10.8
charset-normalizer==2.0.12
docutils==0.17.1
idna==3.3
imagesize==1.3.0
importlib-metadata==4.11.3
Jinja2==3.1.1
markdown-it-py==2.0.1
MarkupSafe==2.1.1
mdit-py-plugins==0.3.0
mdurl==0.1.0
myst-parser==0.17.0
packaging==21.3
Pygments==2.11.2
pyparsing==3.0.7
pytz==2022.1
PyYAML==6.0
requests==2.27.1
snowballstemmer==2.2.0
Sphinx==4.5.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
typing_extensions==4.1.1
urllib3==1.26.9
zipp==3.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions