md2ipynb
Markdown to Jupyter Notebook converter.
Setup
[optional] Virtual environment
Make sure you have virtualenv installed.
pip install -U virtualenv
Create and activate a new virtualenv.
python -m virtualenv env
source env/bin/activate
Note: Once you are all done, you can deactivate it by running
deactivate.
Installation
The easiest way to install is through pip.
pip install -U md2ipynb
Example data
Now, to get some example data, we'll clone the repository.
# Clone the repository just to have access to the examples.
git clone git@github.com:davidcavazos/md2ipynb.git
cd md2ipynb
Note: If you make modifications to the source code and want to use that, you can install it in "editable" (development) mode.
pip install -e .For more information, see the Contribution guide.
Installing the md2ipynb module will also install the md2ipynb command line tool.
For custom preprocessing steps or integration with Python scripts,
it is also available by importing the md2ipynb module from any Python script.
Minimal example
- source: hello.md
- code: hello-world.py
Here is a minimal example on how to convert a Markdown file.
By default, the output is printed into stdout.
md2ipynb examples/pages/hello.md
You can also specify an output path with the -o or --output option.
md2ipynb examples/pages/hello.md -o examples/notebooks/hello.ipynb
Here is the generated notebook on Colab and GitHub.
|
|
|
Example
- source: hello.md
- code: hello-world.py
- import: license.md
- import: setup-py.md
- import: cleanup.md
Here is a more complete example on specifying an output path, import sections, variables, as well as more metadata for a Colab visualization.
md2ipynb examples/pages/hello.md \
-o examples/notebooks/hello.ipynb \
--imports examples/templates/license.md:0 \
examples/templates/setup-py.md:1 \
examples/templates/cleanup.md:-2 \
--var package=md2ipynb \
end_message="You're all done 🎉🎉" \
--notebook-title 'Hello md2ipynb!' \
--docs-url https://github.com/davidcavazos/md2ipynb \
--docs-logo-url https://www.tensorflow.org/images/GitHub-Mark-32px.png \
--github-ipynb-url https://github.com/davidcavazos/md2ipynb/blob/master/examples/notebooks/hello.ipynb
Note: For more information on the available options, run
md2ipynb --help.
Here is the generated notebook on Colab and GitHub.
Note that since we specified the --github-ipynb-url,
there is now an "Open in Colab" button in the GitHub ipynb file.
|
|
|
Python example
- source: hello.md
- code: hello-world.py
- import: license.md
- import: setup-py.md
- import: cleanup.md
The following example shows how to use md2ipynb as a Python module.
This example shows how to specify custom preprocessing steps, import sections,
use variables, as well as more metadata for a Colab visualization.
import md2ipynb
def add_separators(paragraphs):
for p in paragraphs:
yield '---'
yield p
yield '---'
def replace(paragraphs, old, new):
for p in paragraphs:
yield p.replace(old, new)
# Create a new IPython notebook.
notebook = md2ipynb.new_notebook(
input_file='examples/pages/hello.md',
imports={
0: ['examples/templates/license.md'],
1: ['examples/templates/setup-py.md'],
-1: ['examples/templates/cleanup.md'],
},
variables={
'package': 'md2ipynb',
'end_message': "You're all done 🎉🎉",
},
notebook_title='Hello md2ipynb!',
docs_url='https://github.com/davidcavazos/md2ipynb',
docs_logo_url='https://www.tensorflow.org/images/GitHub-Mark-32px.png',
github_ipynb_url='https://github.com/davidcavazos/md2ipynb/blob/master/examples/notebooks/hello.ipynb',
# Additional steps can be run in the order specified.
# If the generator receives multiple arguments, they can be passed as a tuple.
steps=[
add_separators,
(replace, 'Hello', 'Hi'),
],
)
# Write the notebook to a file.
import nbformat
with open('examples/notebooks/hello-custom.ipynb', 'w') as f:
nbformat.write(notebook, f)
Here is the generated notebook on Colab and GitHub.
|
|
|
Contributing
Contributions are welcome! For instructions on how to contribute, please check the Contribution guide.
Metadata
Release files for md2ipynb 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| md2ipynb-0.2.1.tar.gz | 17.6 kB | Without provenance | Details for md2ipynb-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| md2ipynb-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for md2ipynb-0.2.1-py3-none-any.whl |
Total release size: 59.8 kB
Release files / md2ipynb-0.2.1.tar.gz
| Download URL | md2ipynb-0.2.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36325aa9656039f8a4f9b1a1d1483caab0523ced58d8184d0fa06798fc2ec485
|
|
BLAKE2b-256 checksum How to use checksums |
53b59bcd850d93125b832f1b0a7ee01c174ed924349a9acb855138d115673d82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
|
Release files / md2ipynb-0.2.1-py3-none-any.whl
| Download URL | md2ipynb-0.2.1-py3-none-any.whl |
|---|---|
| Size | 42.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
172ab5afaabef884d0640d582a8883d4e9936aae482dd164e1fbb1aaa40f9b72
|
|
BLAKE2b-256 checksum How to use checksums |
ebf1dad4e8a88f652d991a4b9a124f1a157224eaf48dc5938eb4015f36d9d3d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
|
Security for md2ipynb 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.