Markdown table alignment ignored
See original GitHub issueDescribe the problem
One should be able to create tables with specified alignment, as in
Left Aligned | Centered | Right Aligned |
---|---|---|
Cell 1 | Cell 2 | Cell 3 |
Cell 4 | Cell 5 | Cell 6 |
| Left Aligned | Centered | Right Aligned |
| :--- | :---: | ---: |
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |
Using MyST, it seems to be at the discretion of the theme. For example, RTD looks like this while the PyData theme looks like
Link to your repository or website
No response
Steps to reproduce
Paste the above markdown table into a document parsed by MyST.
The version of Python you’re using
3.9.6
Your operating system
Arch Linux
Versions of your packages
MyST-Parser 0.15.1
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Markdown table alignment stopped working #3919 - GitHub
In Jupyter, now it's always right aligned! It's one thing enforce right-alignment for consistency reasons as described in /pull/2534.
Read more >Left-align headers in Markdown table? - Stack Overflow
My question is, is there any way to left-align the header cells while retaining the alignment in the image? IE, I want to...
Read more >Working with Tables in GitHub Markdown - Pluralsight
To center-align, surround a dash with two colons :-: . Surround any of the above with pipes to create the second row of...
Read more >Markdown table alignment ignored #15959 - Gitea
The rendering of the markdown does not include the alignment information. The html code that gets generated looks like <table> <thead> <tr> <th>a11111</th> ......
Read more >Incorrect alignment on Markdown tables on PR description
Issue Summary. Markdown tables very much differ from their preview view when compared to the actual results in the PR body.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Heya, so basically the intention in the markdown parser, is to set a style on each cell: you can see if you put this table into https://markdown-it.github.io, you’ll get e.g.
However, with docutils/sphinx there is no way to propagate a style into the HTML, so currently it is setting these as classes
e.g. the same output in sphinx is
There are actually two things not ideal with this table (a) we don’t need the paragraph tags (I checked with RST and that also outputs
<p>
), and (b) the text-align are classes rather than stylesIf you want to fix this with the current myst-parser then, the way would be to add some custom CSS to your project:
A minimal fix here would be to at least document this workaround, probably improve the naming of the CSS classes, and maybe reach out to some of the main themes to include it in their CSS
cc @choldgraf (sphinx-book-theme), @pradyunsg (furo) what is your preference for the class names
This is because of https://github.com/pydata/pydata-sphinx-theme/issues/524 Note, a workaround would be to add
:class: align-center