Jupyter Notebook Integration
This blog supports Jupyter notebooks (.ipynb files) by converting them to Markdown, allowing you to share interactive code and mathematical formulations directly with your readers.
Environment Setup
Section titled “Environment Setup”The Python environment is managed with uv and direnv for maximum performance and stability:
- Auto-activation:
direnvautomatically activates the virtual environment when you enter the project directory. - Dependency Management: All requirements are pinned in
requirements.txt.
First-Time Installation
Section titled “First-Time Installation”# Sync dependenciesuv pip install -r requirements.txt
# Allow direnv to manage the environmentdirenv allow .Creating a Blog Post from a Notebook
Section titled “Creating a Blog Post from a Notebook”- Write your Notebook: Save your
.ipynbfile in thenotebooks/directory. - Convert: Run the conversion script provided in the repository.
python3 scripts/convert-notebook.py notebooks/your-notebook.ipynbThis script performs several automated tasks:
- Converts cells to Markdown.
- Adds appropriate frontmatter (defaulting to
topic: blogandaccessLevel: public). - Relinks and moves generated images (plots, figures) to the correct asset directory.
- Handles LaTeX equations ($E=mc^2$) so they render beautifully using KaTeX.
Features Supported
Section titled “Features Supported”- ✅ Syntax Highlighting: Automatic for Python, JavaScript, and more.
- ✅ Mathematical Equations: Full support for inline (
$...$) and block ($$...$$) LaTeX. - ✅ Rich Outputs: DataFrames, plots, and console outputs are preserved.
- ✅ Access Control: You can set the
accessLevelin the frontmatter of the converted Markdown.
Best Practices
Section titled “Best Practices”- Run All Cells: Ensure you execute your notebook before conversion so that the outputs are correctly captured.
- Review Frontmatter: After conversion, check the generated
.mdfile to verify the title and tags are what you intended. - Draft Status: Converted posts are set to
draft: trueby default. Set this tofalsewhen you’re ready to publish.