Reputation: 1061
I am creating my SphinX document via sourcing from a MarkDown source file i.e. in my index.rst
file I have:
.. toctree::
:maxdepth: 2
:caption: Contents:
myMarkDownText
.
.
.
in which myMarkDownText
is refereeing to a myMarkDownText.md
I tried creating a table from this source MarkDown file in both following formats:
| Name | Age |
| :--- | ---: |
| John D Hunter | 40 |
where is in MD syntax, and
================== ============
Name Age
================== ============
John D Hunter 40
================== ============
where is in RST syntax.
Non of them appear to produce a table-shape in my SphinX output index.html
when I create it via:
make html
Do you know any other format/way that I should try?
PS_ Please notice, I can produce tables in good shape if I put my table in my index.rst
in my SphinX. But this is not my question. My question is creating tables in SphinX while sourcing from .md
source files.
Thank you!
Upvotes: 1
Views: 1699
Reputation: 1146
The plugin sphinx-markdown-tables let you get your table in sphinx when sourcing from markdown using recommonmark
.
The other solution is to put your table in a csv file and use the native integration of csv files into RST format. If you source from markdown with recommonmark
you can use the eval_rst
option to get your rst snippet evaluated, doc here
Solution 2 has the advantage of being built-in whereas solution 1 is easier once setup, as you don't have to deal with extra files and absolute/relative path issues
Upvotes: 1
Reputation: 42497
Table syntax is a non-standard extension to Markdown which is not supported by the implementation used by Sphinx. Therefore it appears to not be possible.
According to the documentation, Sphinx uses recommonmark to parse Markdown documents, which is a CommonMark implementation of Markdown. As you can see in the CommonMark spec, tables are not a supported feature. For completeness, note that tables were also not part of the original Markdown rules either. Also, a review of the options available in recommonmark indicate that there is no optional support for tables to be enabled.
Perhaps an alternate Markdown implementation exists with a docutils bridge, but I'm not aware of any myself (and recommending libraries is off topic here).
Upvotes: 1