Feature Tour, Part 2: Math and Diagrams
A demonstration of build-time KaTeX equations and theme-aware Mermaid diagrams, using standard linear algebra and this site's own build pipeline as examples.
Published 2 min readCategory: Graphics
On this page
Demonstration content. This article exercises the math and diagram rendering on this site. The equations are standard textbook results.
Part 2 of the tour was published after part 3. Series follow the order the author assigns, not publication dates.
Inline and display math
Equations are written in standard Markdown math syntax and typeset with KaTeX (external link) at build time, so no math JavaScript runs in the browser. Inline math sits in a sentence: the dot product of and is .
Display math gets its own block. A rotation by in the plane:
Linear interpolation between two values, and its derivative with respect to :
Long equations scroll horizontally on narrow screens instead of overflowing the page:
Diagrams
Diagrams are written as Mermaid (external link) code blocks. They are drawn in the browser, only on pages that contain them, and redrawn when you switch between light and dark themes. The original source stays available under each diagram as a text alternative.
This flowchart shows how this site is built:
Diagram source
flowchart LR
accTitle: Site build pipeline
accDescr: Markdown files are validated, rendered to HTML, indexed for search, and deployed as static assets.
A[Markdown and MDX files] --> B{Frontmatter valid?}
B -- no --> X[Build fails with an error]
B -- yes --> C[Render static HTML]
C --> D[Generate RSS and sitemap]
D --> E[Build search index]
E --> F[Deploy static assets]A sequence diagram of what happens when you search:
Diagram source
sequenceDiagram accTitle: Client-side search sequence accDescr: The browser loads the search library, fetches only the index fragments that match the query, and renders results without contacting a search server. actor Reader participant Page as Search page participant Index as Static index files Reader->>Page: Types a query Page->>Index: Fetch matching index chunks Index-->>Page: Chunk data Page-->>Reader: Ranked results with excerpts