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
Limited rst to md support in notebooks #219
Comments
Great to see that PyTorch is using sphinx-gallery! To be fair this is probably one of the more involved sphinx-gallery "example as tutorial" I have seen in the wild (~600 lines). My first instinct is to be slightly reluctant to go in this direction but I could be convinced if the PR has an optional dependency on pypandoc and is not too intrusive. The first thing to check would be that pandoc does convert the rst to something reasonable in your example. |
Well, I moved pytorch tutorials from github hosted notebook files to html pages based on sphinx gallery. I think sphinx gallery is excellent for writing tutorials. I have a simple script here to convert notebooks to notebook styled examples based on pandoc.
Here's what I want to do:
That's non intrusive enough, I hope? |
The change does not look too intrusive indeed. Maybe others (@Titan-C @GaelVaroquaux @Eric89GXL) have comments on this before you start working on a PR. A small comment: note that when downloading the notebook you probably won't have |
If the proposal is to (if possible) offload the conversion onto a better-tested library, then +1 from me |
The last time someone suggested using pandoc the discussion immediately ended with NO. because that includes putting the entire GHC and pandoc as a dependency. At those times we were not aware pypandoc existed nor that pandoc now can be installed as a binary. I just tested pypandoc and it is capable to download and install pandoc in userspace, is also in conda-forge and windows wheels ship the pandoc binary. So installing this dependency becomes very easy now. +1 |
We're trying to using sphinx-gallery for our package, but running into problems where notebooks generated by sphinx-gallery don't convert properly, which has us reverting to checking in notebooks for the time being. Came here to +1 the issue. |
As far as I can tell this problem still exists, i.e. downloading notebooks from sphinx-gallery means they have rest-formatted markdown which doesn't render properly (like in the screenshot in the first post). Does anyone have workarounds? sphinx-gallery is such a great effort, would be a shame not to be able to use it because of this. |
@larsoner happy to implement the above proposed (optional) pypandoc solution if we're still +1 |
Yep, let's go for it with a |
I'm +1 on this but we should flag it as a big old "this is advanced and your experience may vary" because pandoc can be pretty tricky to deal with different edge-cases etc, and I don't think we want to be on the hook for explaining how it works to folks. Here's another thought: as a part of another project I've been working on, we've now got a 100% functional markdown parser for Sphinx (https://myst-parser.readthedocs.io/). This goes above what recommonmark does, and adds syntax for roles, directives, etc. Perhaps it could another optional extension / flag in sphinx-gallery, and then people could write their python comments in markdown, and the generated |
we've now got a 100% functional markdown parser for Sphinx (https://myst-parser.readthedocs.io/).
Finding a way to integrate this would be nice, because it would give an
full edit workflow with jupytext.
|
@GaelVaroquaux I don't think this would be too difficult in principle, the myst-parser "just works" in the sense that if you add it as an extension then files ending with I think the question is how much there are assumptions made about rST in the sphinx-gallery code...that may be a big trickier. Also I should probably clarify the above - if the user writes their content in CommonMark, then the resulting |
Everything we write is RST-formatted. Can you be more specific about what we'd need to reformat? For example it doesn't seem like a problem if we still write |
Well I'd think the points where we'd need to support markdown are:
All the auto-generated files would still work fine, since MyST just adds a markdown parser, but Sphinx still retains the rST parser so those files work fine. |
MyST discussion continued in #710 |
Hi,
Current parser for rst to md in notebook.py is quite limited. For example this page's notebooks looks like this:
Here's what I propose: use pypandoc if available else fallback to current implementation. If you like this, I can raise a PR.
The text was updated successfully, but these errors were encountered: