Rinohtype crashes when processing a heading-only / empty body table
th0mr opened this issue · 2 comments
Is there an existing issue for this?
- I have searched the existing issues
Sphinx or rinoh output
Exception occurred:
File "C:\Python38\lib\site-packages\rinoh\frontend_init.py", line 42, in __getattr_
raise AttributeError('No such element: {} in {}'.format(name, self))
AttributeError: No such element: row in <rinoh.frontend.rst.nodes.TBody object at 0x0000020DFC059610>
Source files
Hi,
I'm having issues whenever rinohtype encounters a header-only table i.e. a table with a header but no rows.
The best way I could find to replicate this is with this csv-table.
RST Input:
.. csv-table::
:header: "What", "A", "Fun", "Issue"
:file: ./empty.csv
Where empty.csv is a completely empty file, i.e. no rows.
After experimenting, I found HTML can generate this type of table correctly. Which makes me think this could be a bug for rinoh.
I’ve had a look through the issues and cant see anything like this that has been raised before. Is there something I can do to avoid this, or is this a bug?
I've assembled a minimal example document with this table in here. minimal.zip
It was built with python -m sphinx -M rinoh . ./build
Versions
rinohtype 0.5.5 (in development)
Sphinx 5.3.0
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Windows-10-10.0.19045-SP0
It is likely that this case is not handled. It should be easy to check whether the table body is missing (or empty, rather) and gracefully handle this situation. If you feel up to it, please provide a PR with a test in tests_regression/rst
that triggers the issue and the fix.
I'll have a look into this when I get some time this week 😄