notebook-mdx
Examples

Jupyter Notebook Demo

Live demonstration of Jupyter notebook integration with image rendering

Jupyter Notebook Demo

This page demonstrates how to embed Jupyter notebooks directly in MDX with authentic styling and image rendering.

🎯 Features

  • 📄 Direct Import: Use simple :::notebook directive syntax
  • 🎨 Authentic Styling: Matches real Jupyter notebook interface
  • 🖼️ Image Rendering: Supports PNG, JPEG, GIF, and SVG images
  • 📊 Multiple Outputs: Stream, execute_result, display_data, and error outputs
  • 🔢 Execution Counts: Proper In [n]: and Out [n]: prompts

📓 Live Notebook Display

Here's the imported notebook:

🧪 Image Output Types Supported

The notebook renderer supports all standard Jupyter image formats:

  • PNG Images: image/png - Base64 encoded
  • JPEG Images: image/jpeg - Base64 encoded
  • GIF Images: image/gif - Base64 encoded
  • SVG Images: image/svg+xml - Raw SVG string
  • HTML Content: text/html - Rich HTML outputs
  • JSON Data: application/json - Formatted JSON display

🎛️ How It Works

  1. Remark Plugin: remarkNotebookDirective processes :::notebook directives
  2. File Loading: Notebook files are loaded and parsed at build time
  3. Component Rendering: React components render each cell with proper styling
  4. Image Processing: Base64 images are converted to data URLs
  5. Metadata Handling: Image dimensions and other metadata are preserved

💡 Usage Example

# My Documentation

:::notebook{file="./my-notebook.ipynb"}
Description of the notebook
:::

This approach allows you to version control your notebooks and display them with full fidelity in your documentation!