Comments (13)
@srnnkls , if that can help, I have prepared a branch with a tentative implementation of the org
format based on pandoc
(back and forth), see the last three commits here: https://github.com/mwouts/jupytext/commits/org_pandoc:
- The first commit 086178b adds the
org:pandoc
format to Jupytext (and simply callspandoc
) - The second commit 93f6478 activates the round trip tests on that format
- And the third commit b5432c7 adds the files generated by the round trip tests
Note that the round trip test does not work. Is it correct that pandoc's conversion only works in one direction (ipynb to org)? Any way, feel free to experiment with this, and replace either converter with your favorite one.
Two additional comments:
- Jupytext removes the outputs before calling
pandoc
(because they are preserved in the.ipynb
file), so no headache with outputs... pandoc
is used for themd:pandoc
format, but that is not Jupytext's default markdown format (see the example files at https://github.com/mwouts/jupytext/tree/master/demo )
from jupytext.
Hello @srnnkls, thanks for reaching out!
Well, I am afraid that we've not made big progresses here... As you saw above, one can use ox-ipynb, by @jkitchin, to convert org-mode documents to ipynb, but I am not aware of a tool doing the opposite conversion.
It would help much if you could write two functions that convert a notebook object to its text representation, and vice versa. Maybe at first we should target a limited conversion, i.e.
- keep the content of code and markdown cells verbatim in the org-mode representation,
- and ignore the cell and notebook metadata.
Ideally that first version should be compatible (should use?) ox-ipynb
.
These two functions should be called in jupytext.reads
and jupytext.writes
if the format name matches the name you choose for this format, e.g. "org"
. You should also add a description of the new format in formats.py
.
NB: If you like, you can also provide these two functions in a separate Python package, and add that package as an optional dependency in Jupytext - like we did for the md:pandoc
or the md:myst
formats.
from jupytext.
You can use pandoc to convert ipynb to org right now. It is technically possible to do a round trip conversion, but you will lose things like cell metadata, and probably some formatting.
It would not be hard to use elisp to convert an ipynb to an org file containing markdown blocks and code blocks. Also not hard to do that in Python. It might be tricky either way to deal with the results.
from jupytext.
Just a note for the people who subscribed to this thread... I have opened an issue at pandoc regarding the round trip ipynb-org-ipynb: jgm/pandoc#6367.
The issue also raises the question of how the notebook cells should be represented in org mode. Personally I think that the representation should remain as simple as possible, because the users are going to type it ๐ But obviously, it is simpler for the programmers (and maybe also safer in the long run?) to use explicit cell markers. Anyway... if you have an opinion about this, please follow the pandoc thread as well!
from jupytext.
The second and third links provided by Doug at #61 provide examples of code blocks with cell metadata. The first and fourth link point to ORG to Notebook converters, writen in Emacs Lisp.
Interesting facts:
- ORG is not markdown! If we want to support styling, round trip conversion is going to be tough!
- ORG can include results. Currently Jupytext supports no format with outputs. Probably we don't want to implement the matching with Jupyter outputs.
- More generally, ORG has support for many features that are not in Jupyter notebooks (tables, etc...). Is it acceptable for the users to have them, say, as raw cells in Jupyter?
from jupytext.
Maybe org-mode and jupytext aren't going to be a good match afterall. But my friends are still on the quest for combining emacs + notebooks...
from jupytext.
No problem! @dsblank , we'll try to make your friends happy ๐
Could you ask them to write a sample org file with text, code, a header, and a few org specific sections, and tell us how they imagine the corresponding notebook? Or even, could they contribute a test similar to test_read_simple_julia.py, but for org mode?
from jupytext.
Whatโs the current state with this? Do you already have something to work on? Iโd like to help.
from jupytext.
Oh, that's interesting! What we could do, then, is to use ox-ipynb
on one side, and pandoc
on the other side, plug this into Jupytext's collection of test notebooks, and see how well this work ๐ (or not). If time permits I will give it a try!
from jupytext.
Hey, thank's for taking the time to discuss options. Another option for ipynb to org conversion is nbcorg. I'm using nbcorg
and ox-ipynb
at the moment. That works well but I'd like to have a emacs independet solution that works from jupyter and the command-line. That is what brings me here. As a nbconvert
plugin nbcorg
uses jinja
templates.
I will have a look at jupytext-reads
and jupytext-writes
. @jkitchin, you are right. I'm not sure about how to deal with results too. nbcorg
includes results as EXAMPLE
blocks what I'm not a fan about.
from jupytext.
Okay, I just realised that for markdown you use pandoc
under the hood as well. I will write a round trip conversion test first, then. I don't know when I find the time to work on this but probably sometime within the next week.
from jupytext.
Wow, thank you! Iโll have a look. Removing results before converting to text and just adding them back to the notebook version is a nice approach; good to know about it.
from jupytext.
Recent developments on the Pandoc side of things: jgm/pandoc#6367 (comment)
from jupytext.
Related Issues (20)
- Use callback to frontend extension Settings change to add/remove entries to launcher and main menu
- Unable to unpair ipynb in jupyter notebook HOT 7
- Add Galata UI tests for notebook
- Replace toml package with tomli HOT 3
- Panel widget event triggers are not working in py:percent notebooks HOT 2
- Write temporary notebooks to a `TemporaryDirectory` rather than `NamedTemporaryFile`
- feature request: automatic creation of missing notebooks for use after git clone
- Using jupytext in a nested project can result in re-import of the current module HOT 2
- Enable the discussions section for the repository HOT 2
- The Jupytext pre-commit hook fails to install when node is not available HOT 2
- Ability to specify jupytext as the viewer via URL HOT 5
- --sync: avoid updating timestamp of *.py if nothing changes HOT 11
- jupytext-config set-default-viewer failing with a miniconda install on Windows 10 HOT 2
- Convert Jupyter Notebooks with R code cells to ```r code cells
- Automatic code cell detection HOT 3
- Jupytext corrupts original notebook with base64 of pair HOT 1
- Allow to provide the output argument when providing multiple files with --set-formats HOT 1
- indented magic commands block all magic commands HOT 1
- jupytext and jupyter lite ? HOT 4
- Add CI workflow to update playwright snapshots automatically
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jupytext.