Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

recommonmark will never support table, what can I do #103

Closed
leniy opened this issue May 24, 2018 · 8 comments
Closed

recommonmark will never support table, what can I do #103

leniy opened this issue May 24, 2018 · 8 comments

Comments

@leniy
Copy link

leniy commented May 24, 2018

I know recommonmark will never support table , cause this is a major feature than markdown , to let people to use rst.

So,is there any other Parser for sphinx to use ?

@leniy leniy changed the title recommonmark will **never** support table recommonmark will never support table, what can I do May 24, 2018
@maxgrenderjones
Copy link

Seems like a situation where AutoStructify should help - use the eval_rst directive to get it to output a table specified using rst format, i.e.

```eval_rst
+------------+------------+-----------+ 
| Header 1   | Header 2   | Header 3  | 
+============+============+===========+ 
| body row 1 | column 2   | column 3  | 
+------------+------------+-----------+ 
| body row 2 | Cells may span columns.| 
+------------+------------+-----------+ 
```

@leniy
Copy link
Author

leniy commented May 28, 2018

@maxgrenderjones
thx, and btw, how to figure out the table's boundary, cause each time I add some words to a table, I need to add lots of ---- and ==== manually.

@leniy
Copy link
Author

leniy commented May 28, 2018

Are there any automation tools?

@asmeurer
Copy link

Emacs has some tools to edit ASCII tables (https://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Based-Tables.html)

But if you are just writing a simple n x m table where no cells extend beyond their width or hight, it's much easier to use a list table (also goes in an eval_rst block).

Or, alternately, you can write the table in pure HTML, since Markdown supports HTML directly inline.

@aborruso
Copy link

aborruso commented Jul 8, 2018

Hi @leniy I have solved using https://github.com/ryanfox/sphinx-markdown-tables

@leniy
Copy link
Author

leniy commented Jul 12, 2018

@aborruso ,yes,@ryanfox 's tool is very useful.

@clayrisser
Copy link
Contributor

clayrisser commented Feb 2, 2019

@aborruso, (sphinx-markdown-tables)[https://github.com/ryanfox/sphinx-markdown-tables] is not true sphinx/docutils table support. It simply converts the tables to html tables. This creates major issues when writing custom sphinx builders/writers.

For example when building the sphinx-markdown-builder, I walk the docutils tree to build markdown tables. However, this fails to work with an html table. So, I have to build a custom exception that detects html tables to convert it to a markdown table. This is certainly not ideal, because someone might explicitly define their table in html and want it kept in html. In summary, html tables should be separate from a docutils table, and recommonmark should build a docutils table from markdown tables to ensure this separation.

Sadly, the commonmark python module does not support parsing markdown tables. It has been suggested to rebuild the recommonmark parser to use the Markdown python module. This parser supports extensions and has a very solid extension for parsing markdown tables.

I have created a pull request to add the Markdown parser.
#138

It not only enables full markdown support using the Markdown python module but also opens the door for more features supported by the Markdown modules various extensions.

I have ensured the pull request is fully backward compatible with the CommonMark parser.

In order to use the Markdown parser this pull request implements, you have to explicitly set the parser property in the recommonmark_config to Markdown.

    app.add_config_value('recommonmark_config', {
        'parser': 'Markdown'
    }, True)

You can see my code at the link below.
https://github.com/codejamninja/recommonmark/tree/codejamninja/python-markdown

@simonsan
Copy link

@aborruso Link worked very well! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants