Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom markdown cell rendering #502

Closed
ajdajd opened this issue Oct 16, 2020 · 5 comments
Closed

Custom markdown cell rendering #502

ajdajd opened this issue Oct 16, 2020 · 5 comments

Comments

@ajdajd
Copy link

ajdajd commented Oct 16, 2020

Hi,

I am working on a project where we use mermaid to create diagrams in the notebooks. In jupyterlab, we use this extension and it looks like this (the first cell shows the syntax):
image

And this how nbsphinx builds it:
image

I wonder if there is a way for this to render properly. In rst files, this extension works.

I am not opposed to writing some hacky script to make this work. If someone can point me to a direction where I could start, it would be a great help! :)

@chrisjsewell
Copy link
Contributor

chrisjsewell commented Oct 16, 2020

sorry I try not to cross-post too much about myst-nb here 😬 ... but if you use that then you can just use https://github.com/mgaitan/sphinxcontrib-mermaid similar to how you would in rST:

```{mermaid}
graph LR
   A --> B
```

@mgeier
Copy link
Member

mgeier commented Oct 17, 2020

@chrisjsewell No problem, feel free to mention MyST-NB as much as you like! Users should know all the available options in order to choose what's best for them.

I was actually going to mention MyST-NB myself. Implementing something like this in nbsphinx would be quite complicated and I don't have plans to do that. Other than probably allowing custom Markdown parsers, but I guess this will not happen very soon (see also #455).

An alternative approach would probably be to use an IPython "magic" to create mermaid diagrams (and if such a thing doesn't exist, implement it)?

@ajdajd
Copy link
Author

ajdajd commented Oct 19, 2020

Thanks @chrisjsewell. I tried myst-nb and the markdown cell still did not render the graph.

What worked was saving what you wrote as .md--is this what you meant?

Thank you @mgeier for being open and the suggestion. I'll try it when I reach a dead end with what's available. Cheers!

@chrisjsewell
Copy link
Contributor

Thanks @mgeier 😀
@ajdajd this is probably because you have nbsphinx and myst-nb extensions added at the same time? If so then nbsphinx may be parsing the ipynb and not myst-nb, you need to remove nbsphinx from the extension list. myst-nb parses markdown files exactly the same as markdown cells so, in principle, there should be no difference between them

@ajdajd
Copy link
Author

ajdajd commented Oct 20, 2020

It worked @chrisjsewell! You are right, I think I mixed up the config in my initial test yesterday.

Just for the sake of documentation, I disabled the recommonmark extension and this is my source_suffix under conf.py:

source_suffix = {
    ".rst": "restructuredtext",
    ".md": "myst-nb",
    ".ipynb": "myst-nb",
}

And this is the result:
image
image

The next problem is that the jupyterlab extension doesn't work now because of the addition of { }.


Marking this as closed. Thanks, everyone!

@ajdajd ajdajd closed this as completed Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants