How to view a markdown file in jupyter lab properly? - jupyter-notebook

How to view a markdown file in Jupyter lab properly?
The readme file of a git project is written in markdown, as usual. How can one properly view it in Jupyter lab (rendered)? Currently I see the text version only.

A good solution is shown here in the
youtube video
Open the file, right click on the content, "Show markdown preview"

Right click on the open markdown text editor area and you should get a menu option "Show markdown preview". Select that and it will render the text into markdown in another window (side by side by default)

Related

Numbered heading in markdown

I have starting using jupyter notebook and jupyter lab, and in markdown cells the heading formatting is shown with numbers, how to have heading not to show numbers or better how to decide when and where to show heading numbers?
In jupyter lab you can show the "Table of Content" view in the left pane. In the toolbar of the pane there is a button for "Toggle Auto Numbering"
In classic notebook interface I don't know how to do the same, but luckily I don't use classic notebook.

How to view .ipynb as regular text intsead of an ipython notebook in vscode

VS code recently added the ability to work with jupyter notebooks (.ipynb files), this is to say it renders them as notebooks and not the underlying text.
The problem I'm running into is I want to make some edits on the raw text rather than the "notebook" but I can't figure out how to show it as a text file the way any other editor would.
Is there a way to toggle between the views?
Disable automatically opening *.ipynb files in Notebook Editor
To make sure the Jupyter notebooks don't open in the Notebook Editor automatically, make sure to disable this settings. (Command Palette -> Settings)
OR
In the User or Workspace settings.json, add the following the root json - "jupyter.useNotebookEditor": false
To toggle between the Notebook Editor and Raw Text Mode Editing
There is an option/command called Reopen Editor with..., which will provide you options to open the *.ipynb file in text mode.
You trigger this by performing a Right Click on the Editor Tab (Editor Title Bar) or Command Palette -> Reopen Editor with...
PS: I have the Jupyter extension (v2020.12.414227025)
Open: File > Preferences > Settings
Search ipynb and deselect the following:
Other answers didn't work for me recently. I found no "use notebook editor" option under preferences, perhaps vs code has reorganized recently. Instead I found the following solution. Right click on an *.ipynb file tab to get the context menu, and click "Reopen Editor With..." as pictured below.
Then on the following popup click "configure default editor for .ipynb", and then click on the text editor as seen below:
And viola. The default settings have been changed.
I think the fastest way is to rename the file.
Just press F2 (or return for mac) while selecting the file in the vscode explorer, then rename from my-notebook.ipynb to my-notebook.json, because jupyter ipynb files are regular json files
Create .json file and paste the notebook json in there, save the file and then rename the extension to .ipynb and it will open in the jupyter editor
(Similar to aquirdturtle's answer)
What about
On the left side explorer
Right Click on file -> Open With -> Text Editor
Set the setting
"files.associations": {
"*.ipynb": "text"
}
Or try click on the Status Bar field that shows the Language Mode of the file in the lower right.
Use the command: Change Language Mode

How do you link to a slide in a Jupyter Notebook saved as Reveal.JS?

When I download a Jupyter Notebook as slides, the links are not active (i.e. they don't take you anywhere). How do I link a table of contents page to the respective slides?
Linking to a cell can be done by anchoring it and then calling it later see answer here (e.g. place<a id="another_cell"></a> in the desired cell to jump to and place [Another Cell](#another_cell) where you'd click "Another Cell"). This works fine in an download of the Reveal.JS as a PDF, but not when doing slides.
Current code to publish with nbconvert:
jupyter nbconvert SOME_NOTEBOOK.ipynb
--to slides
--output-dir .\SOME_FOLDER
--SlidesExporter.reveal_theme=serif
--SlidesExporter.reveal_scroll=True
--SlidesExporter.reveal_transition=none
--TemplateExporter.exclude_input=True
--TemplateExporter.exclude_output_prompt=True
--reveal-prefix=./lib/reveal.js-3.8.0
You can try this:
Slide number 2
Note:
The slide count starts after the slide that has the table of contents.

How can I make a presentable PDF from a Jupyter Notebook?

I know that I can click on File -> Print Preview and let my browser save the result as a PDF. But that PDF will contain quite a bit of code.
Can I hide parts from the print preview or make a PDF with another tool?
Ideally, there would be magic functions:
%hide: Hide the cell and its output
%hide-code: Hide only the code of the cell, but show the output of the code
Print to PDF in the browser
In JupyterLab, you can hide the cell's input and output by clicking the side bar as demonstrated in the doc. After hiding, you can use the browser's printing menu to generate a PDF. I've tested it on FireFox and expect similar result on Chrome or Edge.
Export to PDF with nbconvert
If you aim at a native conversion from ipynb format to pdf, the nice old nbconvert tool is your friend. It usually comes together with Jupyter and can be invoked conveniently in the menu of JupyterLab File->Export Notebook As...->PDF or, in the classic Jupyter Notebook interface, File->Download as->PDF (via LaTeX).
Hiding input/output in cells can be realized by setting the cell's metadata hide_input=true and installing a nbextension as discussed in issue #155.
Print Preview menu in the classical Jupyter
Finally to your question
Can I hide parts from the print preview or make a PDF with another tool?
The "print preview" button in the classical Jupyter interface is a shortcut for calling nbconvert to generate a HTML file and redirect your browser to it. Therefore, similar configuration for nbconvert to hide input as discussed above (in issue #155) can be used. This feature is implemented by jupyter_contrib_nbextensions bundle and explained in the doc.
As the above-mentioned answers do not work for me; I found another solution:
I use an additional package notebook-as-pdf.
Read the tutorial here. It uses Chromium and is the only approach that worked for me so far reliably. The "print preview" does still not work. But it produces a clean PDF with no code input.
I do:
pip install -U notebook-as-pdf
pyppeteer-install
jupyter nbconvert --to PDFviaHTML --TemplateExporter.exclude_input=True PATH_TO_YOUR_FILE.ipynb
What did NOT work for me:
The solution above.
All the scripts mentioned in those answers

Hyperlink that can lead to a pdf in Jupyter notebook

I'm working with Jupyter notebook and have a question in mind:
If I want to markdown an HTML file or any website, I can just simply do
[name-of-the-website](address-here)
and it will create a link to the page that I want to reference
My question is
Are there any markdown code for PDF reference
IS the code the same with HTML reference (whenver I click into the markdown link, It will create a new tab which can download the file to the computer)
P/s: I'm not talking about coverting the notebook into PDF file
I have found out an answer:
Go to the file PDF that you want to download, for example I want to download this PDF file
Ideas:
Because there should be a HTML link to download the document, if one can find this link, then can proceed to normal markdown HTML file in Jupyter Notebook
Steps:
On the browser, right-click that PDF download link, and then choose Inspect Element (Q) (on Firefox or any browser in use)
It is then open the console that will shown the download HTML file like shown:
href="http://www.montefiore.ulg.ac.be/services/stochastic/pubs/2009/DMWG09/dumont-visapp09-shortpaper.pdf"
One can proceed with normal markdown in Jupyter Notebook
This works for me:
ref.
This is a relative path to the file.

Resources