Hydrogen makes it easy to export text files to Jupyter Notebook files (
With text like the following, running "Hydrogen: Export Notebook" will export code and markdown cells to a Notebook file of your choosing.
# %% print('Hello, world!') # %% markdown # A **Markdown** cell!
Use a special inline comment to distinguish the beginning of code cells and markdown cells. The inline comment must start with the comment character registered in the language's grammar file.
After the comment character, you need to add one space plus any of the following markers on the same line:
In(you can have any number of digits or spaces in the brackets)
For example, the following text corresponds to three code cells in a Python file
# %% print('Hello, world!') # <codecell> print('foo') # In print('bar')
These are the same cell markers used by "Hydrogen: Run Cell".
You can also create cells with Markdown-formatted text. Just as for code cells, there are a range of allowed markers to delimit the start of a markdown cell:
Each line of text in the cell's body should be prefixed by the language's comment character. Any common leading whitespace in the cell will be stripped, so the body text can include a space after the comment symbol without having leading whitespace in the output and with indented lists keeping their structure.
For example, here are two markdown cells in a Python file
# %% [markdown] # _italic text_ # **bold text** # <markdown> # - Indented # - Lists
the two cells would be exported without any common leading whitespace as
_italic text_ **bold text**
- Indented - Lists
Hydrogen doesn't support the export of raw cells at this time.