-
Notifications
You must be signed in to change notification settings - Fork 392
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
Percent format with outputs - Sponsors wanted! #951
Comments
This project has the potential to make diffs on notebooks easy to read without requiring any additional tool - see how a change in the code of a plot is rendered on our proof of concept: |
Any update on this issue? I would love to include the output of code cells in the percent py files |
Your idea looks pretty neat! I pray for this will be integrated into Jupytext soon. Best. |
I have been looking for a simple way to render a notebook to myst and preserve code generated image outputs in particular. As as a really simple, minimal hack, it looks like we can modify the # https://github.com/mwouts/jupytext/blob/4b5651237fabce3ad49f5c397cbd2e6b34c1a943/src/jupytext/myst.py#L412
added_md_cell = False
for output in cell.outputs:
if "data" in output and "image/png" in output["data"]:
metadata = {"tags": ["jp-previous-cell-output"]}
string += f"\n+++ {json.dumps(metadata)}\n"
string += (
f'![](data:image/png;base64,{output["data"]["image/png"]})\n'
)
added_md_cell = True
last_cell_md = added_md_cell We can round trip on this by ignoring any # https://github.com/mwouts/jupytext/blob/4b5651237fabce3ad49f5c397cbd2e6b34c1a943/src/jupytext/myst.py#L343
if "tags" in md_metadata and "jp-previous-cell-output" in md_metadata["tags"]:
pass
else:
_flush_markdown(md_start_line, token, md_metadata)
md_metadata = read_cell_metadata(token, len(notebook.cells))
md_start_line = token.map[1] I imagine things would get more complex as more output types are handled, but as a simple way of exporting notebooks with generated images to myst, it seems to work. |
I'd like to be add support for outputs to the
py:percent
format.This seems easier to do that adding outputs to Markdown (#220), as we have less constraints on how outputs should be included in the text document.
The project is described at https://github.com/mwouts/nbpercent/#readme - essentially the idea is to export all outputs (except simple text outputs) to PNG, HTML, Markdown files.
Such a text format for notebook would improve the experience of version control for notebooks with outputs, and would also eliminate the need to keep paired text and ipynb files in sync.
I'd like to be working on this in the next two months, but I am looking for a sponsor - please contact me through email (on my GitHub account).
The text was updated successfully, but these errors were encountered: