Chemical Equation Rendering Pipeline
Overview
This diagram traces the complete pipeline that transforms $\ce{H2O}$ written
in a generated markdown file into a beautifully typeset chemical formula in the browser.
The pipeline begins with CLAUDE.md — the project rulebook that instructs the
chapter-content-generator skill to use dollar notation exclusively — and then
passes through five processing layers: Python extension, build, browser loading,
and MathJax rendering.
Hover over each node to read a detailed explanation of that step.
Pipeline Steps
- CLAUDE.md prerequisite — Must specify the dollar notation rule; instructs the content generator to never use backslash notation
- chapter-content-generator skill — Reads
CLAUDE.mdand generates.mdcontent using$...$and$\ce{...}$ - arithmatex intercepts —
pymdownx.arithmatexcaptures$delimiters before Python-Markdown runs - Protected spans — Math content is wrapped in
<span class="arithmatex">and converted to\(...\)internally - Python-Markdown runs — Processes headings, links, lists with math content safely isolated
- MkDocs assembles — Builds the full HTML page with all CSS and JS references
- Browser loads — Page loads with equations as unrendered protected spans
- mathjax-config.js — Declares the
mhchempackage and sets delimiters; must load before the CDN bundle - MathJax CDN — Full
tex-chtml.jsbundle loads (full bundle required for mhchem) - DOM scan — MathJax finds all
\(...\)and\[...\]spans queued for typesetting - mhchem extension — Processes
\ce{...}into proper chemical notation with subscripts, arrows, and charges - Rendered output — Final typeset equations and chemical formulas appear to the reader
Key Design Decision
The pymdownx.arithmatex extension (with generic: true) acts as a protective
shield. By intercepting $ delimiters before Python-Markdown processes the
document, it prevents the Markdown parser from misinterpreting chemical formulas
that contain [] or () — which look identical to Markdown link syntax.
The rule: Always write $ and $$ in markdown. Never write \(...\) or
\[...\] directly in .md files.
This rule must be encoded in CLAUDE.md so the chapter-content-generator skill
enforces it automatically. Without the explicit instruction in CLAUDE.md, an AI
content generator defaults to backslash notation, which breaks the pipeline.