Skip to main content

Render Quarto .qmd files to Markdown with figure management

Project description

quarto-prerender

Render Quarto .qmd files to Markdown, designed to work as a pre-processor for static site generators.

.qmd → .md + figures

Installation

# Requires Quarto CLI
brew install quarto  # macOS

# Install the tool
uv sync

Python Environment for Notebooks

Quarto needs a Python environment with Jupyter and your notebook dependencies (numpy, matplotlib, etc.). Create a separate data science venv:

# Create the environment
uv venv ~/envs/datascience --python 3.12

# Install packages
uv pip install --python ~/envs/datascience/bin/python \
  jupyter numpy matplotlib pandas

# Use it with quarto-prerender
quarto-prerender pages/ --python ~/envs/datascience/bin/python

Add more packages as needed for your notebooks.

Usage

# Render all .qmd files in a directory
quarto-prerender pages/

# With options
quarto-prerender pages/ \
  --cache .quarto_cache \
  --assets pages/assets/quarto \
  --force

# Watch mode
quarto-prerender pages/ --watch

# Verbose output
quarto-prerender pages/ -v

How It Works

  1. Finds all .qmd files in the target directory
  2. Runs quarto render with GFM output format
  3. Moves generated figures to assets/quarto/{path}/
  4. Fixes figure paths in the generated .md
  5. Preserves original frontmatter (public, published, etc.)

Directory Structure

pages/
├── analysis/
│   ├── report.qmd          # Source
│   └── report.md           # Generated
└── assets/
    └── quarto/             # Generated figures
        └── analysis/
            └── report_files/
                └── figure-1.png

Obsidian Integration

Use the qmd-as-md-obsidian plugin to edit .qmd files in Obsidian.

Example .qmd File

---
title: "Analysis Report"
public: true
date: 2025-01-15
tags: [ml, analysis]
execute:
  freeze: auto
jupyter: python3
---

# Model Performance

```{python}
#| label: fig-loss
#| fig-cap: "Training loss over epochs"
#| out-width: "600px"

import matplotlib.pyplot as plt
import numpy as np

epochs = np.arange(100)
loss = np.exp(-epochs/20) + 0.1 * np.random.randn(100)

plt.figure(figsize=(10, 6))
plt.plot(epochs, loss)
plt.xlabel("Epoch")
plt.ylabel("Loss")
plt.show()

## Figure Sizing

Figures are responsive by default (no fixed width). To set a specific width for a figure, use Quarto's `out-width` option:

```python
#| out-width: "600px"

For responsive images on mobile, ensure your site's CSS includes img { max-width: 100%; }.

Gitignore

Add to your content repository's .gitignore:

# Quarto cache
.quarto_cache/

# Generated figures
assets/quarto/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quarto_prerender-0.1.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quarto_prerender-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file quarto_prerender-0.1.0.tar.gz.

File metadata

  • Download URL: quarto_prerender-0.1.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for quarto_prerender-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cf2b9355d15b977ca20e3569ccd956c56c817ad11c3fb80259e367b15d52e7a2
MD5 804f32b69ed146b8b12a2152cda1f52c
BLAKE2b-256 e80f79e1a277d55a8ddb6ab5b700394667e4c78cfac02cc6fddd55139ca7753e

See more details on using hashes here.

File details

Details for the file quarto_prerender-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quarto_prerender-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8cdbeb7ac5532bcbea10d9281670f7763ddcd5d10e808c3461f77b89c8fd0ad
MD5 094050df1070faabe2d45c8147ce03ab
BLAKE2b-256 85959f1d1535d5d5f5d6c8e0eeceaeb39c2c6cc9be7f4279940aa81f20f1f3f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page