executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx

Home Page:https://myst-nb.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tables from code-output not properly rendered

raphaelquast opened this issue · comments

Describe the bug

context
I have a nice markdown table like this:

| a | b | c |
|---|---|---|
| 1 | 2 | 3 |

and I'd like to render it from a code-cell using something like this:

from IPython.display import display, Markdown
display(Markdown(
"""
| a | b | c |
|---|---|---|
| 1 | 2 | 3 |
"""
))

... and in my conf.py i have the following:

myst_render_markdown_format = "myst"

expectation
I expected something like this:

image

bug
But instead I get this:

image

  • from this issue #322 I get that this should work... any idea what's going on here?

Reproduce the bug

the description should be enough to reproduce

List your environment

myst-nb 1.0.0
myst-parser 2.0.0

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

I was also trying to render a dataframe into a proper markdown table and I was able to reproduce bug.
This is inconvenient as mystnb should help to format table with data instead of having to write markdown.

@mathisdrn
fyi: I found that HTML tables seem to do the job just fine (and pandas supports html-table output as well... )!

import pandas as pd
from IPython.display import display, Markdown
df = pd.DataFrame(dict(a=[1,2,3], b=[4,5,6]))

display(HTML(df.to_html()))