danielfrg / mkdocs-jupyter

Use Jupyter Notebook in mkdocs
https://mkdocs-jupyter.danielfrg.com
Apache License 2.0
362 stars 45 forks source link

Comments in code cells break nav structure #182

Open Peter9192 opened 6 months ago

Peter9192 commented 6 months ago

Thanks for the nice plugin!

I noticed that a notebook with a markdown code cell like below breaks the headers in the navigation side bar:

# Example notebook

This represents a top markdown cell.

some text

## Header before code block 
This header is shown in sidebar

Let's say I want to give an example code (not a code cell, just a code block in markdown)
Using double backticks below as I have no clue how to render nested fenced code blocks in a github issue.

``python
1+1 = 2

# This seems off:
1+1=3
`` 

## Header after code block
This header is not shown in the sidebar.

Would it be possible to ignore hashtags in markdown code block while parsing the notebook?

mrdbourke commented 3 months ago

+1 to this, I'm also having the same issue.

I've been using a hack of turning code blocks into images, however, this is not ideal long-term.

Perhaps it's an issue with nbconvert?

I'm reading old issues here: https://github.com/ipython/ipython/issues/5345/

But they may be unrelated.