Skip to content

List table options not working when rendering markdown #673

@schmoelder

Description

@schmoelder

Describe the bug

When adding some additional options such as :align: center or widths: grid to a table and then trying to display it using display(Markdown(my_table)), the alignment (and other properties) are not working as expected.

I expected the table to look like this:

Image

But instead, it looks like this:

Image

Note, the name / reference works as expected.

Reproduce the bug

````{code-cell} ipython3
---
mystnb:
  markdown_format: myst
  remove_code_source: true
---
from IPython.display import display, Markdown

name = "my_table_embedded"
caption = "Some values in a table"

my_table = f"""
```{{table}} {caption} 
:name: {name}
:align: center
:widths: grid

| short | looooooooooooooooooooooooooooooooooooooooong |
| - | - |
| some | value |
```
"""

display(Markdown(my_table))
````

{numref}`my_table_embedded` shows some values.

For reference, here is the plain table that renders correctly:

```{table} "Some values in a table"
:name: my_table_plain
:align: center
:widths: grid

| short | looooooooooooooooooooooooooooooooooooooooong |
| - | - |
| some | value |
```

List your environment

Jupyter Book : 1.0.4.post1
External ToC : 1.0.1
MyST-Parser : 3.0.1
MyST-NB : 1.2.0
Sphinx Book Theme : 1.1.4
Jupyter-Cache : 1.0.1
NbClient : 0.10.2

Link to relevant documentation: https://myst-nb.readthedocs.io/en/latest/render/format_code_cells.html#markdown

Edit: I also just found this issue. So maybe it's a duplicate? But since in my situation it seems to work when parsing the regular table and does not work when executing code, I presume it's actually a myst-nb issue. Admittedly, I don't always fully understand which part of the jupyter stack does what.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions