A Jupyter Notebook Sphinx reader built on top of the MyST markdown parser.
—
Complete command-line interface for project creation, notebook conversion, and document generation across multiple output formats. The CLI provides standalone tools for MyST-NB functionality outside of Sphinx.
Command-line tool for creating new MyST-NB projects with proper structure and configuration.
def quickstart(args: list[str] | None = None) -> None:
"""
Create a new MyST-NB project with basic structure and configuration.
Parameters:
- args: Optional command-line arguments list
Creates directory structure, configuration files, and example notebooks.
"""CLI Entry Point: mystnb-quickstart
Convert MyST markdown files to Jupyter notebook format.
def md_to_nb(args: list[str] | None = None) -> None:
"""
Convert MyST markdown to Jupyter notebook format.
Parameters:
- args: Optional command-line arguments list
Converts .md files with notebook content to .ipynb format
while preserving cell structure and metadata.
"""CLI Entry Point: mystnb-to-jupyter
Direct document generation using docutils backend for various output formats.
def cli_html(argv: list[str] | None = None) -> None:
"""
Generate HTML output from notebook using docutils.
Parameters:
- argv: Command-line arguments for HTML generation
Processes notebook and generates standalone HTML document.
"""CLI Entry Point: mystnb-docutils-html
def cli_html5(argv: list[str] | None = None):
"""
Generate HTML5 output from notebook using docutils.
Parameters:
- argv: Command-line arguments for HTML5 generation
Processes notebook and generates HTML5 document with modern features.
"""CLI Entry Point: mystnb-docutils-html5
def cli_latex(argv: list[str] | None = None):
"""
Generate LaTeX output from notebook using docutils.
Parameters:
- argv: Command-line arguments for LaTeX generation
Processes notebook and generates LaTeX document suitable for PDF compilation.
"""CLI Entry Point: mystnb-docutils-latex
def cli_xml(argv: list[str] | None = None):
"""
Generate XML output from notebook using docutils.
Parameters:
- argv: Command-line arguments for XML generation
Processes notebook and generates structured XML document.
"""CLI Entry Point: mystnb-docutils-xml
def cli_pseudoxml(argv: list[str] | None = None):
"""
Generate pseudo-XML output from notebook using docutils.
Parameters:
- argv: Command-line arguments for pseudo-XML generation
Processes notebook and generates pseudo-XML for debugging document structure.
"""CLI Entry Point: mystnb-docutils-pseudoxml
# Create a new MyST-NB project
mystnb-quickstart
# Interactive prompts will ask for:
# - Project name
# - Author name
# - Initial configuration options
# - Example notebook creationThis creates a directory structure like:
my-project/
├── conf.py
├── index.md
├── notebooks/
│ └── example.ipynb
└── _build/# Convert MyST markdown to notebook
mystnb-to-jupyter my-notebook.md my-notebook.ipynb
# Convert with execution
mystnb-to-jupyter --execute my-notebook.md my-notebook.ipynb
# Convert multiple files
mystnb-to-jupyter notebooks/*.md --output-dir converted/# Generate HTML from notebook
mystnb-docutils-html notebook.ipynb output.html
# Generate with custom CSS
mystnb-docutils-html --stylesheet-path custom.css notebook.ipynb output.html
# Generate HTML5 with modern features
mystnb-docutils-html5 --math-output=mathjax notebook.ipynb output.html# Generate LaTeX
mystnb-docutils-latex notebook.ipynb output.tex
# Generate with custom document class
mystnb-docutils-latex --documentclass=article notebook.ipynb output.tex
# Process with pdflatex
mystnb-docutils-latex notebook.ipynb output.tex && pdflatex output.tex# Generate structured XML
mystnb-docutils-xml notebook.ipynb output.xml
# Generate pseudo-XML for debugging
mystnb-docutils-pseudoxml notebook.ipynb debug.xml# Process multiple notebooks to HTML
for notebook in notebooks/*.ipynb; do
mystnb-docutils-html "$notebook" "html/$(basename "$notebook" .ipynb).html"
done
# Convert all markdown notebooks
find . -name "*.md" -type f -exec mystnb-to-jupyter {} {}.ipynb \;Most CLI commands accept standard docutils options:
# Common options across commands
--config-file CONFIG_FILE # Use custom configuration
--output-encoding ENCODING # Set output encoding
--language LANGUAGE # Set document language
--title TITLE # Set document title
--stylesheet-path PATH # Custom stylesheet
--template TEMPLATE # Custom template
# MyST-NB specific options
--execution-mode MODE # Set execution mode
--execution-timeout SECONDS # Set execution timeout
--remove-code-source # Hide source code
--remove-code-outputs # Hide outputs# In Makefile
html:
find notebooks/ -name "*.ipynb" -exec mystnb-docutils-html {} docs/{}.html \;
# In GitHub Actions
- name: Generate documentation
run: |
for nb in notebooks/*.ipynb; do
mystnb-docutils-html "$nb" "docs/$(basename "$nb" .ipynb).html"
doneCLI commands provide detailed error reporting:
# Check syntax and execution
mystnb-to-jupyter --validate notebook.md
# Generate with error reporting
mystnb-docutils-html --traceback notebook.ipynb output.htmlThe CLI tools integrate with MyST-NB's configuration system and provide the same functionality as the Sphinx extension in standalone form, making them suitable for custom build pipelines and automated processing workflows.
Install with Tessl CLI
npx tessl i tessl/pypi-myst-nb