Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
1db91dd
Created pr-specrs for TML Math Output Options and Browser Render Script
OlgaRedozubova Jan 29, 2026
3d58d65
Added HTML Math Output Options and Browser Render Script
OlgaRedozubova Feb 4, 2026
beab102
Updated pr-specs/2026-01-html-math-output-options.md
OlgaRedozubova Feb 4, 2026
1f89c9c
Updated pr-specs/2026-01-html-math-output-options.md
OlgaRedozubova Feb 4, 2026
075bcf4
Set version 2.0.34
OlgaRedozubova Feb 4, 2026
d61bab5
Updated doc/changelog.md
OlgaRedozubova Feb 4, 2026
65958f2
Updated README.md
OlgaRedozubova Feb 4, 2026
930df36
Fixed: When output_format is 'mathml', include_mathml is not set to t…
OlgaRedozubova Feb 5, 2026
27d6755
Fix the auto-render script to apply these attributes: data-width, dat…
OlgaRedozubova Feb 5, 2026
501fc1a
Added the style scoped to .math-block[data-width=full] so it only aff…
OlgaRedozubova Feb 5, 2026
826e16d
Updated doc/changelog.md
OlgaRedozubova Feb 5, 2026
22fc266
Merged the master branch and resolved conflicts
OlgaRedozubova Feb 9, 2026
609a33a
Set version 2.0.35
OlgaRedozubova Feb 9, 2026
746ee14
Add separate add-speech.js browser bundle for SVG accessibility
OlgaRedozubova Feb 9, 2026
55ea461
Fixed the document.createElement issue
OlgaRedozubova Feb 9, 2026
e4f746a
Fixed speech-rule-engine@4.0.7 to prevent browser compatibility issue…
OlgaRedozubova Feb 10, 2026
d539f41
Fix output_format routing, include_svg override, highlight null guard…
OlgaRedozubova Feb 10, 2026
46c30df
Fix output_format routing, a11y consistency, and browser bundle defaults
OlgaRedozubova Feb 10, 2026
c02971a
Added tests to check output_format, auto_render and add_speech scripts
OlgaRedozubova Feb 10, 2026
aba3164
Weak speech assertion in _add_speech.js: speech.length.should.be.abov…
OlgaRedozubova Feb 10, 2026
5569fc9
Merged the master branch and resolved conflicts
OlgaRedozubova Feb 16, 2026
d4bbda6
Set version 2.0.36
OlgaRedozubova Feb 16, 2026
23d1939
Removed installation of additional formats from defaultConfig for aut…
OlgaRedozubova Feb 17, 2026
eebb12b
Added previewUuid to MathpixRenderConfig
OlgaRedozubova Feb 17, 2026
119cfa9
Add SerializedTypstVisitor for native Typst math output
OlgaRedozubova Feb 17, 2026
f9114d2
Fix Typst visitor: spacing, lr(), binom, oint, underline, cancel, mstyle
OlgaRedozubova Feb 17, 2026
b064191
Fix Typst edge cases: mphantom, mlabeledtr, binom choose, negated sym…
OlgaRedozubova Feb 17, 2026
a1cd616
Fix Typst: big delimiters, non-shorthand accents, mathit, int limits …
OlgaRedozubova Feb 17, 2026
cbf5d62
Fix Typst: text spacing, thin space preservation, operator-internal d…
OlgaRedozubova Feb 18, 2026
bc8d5d4
Add Typst optimizations: operatorname, mathbb shorthand, norm/floor/c…
OlgaRedozubova Feb 18, 2026
a78710f
Fix Typst: stackrel/limits, primes, comma spacing, parallel, nmid, Vm…
OlgaRedozubova Feb 18, 2026
02b24c6
Fix Typst: extensible arrows limits, literal parens in superscripts, …
OlgaRedozubova Feb 18, 2026
b509f09
Add missing Typst symbols: harpoons, triangles, wreath, amalg, mathri…
OlgaRedozubova Feb 18, 2026
817be22
Fix Typst: numcases and subnumcases environments produce cases() output
OlgaRedozubova Feb 18, 2026
023847d
Fix Typst: big delimiter mapping, missing symbols, native large opera…
OlgaRedozubova Feb 18, 2026
3ef2cd2
Fix Typst: add leftrightarrow to accent map for overleftrightarrow
OlgaRedozubova Feb 18, 2026
70de660
Add long-tail Typst symbol mappings: arrows, relations, geometry, sui…
OlgaRedozubova Feb 18, 2026
c7c5c2d
Add array lines (augment) and equation tags to Typst mtable handler
OlgaRedozubova Feb 18, 2026
a05910c
Add missing Typst accent mappings: dot.triple, dot.quad, acute.double…
OlgaRedozubova Feb 18, 2026
7956361
Add mmultiscripts handler, fix limits placement, update deprecated Ty…
OlgaRedozubova Feb 18, 2026
f0747ec
Fix invalid Typst symbol names and delimiter handling
OlgaRedozubova Feb 18, 2026
98ebcf3
Add output_format option, auto-render & add-speech browser bundles
OlgaRedozubova Feb 18, 2026
bee5fb5
Update docs: fix checkboxes, add previewUuid, fix typo
OlgaRedozubova Feb 18, 2026
c321258
Add Typst format to context menu for copying Typst math output
OlgaRedozubova Feb 18, 2026
a5f40d7
Merge pull request #400 from Mathpix/dev/olga/Add-option-to-display-m…
OlgaRedozubova Feb 18, 2026
a87fac1
Fix Typst conversion for empty-base scripts, operator-paren spacing, …
OlgaRedozubova Feb 18, 2026
4c23040
Fix phantom handler, add mathrm/substack/mod tests, and add PR spec
OlgaRedozubova Feb 19, 2026
c386ccb
Merged the master branch and resolved conflicts
OlgaRedozubova Feb 19, 2026
0a69464
Escape literal slash in Typst output to prevent unintended fractions
OlgaRedozubova Feb 19, 2026
e19468f
Fix missing token spacing inside \left...\right delimiters
OlgaRedozubova Feb 19, 2026
9a4e623
Distinguish auto-numbered equations from explicit \tag in Typst output
OlgaRedozubova Feb 19, 2026
433b956
Update PR spec with slash escaping and auto-numbering detection
OlgaRedozubova Feb 19, 2026
66dd21e
Emit multi-row numbered equations as separate math.equation blocks
OlgaRedozubova Feb 19, 2026
f147332
Handle math content inside \tag labels in Typst output
OlgaRedozubova Feb 19, 2026
96548af
Update PR spec with serializeTagContent and multi-row equation details
OlgaRedozubova Feb 19, 2026
36ab707
Add grid layout for numcases/subnumcases with per-row numbering
OlgaRedozubova Feb 19, 2026
984065c
Update PR spec with numcases grid layout and toTypstML regex fix
OlgaRedozubova Feb 19, 2026
d168720
Fix numcases detection for empty prefix and label-cell explicit tags
OlgaRedozubova Feb 19, 2026
be7a28c
Update PR spec with empty-prefix numcases and dual tag detection
OlgaRedozubova Feb 19, 2026
48460c8
Rebuild
OlgaRedozubova Feb 19, 2026
f3fb1dd
Escape top-level commas in numcases single-cell rows
OlgaRedozubova Feb 19, 2026
7fe866d
Rebuild es5 bundles
OlgaRedozubova Feb 19, 2026
afab5de
Update PR spec with comma escaping example for numcases
OlgaRedozubova Feb 19, 2026
875a839
Escape commas in regular cases() rows, not just numcases
OlgaRedozubova Feb 19, 2026
d1defec
Update PR spec: comma escaping applies to regular cases too
OlgaRedozubova Feb 19, 2026
33eb919
Detect paired delimiters (\lfloor, \lceil, \|) without \left...\right
OlgaRedozubova Feb 20, 2026
9722936
Update PR spec: bare delimiter-pair detection for floor/ceil/norm
OlgaRedozubova Feb 20, 2026
045b96c
Allow math conversion when forLatex is true and include_typst is requ…
OlgaRedozubova Feb 20, 2026
85e537b
Add typst_inline dual format: block vs inline Typst output
OlgaRedozubova Feb 20, 2026
a7e553b
Add label support for equations and fix numcases counter pattern
OlgaRedozubova Feb 23, 2026
c84a510
Fix equation counter for explicit \tag{} in Typst output
OlgaRedozubova Feb 23, 2026
9bed5e0
Update build artifacts and type declarations
OlgaRedozubova Feb 23, 2026
10e17cd
Update PR spec: labels, counter rollback, numcases fixes
OlgaRedozubova Feb 23, 2026
8573494
Escape dollar sign and thousand-separator commas in Typst math
OlgaRedozubova Feb 23, 2026
b6f49c3
Update type declarations
OlgaRedozubova Feb 23, 2026
f09f3e0
Update PR spec: dollar sign escaping and thousand-separator commas
OlgaRedozubova Feb 23, 2026
013a1ec
Fix thousand-separator commas inside nested constructs like underline
OlgaRedozubova Feb 23, 2026
2fafc8b
Update common.d.ts type declaration
OlgaRedozubova Feb 23, 2026
a4a8166
Update PR spec: isThousandSepComma helper in nested contexts
OlgaRedozubova Feb 23, 2026
9a20538
Re-build
OlgaRedozubova Feb 23, 2026
1f91b38
Fix \wp Typst output: use Unicode ℘ instead of undefined symbol name
OlgaRedozubova Feb 23, 2026
02c2289
Fix 14 invalid Typst symbol names in typst-symbol-map
OlgaRedozubova Feb 23, 2026
f2feec4
Update PR spec: symbol map validation and 14 fixed symbol names
OlgaRedozubova Feb 23, 2026
78aa69e
Add 141 symbol tests and fix 4 more invalid Typst symbol names
OlgaRedozubova Feb 23, 2026
70c2cf9
Update PR spec: add cong, mid, nothing, corner fixes to symbol table
OlgaRedozubova Feb 23, 2026
6772640
Guard empty content in munderover, mmultiscripts, mn handlers
OlgaRedozubova Feb 23, 2026
235fa40
Update PR spec: document empty-content protection for Typst handlers
OlgaRedozubova Feb 23, 2026
c1a9ba7
Fix negthin and custom named operators in Typst output
OlgaRedozubova Feb 24, 2026
c17797e
Update PR spec: negthin skip and mo operator detection
OlgaRedozubova Feb 24, 2026
405bab7
Implement movablelimits-aware limits/nolimits placement for Typst output
OlgaRedozubova Feb 24, 2026
864cfc6
Update PR spec: document limits/nolimits placement logic
OlgaRedozubova Feb 24, 2026
23b9af3
Fix operator limits, delimiter mapping, and code quality in Typst ser…
OlgaRedozubova Feb 24, 2026
fbfd913
Rebuild es5 bundles
OlgaRedozubova Feb 24, 2026
0344ac4
Update PR spec: document abs/norm fix, idotsint, trig \limits, needsT…
OlgaRedozubova Feb 24, 2026
e039a1b
Add & alignment markers to equation arrays (aligned, align, split)
OlgaRedozubova Feb 24, 2026
63a57cb
Re-build
OlgaRedozubova Feb 24, 2026
f6547a1
Replace unpaired brackets with Typst symbol names in matrix/cases cells,
OlgaRedozubova Feb 24, 2026
965bc33
Update PR spec: document array alignment, unpaired brackets, and span…
OlgaRedozubova Feb 24, 2026
9548875
Wrap one-sided delimiters in lr() everywhere, not just inside mat()/c…
OlgaRedozubova Feb 24, 2026
d776990
Add multiline formatting for mat()/cases() with 3+ rows
OlgaRedozubova Feb 24, 2026
ca7ed32
Update PR spec: document multiline formatting for 3+ row mat()/cases()
OlgaRedozubova Feb 24, 2026
332286d
Drop empty superscripts/subscripts (e.g. m^{} → m) to avoid invalid T…
OlgaRedozubova Feb 25, 2026
8a3978c
Update PR spec: document empty-exponent script handling
OlgaRedozubova Feb 25, 2026
75194f4
Escape semicolons in cases() content to prevent row-separator errors
OlgaRedozubova Feb 25, 2026
85229e9
Escape commas and semicolons in mat() cells and numcases multi-cell rows
OlgaRedozubova Feb 25, 2026
95fd6e9
Update PR spec: document separator escaping in mat() and cases() cells
OlgaRedozubova Feb 25, 2026
cb63810
Lower multiline threshold to 2+ rows for mat() and cases()
OlgaRedozubova Feb 25, 2026
342459a
Update PR spec: lower multiline threshold to 2+ rows
OlgaRedozubova Feb 25, 2026
3a94deb
Fix \textit not producing italic() in Typst output
OlgaRedozubova Feb 25, 2026
c515e9c
Update PR spec: document \textit and \textbf font handling
OlgaRedozubova Feb 25, 2026
1f15490
Fix overbrace/underbrace annotations to use second argument syntax
OlgaRedozubova Feb 25, 2026
8be49f4
Add tests for underline, overline, underbrace, and overbrace
OlgaRedozubova Feb 25, 2026
78ef6dd
Update PR spec: document underbrace/overbrace annotation syntax
OlgaRedozubova Feb 25, 2026
d8e45e6
Map \imath and \jmath to dotless.i and dotless.j in Typst output
OlgaRedozubova Feb 25, 2026
4f56d37
Update PR spec: document dotless.i and dotless.j mappings
OlgaRedozubova Feb 25, 2026
ffa51a2
Fall back to lr() for abs/norm/floor/ceil when content has top-level …
OlgaRedozubova Feb 25, 2026
2cccd7a
Update PR spec: document abs/norm/floor/ceil separator-safe lr() fall…
OlgaRedozubova Feb 25, 2026
eadbd1f
Escape semicolons inside lr() to prevent row-separator interpretation
OlgaRedozubova Feb 25, 2026
b26e2b5
Update PR spec: document semicolon escaping inside lr()
OlgaRedozubova Feb 25, 2026
ddb7f75
Use stretch() instead of limits() for extensible arrows in Typst output
OlgaRedozubova Feb 25, 2026
a359cb2
Update PR spec: document stretch() for extensible arrows vs limits() …
OlgaRedozubova Feb 25, 2026
1ace42a
Add longdiv support in Typst output: overline(")" content)
OlgaRedozubova Feb 25, 2026
9d6bb66
Update PR spec: document longdiv conversion to overline(")" content)
OlgaRedozubova Feb 25, 2026
ff9882e
Remove space between ")" and content in longdiv for tighter rendering
OlgaRedozubova Feb 25, 2026
7df5f97
Update PR spec: fix longdiv examples to show no-space format
OlgaRedozubova Feb 25, 2026
2596057
Add \enclose{circle} support in Typst output
OlgaRedozubova Feb 25, 2026
e06ee91
Update PR spec: document \enclose{circle} conversion
OlgaRedozubova Feb 25, 2026
c47ff0e
Add enclose{radical}, enclose{top}, enclose{bottom} Typst support
OlgaRedozubova Feb 25, 2026
2ec0434
Update PR spec: document enclose{radical}, enclose{top}, enclose{bottom}
OlgaRedozubova Feb 25, 2026
d45a5f5
Escape \surd (√) to \√ in Typst output to prevent sqrt operator
OlgaRedozubova Feb 25, 2026
234f2c8
Update PR spec: document \surd → \√ escaping
OlgaRedozubova Feb 25, 2026
bce6736
Fix \lcm conversion: escape unbalanced ) in menclose wrappers
OlgaRedozubova Feb 25, 2026
609c38d
Wrap hex colors in rgb("...") for valid Typst output
OlgaRedozubova Feb 25, 2026
fd784bf
Add colorbox/fcolorbox support via #highlight(fill: ...) in Typst
OlgaRedozubova Feb 25, 2026
806449c
Update PR spec: document colorbox/fcolorbox Typst conversion
OlgaRedozubova Feb 25, 2026
b02ce9f
Fix \boldsymbol losing bold for Greek letters and symbols
OlgaRedozubova Feb 25, 2026
8206112
Update PR spec: document \boldsymbol with Greek letters
OlgaRedozubova Feb 25, 2026
02ad60a
Replace unmatched brackets with Typst symbol names globally
OlgaRedozubova Feb 25, 2026
e00df74
Revert unmatched bracket replacement — too many false positives
OlgaRedozubova Feb 25, 2026
0c2306b
Add pre-serialization tree walk to mark unpaired ASCII brackets in Ty…
OlgaRedozubova Feb 25, 2026
1d94f7f
Update PR spec: document unpaired bracket escaping via pre-serializat…
OlgaRedozubova Feb 25, 2026
630895b
Escape colons in mat()/cases() cells to prevent named-argument parsing
OlgaRedozubova Feb 26, 2026
f2908c0
Update PR spec: document colon escaping in mat()/cases() cells
OlgaRedozubova Feb 26, 2026
544e547
Add tests for colon escaping in mat() and cases() cells
OlgaRedozubova Feb 26, 2026
e7e6624
Escape double-quote character in Typst math output
OlgaRedozubova Feb 26, 2026
69a7fcd
Update PR spec: document double-quote escaping in Typst math
OlgaRedozubova Feb 26, 2026
c14b591
Escape special characters (#, &, _) in Typst math output
OlgaRedozubova Feb 26, 2026
74396d2
Fix token separation for Unicode symbols in Typst output
OlgaRedozubova Feb 26, 2026
32771ce
Escape commas and semicolons in all Typst function-call wrappers
OlgaRedozubova Feb 26, 2026
27db050
Update PR spec: document separator escaping in all function-call wrap…
OlgaRedozubova Feb 26, 2026
363d0fe
Optimize mhchem phantom output in Typst serialization
OlgaRedozubova Feb 26, 2026
1311469
Update PR spec: document mhchem phantom optimization
OlgaRedozubova Feb 26, 2026
ae126c6
Fix bare delimiter pairing with scripts and add angle bracket detection
OlgaRedozubova Feb 26, 2026
0c59240
Update PR spec: document scripted delimiter detection and angle brackets
OlgaRedozubova Feb 26, 2026
f0d6d94
Escape double quotes inside mtext content in Typst output
OlgaRedozubova Feb 26, 2026
0186ef1
Update PR spec: document mtext quote escaping
OlgaRedozubova Feb 26, 2026
c163005
Fix untagged rows in equation arrays and unpaired brackets inside fences
OlgaRedozubova Feb 26, 2026
7f3c2d3
Update PR spec: document equation array wrapping and fence delimiter …
OlgaRedozubova Feb 26, 2026
99b6e87
Stop escaping ] from \right] in one-side-invisible lr() delimiters
OlgaRedozubova Feb 26, 2026
756fb51
Update PR spec: document one-side-invisible delimiter escaping rules
OlgaRedozubova Feb 26, 2026
be207d7
Fix comma/separator escaping in Typst function calls
OlgaRedozubova Feb 26, 2026
f39cf99
Switch separator escaping to official Typst backslash syntax
OlgaRedozubova Feb 26, 2026
06b8a1f
Update PR spec: backslash separator escaping, Indian numbering, frac …
OlgaRedozubova Feb 26, 2026
198ca52
Use number-align for single-tag align*/gather* environments
OlgaRedozubova Feb 27, 2026
f52957a
Update PR spec: document number-align strategy for single-tag environ…
OlgaRedozubova Feb 27, 2026
a91f9b0
Add missing number-align test cases for full spec coverage
OlgaRedozubova Mar 2, 2026
0bc049c
Merge pre-align math content into tagged equation block
OlgaRedozubova Mar 2, 2026
f2fcd4c
Update PR spec: document pre-align content merging
OlgaRedozubova Mar 2, 2026
fe4c3f9
Merge post-align math content into tagged equation block
OlgaRedozubova Mar 2, 2026
a0f8e88
Escape content-mode special chars in equation tag text
OlgaRedozubova Mar 2, 2026
dd46809
Escape mismatched delimiter pairs in lr() to prevent parse errors
OlgaRedozubova Mar 2, 2026
4c01d9d
Refactor: extract inline regex patterns into named constants in commo…
OlgaRedozubova Mar 2, 2026
530dc0c
Refactor: unify 5 escape functions into parametric scanExpression()
OlgaRedozubova Mar 2, 2026
d652440
Refactor: decompose mtable, extract helpers, improve naming
OlgaRedozubova Mar 2, 2026
03a6668
Refactor: extract bracket-utils and table-handlers from handlers.ts
OlgaRedozubova Mar 2, 2026
07fac04
Clean up comments per Mathpix coding standards
OlgaRedozubova Mar 2, 2026
092ba21
Extract constants and remove dead code
OlgaRedozubova Mar 2, 2026
28c8703
Fix mspace thick mapping, use const and includes()
OlgaRedozubova Mar 2, 2026
8597c51
Extract MSPACE_WIDTH_MAP constant for spacing values
OlgaRedozubova Mar 2, 2026
b54a3a8
Extract RE_SPECIAL_FN_CALL and UNPAIRED_BRACKET_PROP constants
OlgaRedozubova Mar 2, 2026
e901c3b
Extract addLimitsParam helper, use formatScript in idotsint, reorder …
OlgaRedozubova Mar 2, 2026
caeb946
Extract cross-file and repeated magic strings into named constants
OlgaRedozubova Mar 2, 2026
9673dbc
Replace inline /\w/ and bracket string with shared constants
OlgaRedozubova Mar 2, 2026
f886bea
Refactor serialized-typst: 6 architectural improvements
OlgaRedozubova Mar 2, 2026
a726d5e
Fix 9 code quality issues in serialized-typst handlers
OlgaRedozubova Mar 2, 2026
b7eb066
Eliminate all as-any casts from serialized-typst module
OlgaRedozubova Mar 2, 2026
eabe571
Type all node parameters with MathJax TreeNode/MmlNode types
OlgaRedozubova Mar 2, 2026
95e13d9
Replace TreeNode with extended MmlNode interface, eliminate all as-Mm…
OlgaRedozubova Mar 2, 2026
42c052b
Rename extended MmlNode to MathNode to avoid confusion with MathJax's…
OlgaRedozubova Mar 2, 2026
2f6ead9
Extract interfaces and types into types.ts module
OlgaRedozubova Mar 2, 2026
bfb2638
Extract constants into consts.ts, move local constants to file top, r…
OlgaRedozubova Mar 2, 2026
e1e9571
Remove factory pattern from handlers, move handleAll to common.ts
OlgaRedozubova Mar 2, 2026
a7c1371
Fix buildLimitBase empty base and remove spurious backslash escaping …
OlgaRedozubova Mar 2, 2026
44b45b1
Extract Unicode escape sequences into named constants in consts.ts
OlgaRedozubova Mar 2, 2026
b953bb3
Add HandlerKind union type, fix matchBraceAnnotation, use template li…
OlgaRedozubova Mar 2, 2026
69d34e3
Replace getAttributes with generic getAttrs<T> for typed attribute ac…
OlgaRedozubova Mar 2, 2026
b5bb19e
Split handlers.ts into token-handlers, script-handlers, and structura…
OlgaRedozubova Mar 2, 2026
8413964
Add generic getProp<T> wrapper for typed node property access
OlgaRedozubova Mar 2, 2026
2755fa5
Refactor table-handlers.ts: template literals, extract tag-building h…
OlgaRedozubova Mar 2, 2026
9a4b7a9
Refactor index.ts: decompose visitInferredMrowNode into pattern funct…
OlgaRedozubova Mar 2, 2026
04ab14c
Minor cleanup: remove extra blank line in escape-utils, use template …
OlgaRedozubova Mar 2, 2026
aa14a22
Minor cleanup: template literal in common.ts, remove extra blank line…
OlgaRedozubova Mar 2, 2026
a0fa2f3
Strict TypeScript typing: remove any, unsafe casts, add readonly and …
OlgaRedozubova Mar 2, 2026
7065795
Fix mmultiscripts attach positions and mo inScript check
OlgaRedozubova Mar 2, 2026
f6e3757
Fix symbol map conflicts, displaystyle check, and code quality issues
OlgaRedozubova Mar 2, 2026
08a2c9e
Fix rows mutation, separate bracket depth counters, document error ha…
OlgaRedozubova Mar 2, 2026
2aaaea4
Update PR spec to reflect module decomposition and bug fixes
OlgaRedozubova Mar 3, 2026
b119a69
Refactor handlers.ts dispatch and index.ts pattern helpers
OlgaRedozubova Mar 3, 2026
bd080d2
Harden script-handlers: regex, escaping, and minor cleanup
OlgaRedozubova Mar 3, 2026
b323fb2
Harden structural-handlers: table detection, paren escaping, mstyle b…
OlgaRedozubova Mar 3, 2026
d718c70
Harden table-handlers: tag extraction, content escaping, whitespace p…
OlgaRedozubova Mar 3, 2026
de97d52
Refactor token-handlers: extract helpers, remove try/catch, decompose mo
OlgaRedozubova Mar 10, 2026
95ccdf7
Harden escape-utils: strict types, colon source-check, unclosed strin…
OlgaRedozubova Mar 10, 2026
bb90951
Harden common.ts: remove try/catch, simplify helpers, improve docs
OlgaRedozubova Mar 10, 2026
767437d
Refactor bracket-utils: unify pairing, decompose scanner, rename helpers
OlgaRedozubova Mar 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 123 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,127 @@ import {
<img width="370" alt="Screen Shot 2022-05-03 at 17 21 50" src="https://user-images.githubusercontent.com/32493105/166471623-fd3f6a5b-84e4-4d43-afcd-0384e83eb2df.png">


## Output Format

The `output_format` option in `TOutputMath` controls which math format is placed in the HTML output. This is useful for optimizing file size or delegating rendering to the client.

| Value | Description |
|-------|-------------|
| `'svg'` (default) | Pre-rendered SVG with hidden format elements. Works offline, no client-side rendering needed. |
| `'mathml'` | Native `<math>` elements only. Smaller file size, requires client-side rendering via `auto-render.js`. |
| `'latex'` | Raw LaTeX with original delimiters. Smaller file size, requires client-side rendering via `auto-render.js`. |

### Example usage

```js
const options = {
outMath: {
output_format: 'mathml', // or 'latex'
include_mathml: true,
include_latex: true,
}
};
const html = MathpixMarkdownModel.markdownToHTML('$x^2$', options);
```

When using `'mathml'` or `'latex'`, the server outputs minimal HTML containing only the raw format. Use the browser rendering script (`auto-render.js`) to transform this into the full structure with SVG and hidden formats.


## Browser Rendering Script (auto-render.js)

For `output_format: 'mathml'` or `output_format: 'latex'`, use the browser bundle to render math on the client side.

### Loading the script

```html
<script src="https://cdn.jsdelivr.net/npm/mathpix-markdown-it@latest/es5/browser/auto-render.js"></script>
```

### Usage

```js
// Render all math elements in a container
window.MathpixRender.renderMathInElement(document.getElementById('content'), {
outMath: {
output_format: 'svg',
include_svg: true,
include_mathml: true,
include_latex: true,
include_asciimath: true,
},
accessibility: {
assistive_mml: true,
include_speech: true,
}
});
```

### Configuration options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `outMath` | `TOutputMath` | `{ output_format: 'svg', include_svg: true }` | Controls which hidden formats to generate. Set `include_mathml`, `include_latex`, `include_asciimath`, etc. to `true` to generate hidden format elements for context menu compatibility. |
| `accessibility.assistive_mml` | `boolean` | `true` | Add `<mjx-assistive-mml>` element for screen readers |
| `accessibility.include_speech` | `boolean` | `false` | Add `aria-label` with speech text (requires `assistive_mml: true`) |

### Accessibility behavior

The browser bundle uses a simplified accessibility configuration (different from the server-side [TAccessibility](#taccessibility) interface):

| Configuration | Result |
|---------------|--------|
| `{ assistive_mml: true, include_speech: true }` | `aria-label` attribute with speech text + `<mjx-assistive-mml>` element |
| `{ assistive_mml: true }` | `aria-labelledby` pointing to `<mjx-assistive-mml>` ID |
| No accessibility config | No accessibility attributes added |

The script automatically skips elements that have already been rendered.

**Note:** For server-side rendering accessibility, use the [TAccessibility](#taccessibility) interface with `assistiveMml` and `sre` options instead.


## Browser Speech Script (add-speech.js)

Use this script to add speech accessibility to math that was already rendered server-side as SVG with `assistiveMml: true` but without SRE speech. It loads SRE dynamically and adds `aria-label` attributes to existing `mjx-container` elements.

This is useful when you want fast server-side rendering without the SRE dependency, but still want speech accessibility on the client.

### Prerequisites

The rendered HTML must include `<mjx-assistive-mml>` elements (i.e., the server used `accessibility: { assistiveMml: true }`).

### Loading the script

```html
<script src="https://cdn.jsdelivr.net/npm/mathpix-markdown-it@latest/es5/browser/add-speech.js"></script>
```

By default, the script automatically processes `document.body` on `DOMContentLoaded`.

### Usage

```js
// Add speech to all rendered math in a specific container
window.MathpixSpeech.addSpeechToRenderedMath(document.getElementById('content'));
```

### Configuration

Set `window.MathpixSpeechConfig` before the script loads to customize behavior:

```js
window.MathpixSpeechConfig = {
container: document.getElementById('math-content') // defaults to document.body
};
```

### What it does

For each `mjx-container` element that does not already have an `aria-label`:
1. Extracts MathML from the `<mjx-assistive-mml>` child element
2. Generates speech text using SRE (Speech Rule Engine)
3. Sets `aria-label`, `role="math"`, and `tabindex="0"` on the container


# Documentation

## React components
Expand Down Expand Up @@ -818,6 +939,7 @@ The `MathpixMarkdown` React element accepts the following props:

| | type&nbsp;*`default`* | description |
|--------------------------|------------------------------|-------------------------------------------------------------------------------------------------------------------|
| `output_format` | `'svg' \| 'mathml' \| 'latex'`&nbsp;*`'svg'`* | Controls which math format is placed in HTML output. See [Output Format](#output-format) section. |
| `include_mathml` | boolean&nbsp;*`false`* | outputs mathml `<mathml style="display: none"><math>...</math></mathml>` |
| `include_mathml_word` | boolean&nbsp;*`false`* | outputs mathml_word `<mathmlword style="display: none"><math>...</math></mathmlword>` |
| `include_asciimath` | boolean&nbsp;*`false`* | outputs asciimath `<asciimath style="display: none">...</asciimath>` |
Expand Down Expand Up @@ -964,7 +1086,7 @@ const { loadSreAsync } = require('mathpix-markdown-it/lib/sre/sre-node');

```

Then just pass the resulting value to `accessibility.spe`
Then just pass the resulting value to `accessibility.sre`
```js
accessibility: {
assistiveMml: true, // assistive-mml will be added to mjx-container
Expand Down
32 changes: 32 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# February 2026

## [2.0.36] - 16 February 2026

- Math Output Format:
- Added `output_format` option to `TOutputMath` to control which math format is placed in HTML output.
- `'svg'` (default): Pre-rendered SVG with hidden formats, works offline.
- `'mathml'`: Native `<math>` elements only, smaller file size, requires client-side rendering.
- `'latex'`: Raw LaTeX with original delimiters, smaller file size, requires client-side rendering.

- Browser Rendering Script (`auto-render.js`):
- New browser bundle for client-side math rendering at `es5/browser/auto-render.js`.
- Renders MathML or LaTeX content to SVG.
- Generates hidden format elements for context menu compatibility.
- Configurable accessibility support via `MathpixAccessibilityConfig`:
- `assistive_mml`: Add `<mjx-assistive-mml>` for screen readers.
- `include_speech`: Add `aria-label` with speech text.

- Browser Speech Script (`add-speech.js`):
- New browser bundle for adding speech to already-rendered SVG at `es5/browser/add-speech.js`.
- Use when SVG was rendered with `assistiveMml: true` but without `sre` (speech).
- Loads SRE dynamically and adds `aria-label`, `role="math"`, `tabindex` to `mjx-container` elements.
- Requires `mjx-assistive-mml` to be present in the rendered output.
- Exposes `window.MathpixSpeech.addSpeechToRenderedMath(container?)`.

- Accessibility:
- `mjx-assistive-mml` is no longer marked with `aria-hidden="true"` when accessibility options are enabled. Previously, the assistive MathML element was hidden from screen readers even when the user explicitly requested accessibility via `assistiveMml: true` or `sre`. Now, if any accessibility option is set, the MathML content is exposed to assistive technology — either via `aria-labelledby` (pointing to the assistive MML) or via `aria-label` (SRE speech text). This affects both server-side rendering (`addAriaToMathHTML`) and the new browser bundles.

- Fixes:
- Fixed centering issue for equations with numbering inside `.math-block[data-width="full"]`.

- Docs:
- Added implementation details in `pr-specs/2026-01-html-math-output-options.md`.

## [2.0.35] - 13 February 2026

- Tabular:
Expand Down
1 change: 1 addition & 0 deletions es5/browser/add-speech.js

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions es5/browser/auto-render.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions es5/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion es5/context-menu.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions es5/index.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions lib/browser/add-speech.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface MathpixSpeechConfig {
/** Container element to process (defaults to document.body) */
container?: HTMLElement;
}
/**
* Add speech attributes to already-rendered SVG math elements.
* Use this when math was rendered server-side without accessibility (output_format: 'svg').
*
* This function:
* - Loads SRE (Speech Rule Engine) dynamically
* - Finds all mjx-container elements
* - Extracts MathML from mjx-assistive-mml
* - Generates speech text and adds aria-label
*
* @param container - The container element to search for math elements (defaults to document.body)
*/
export declare const addSpeechToRenderedMath: (container?: HTMLElement) => Promise<void>;
97 changes: 97 additions & 0 deletions lib/browser/add-speech.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/browser/add-speech.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/browser/auto-render.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TOutputMath } from "../mathpix-markdown-model";
export interface MathpixAccessibilityConfig {
/** Expose MathJax assistive MathML for screen readers */
assistive_mml?: boolean;
/** Add aria-label speech string generated by SRE */
include_speech?: boolean;
}
export interface MathpixRenderConfig {
accessibility: MathpixAccessibilityConfig;
outMath: TOutputMath;
/** Container width used for layout metrics (cwidth) */
width?: number;
previewUuid?: string;
}
/**
* Typeset MathJax math inside a container element.
* Searches for `.math-inline` and `.math-block`, detects whether each node contains pure MathML or TeX,
* and replaces its inner HTML with MathJax output.
*/
export declare const renderMathInElement: (container: HTMLElement, config?: Partial<MathpixRenderConfig>) => Promise<void>;
Loading