-
Notifications
You must be signed in to change notification settings - Fork 64
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
Parse markdown outputs in notebooks along with the rest of the markdown on a page in order to programmatically generate MyST content #1026
Comments
continuing #1559 here: An example for this would be the following:
My problem now is, that I have 2-20 different structures. For each I get graphs based on the same code. Better would be to have
and/or
A simplified example might be statistics about bank accounts (not scientific, but less abstract).
For different use-cases different approaches might be best. I'm wondering what might be possible:
|
Workaround: Write to temporary text files and then use
|
@choldgraf we should also make it possible to |
Yeah I was thinking that too. It also made me wonder if the notebook cell MyST support could be more like the plugin structure, rather than making it language specific. For example, a cell tag like Does that make sense? If so I can update the issue body to reflect that suggestion. |
@choldgraf the natural way to do this would be to define a MIME type for MyST AST, and recognise it in our transforms! |
That sounds like a good idea. Though if it were the only way, then each kernel would need to have a package that outputs MyST right? The benefit of tags and stdout is that anybody in any language could use it without developing anything specific. |
Although we don't need a package for this (certainly with ipython, you can just use |
My idea was inspired by the way that you handled "black box" outputs for the executable plugins infrastructure. So below I'll share a Python and an R cell that would generate either MyST MD or MyST AST. At build time, if the tag was identified on a cell, then any Below I'll use Print, but I think since Jupyter "returns" the result of the final executed line, it may not be necessary. It'd also cool if this worked with variables too, so that you could insert generated MyST elsewhere. Python - MyST MD
Python - MyST AST1
Footnotes
|
I love the idea of parsing plain/MysT mardkown proper, as it's very easy to generate from many tools. In my code I very often have something like from IPython.display import display, Markdown
md = lambda s: display(Markdown(s)) and I use Having the ability to properly handle that (along perhaps with a new |
I decided to create a separate issue to track generating MyST AST directly from cell outputs, since that might be an easier short-term solution and get us part of the way there: |
@rowanc1 @stevejpurves @fwkoch @choldgraf I can't seem to paste these in Discord right now. Here are some quick discussion videos (~2min each) about the work I've been doing on Markdown output parsing: https://github.com/user-attachments/assets/e0d61b90-2148-42e5-b433-1fddbad6f301 The PR I'm most excited about is currently #1671. Need to dash, no rush here, but it would be good to book in a video meeting at some point. |
Jupyter notebook cells can produce text output that is specific to markdown (
text/markdown
). It'd be useful if MyST could parse this output along with the rest of the markdown in the notebook. This would allow for programmatic generation of notebook content, and along with the{embed}
directive could allow you to nicely stitch together MyST content via any Jupyter Kernel.For example:
As an example, the MyST-nb Sphinx extension documents this functionality here.
An example from our docs where this would be useful
In the admonitions docs here:
https://github.com/executablebooks/mystmd/blob/c0f51ee51890158081736722cb01bcf510699786/docs/admonitions.md?plain=1#L34-L98
We have a big list of all the different types of admonitions for demonstration. It's just boilerplate myst repeated over and over. If we parsed Markdown outputs as MyST, we could replace it with something like:
Related
The text was updated successfully, but these errors were encountered: