pip install beetroot
From the command-line, using the markdown backend:
br_export --backend markdown path/to/notebook.ipynb path/to/output_directory
As a Python API:
import json
from pathlib import Path
from beetroot.markdown.api import export_markdown_notebook
# Input and output paths
nb_path = Path('path/to/notebook.ipynb')
output_path = Path('path/to/output/directory')
# Load the notebook contents as JSON
nb_json = json.loads(nb_path.read_text())
# Export the notebook
markdown, completions = export_markdown_notebook(nb_json)
# Run the completion to write all external files
for completion in completions:
completion(output_path)
# Write the markdown to an output file
md_filename = output_path / nb_path.with_suffix('.md').name
with open(md_filename, 'w') as md_file:
md_file.write(markdown)
- Create a virtual environment for beetroot development:
python3 -m venv ~/venv/venv-beetroot-dev
source ~/venv/venv-beetroot-dev/bin/activate
- Install requirements
pip install -r requirements.dev.txt
Run the following to ensure all dependencies are generated from notebooks and notebooks are cleaned:
nbdev_export && mypy beetroot/ && nbdev_test && nbdev_clean && nbdev_clean --fname test_artifacts/ && nbdev_readme
Search for a string in all python files (.ipynb
and .py
files):
find . -name '_proc' -prune -o \( -name '*.ipynb' -o -name '*.py' \) -type f -exec grep -nH 'export_notebook' {} \;