-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: Enable page creation from Jupyter notebook file (*.ipynb) #3168
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
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for this great PR! I'll try to review it in more details soon, but I'll definitely include it in the upcoming 3.0 release.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: This feature is related to the request in https://requarks.canny.io/wiki/p/notebooks-jupyter-or-observable. We use Wiki.js in my research group and it has been great so far! However we rely a lot on Jupyter notebooks (see https://jupyter.org/try for examples), and Wiki.js was lacking the ability to have pages based on a Jupyter notebook.
Example of use case: if we want to demonstrate how to run a library that we wrote, we would typically write a Jupuyter notebook which one could run directly if the .ipynb file is shared (e.g. during a workshop). However we would also want the instructions and code to be available to everyone to read easily, without downloading and running an opaque .ipynb file every time.
Disclaimer: To be clear, this does not allow code execution of the Jupyter notebook cells in the browser, it only renders the notebook nicely (similar to https://nbviewer.jupyter.org/ for example).
Here is the breakdown of the pull request content:
I created a new Rendering module called
ipynb-core
, which relies on the npm packagenotebooksjs
(https://github.com/jsvine/notebookjs) to parse the notebook content into HTML. The notebook looks like a regular page with code blocks for the Jupyter notebook cells.Screenshot from 2021年03月03日 18-01-45
When creating a new page, I added an option
Jupyter
in the bottom panel ("Convert from") ofeditor-modal-editorselect.vue
. Clicking on it opens theeditor-modal-media
to allow the user to select an .*ipynb file.Screenshot from 2021年03月03日 17-59-10
.ipynb
files can be edited using thecode
editor (Jupyter notebooks are at their core just a JSON file, this allows one to make minor fixes such as typos if needed without re-uploading a new .ipynb file asset). This required me to change one or two things ineditor-code.vue
which was forcing thetext/html
mime type.Screenshot from 2021年03月03日 18-00-28
The code also forced a one-to-one correspondence between editors and content types, but the
code
editor was sufficient for my purpose. I made small changes to allow the same editor to be used by different content types.https://github.com/Requarks/wiki/blob/dev/server/models/pages.js#L294
I am not familiar with Vue.js, so please let me know if I missed something. Thank you !!