$ show mathjax/MathJax-demos-web
This repository is a collection of web demos and examples for MathJax version 4, the JavaScript math rendering library. It demonstrates various ways to integrate MathJax into web pages, including standard TeX/MathML input with CHTML/SVG output, equation numbering and referencing, interactive reveal/toggle steps, speech generation, and compatibility with MathJax v2 configurations. The repo also contains a substantial custom font extension named 'mathjax-newcm' (New Computer Modern) that provides extensive glyph metrics and SVG path data for mathematical typesetting, with a specific focus on braille output (the 'euro-braille' subdirectory). This font data is split into dynamic chunks loaded on demand by MathJax. The codebase is primarily illustrativeβeach demo is a self-contained HTML page with accompanying JavaScript. The custom component and TeX extension examples show how to build tailored MathJax bundles using internal APIs. The configuration converter is a standalone utility that parses legacy MathJax v2 configuration objects and generates equivalent v4 configuration. While the demos are functional and well-organized, the font data files are minified/generated artifacts that are difficult to maintain manually, and several parts rely on MathJax internal APIs that may change across versions. The euro-braille and euro-braille-old directories contain near-duplicate font data with version drift, indicating a maintenance challenge. Overall, this repo serves as a practical reference for MathJax v4 integration patterns and custom font development, but it is not a production library itself. The most reusable components are the custom component assembly pattern, the TeX extension template, and the configuration converter utility.
The LLM identified 4 files worth highlighting for reuse:
Demonstrates how to assemble a custom MathJax component by importing specific modules (TeX, MathML, CHTML, menu, a11y) from @mathjax/src and registering them with the startup loader. This pattern is reusable for creating minimal, tailored MathJax bundles for specific use cases, avoiding the full library.
Provides a template for creating a custom TeX extension in MathJax v4. It uses Configuration, CommandMap, TexError, and replaceUnicode to define new macros (e.g., \mml) with Unicode replacement. This pattern is reusable for any custom LaTeX macro or environment that needs to be registered with MathJax's input processor.
A standalone web utility that converts MathJax v2 configuration objects to v4 format. It includes a hand-written JavaScript object parser (parseObject) and a declarative mapping tree (Translate) that handles options, extensions, fonts, and renderers. This is reusable as a migration aid for projects upgrading from MathJax v2 to v4.
A lightweight utility that adds a 'Show Source' button to demo pages. It fetches the page's own source HTML, colorizes it using a simple syntax highlighter, and toggles display via a <details> element. This pattern is reusable for any documentation or demo site that wants to display source code alongside rendered output.