Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx is not recognising my markdown tables

I am using sphinx locally with .md files. When I add a table in the format:

| something | something else | something more |

| one | two | three |

the text is getting parsed as a paragraph. I have tried with rst files and it works in this format:

===== ===== ====

oneee ttttt ffff

===== ===== ====

sdddd dfvgd sdfv

dfgvv dffff ffff

===== ===== ====

When I am using rst files I am getting error messages about wrongly structured tables while in md files it goes silent.

Any ideas?

like image 888
Byte_Monster Avatar asked Jun 09 '17 15:06

Byte_Monster


People also ask

Does Sphinx support markdown?

To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.

How do you markdown a table?

To add a table, use three or more hyphens ( --- ) to create each column's header, and use pipes ( | ) to separate each column. For compatibility, you should also add a pipe on either end of the row. Cell widths can vary, as shown below. The rendered output will look the same.


1 Answers

In short, standard Markdown has no support for tables and never has. You will need to use RST for tables.

As the Sphinx documentation notes:

To support Markdown-based documentation, Sphinx can use recommonmark. recommonmark is a Docutils bridge to CommonMark-py, a Python package for parsing the CommonMark Markdown flavor.

In fact, a review of the CommonMark spec reveals no mention of tables. For that matter, the original Markdown rules never mentioned tables either. Regardless, over the years various Markdown implementations have added support for tables in various ways, one of the more well known being GitHub. In fact, GitHub has published their own extensions to the CommonMark spec which add support for tables. However, recommonmark/CommonMark-py does not use that spec, but the standard CommonMark spec, so there is no table support.

I checked the documentation for both recommonmark and CommonMark-py, but neither appear to support tables as an option either. However, recommonmark does add some Sphinx specific functionality, which is off by default. While they mostly have to do with autogenerated table of contents and math, there is the enable_eval_rst option which, if enabled, allows you to embed RST right in your Markdown document. You may be able to include a RST table right in a Markdown document with that feature enabled.

like image 105
Waylan Avatar answered Sep 24 '22 11:09

Waylan