jupyter-book
jupyter-book copied to clipboard
Markdown level one headers not displaying
Describe the bug
context
I am trying to display markdown text (scraped from wikipedia and run through pandoc) in a jupyter book; it has multiple levels of headings. The content looks great with display(Markdown(content))
in the notebook file itself (either a ipynb or .md notebook run in juptyer-notebook).
expectation When I built it as a book, I expected it to also display.
bug
None of the content inside a display call after the first level one header displays. No console errors are displayed for the cells (though I do have the expected console error for the last cell in my toy example, (WARNING: Non-consecutive header level increase; 0 to 2 [myst.header]
)
problem Since you can't start from a level 2 header, if level 1 header breaks things, it means it's impossible to display structured markdown context in a book in this method. One could write the text to a file and then re-load it in, but it would be nice not to have to. I'm sure this is an edge/corner case, so I'm not sure if this is meant to be supported or not; if not (and not planned to be supported), it would at least be nice to document this
Thank you so much!
Reproduce the bug
To reproduce, build the content below as part of a jupyterbook
List your environment
Mac 11.6.4, Python 3.8.11
jupyter-book --version
Jupyter Book : 0.12.3
External ToC : 0.2.4
MyST-Parser : 0.15.2
MyST-NB : 0.13.2
Sphinx Book Theme : 0.1.10
Jupyter-Cache : 0.4.3
NbClient : 0.5.3
Start of notebook content
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.11.5
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
```{code-cell} ipython3
from IPython.display import display, Markdown
from myst_nb import glue
glue('glue','# Hello')
{glue:}glue
+++
{glue:text}glue
display(Markdown('# Hello'))
display(Markdown("Hello2\n====\n"))
display(Markdown('Hello3'))
display(Markdown('## Hello4'))
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:
I use programmatic creation of Markdown headers too and so I would be curious is there is a fix/workaround for this. A workaround my project has is to use
from ipython.display import display, HTML
display(HTML('<p style="font-size:20px;">Title </p>'))
where we can vary the font size to match the given level of heading, however with this approach the headings won't appear in the top right navigation panel
Also struggling with a way to programmatically insert Jupyter notebook headings which are then understood by Jupyter-book. See issue #1982