Expand LaTeX symbol coverage using codegen from vendored tables#7
Expand LaTeX symbol coverage using codegen from vendored tables#7chitwitgit wants to merge 3 commits into
Conversation
Replace the hand-maintained symbol map with generated tables seeded from KaTeX v0.16.22 source snippets, add accent and function handling, and document regeneration via pnpm generate:katex. Fixes md2docx#6
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| JavaScript | Jun 10, 2026 2:19a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
SummaryFollow-up to #7. PR #7 replaces the hand-maintained symbol map with KaTeX-generated tables (~567 symbols). That covers most macros where the fix is simply resolving a command to the right Unicode glyph (e.g. The port still had gaps: some common macros need more than symbol lookup. N-ary operators must emit This PR adds explicit handlers for those cases (~115 lines on top of #7). What changed
|
| Category | Macros | OMML |
|---|---|---|
| N-ary operators | \prod, \int, \oint, \bigcup, \bigcap, \bigoplus, \bigotimes |
m:nary |
| Layout | \binom{a}{b} |
m:d (round brackets + fraction) |
| Layout | \stackrel{a}{b} |
m:limLoc + MathLimitUpper |
| Accents | \overline, \widetilde |
createMathAccentCharacter |
| Font/text | \mathrm, \mathit, \textbf, \textit, \underline, \overbrace, \underbrace |
argument content only (no literal macro name) |
| Skip | \boxed, \boldsymbol |
no literal fallback |
| Other | \newline |
space (non-empty OMML) |
\sum unchanged — already handled via MathSum.
lib/scripts/generate-katex-data.ts (+4 lines)
Codegen fixes for macro-only symbols missed by simple alias parsing:
\quad,\qquad— fixed\\\\hskipregex for vendored KaTeX file\ne→≠(alias of\neq)\cdots→⋯(via\@cdots)
Regenerated katexMeta.ts: 21 → 25 KATEX_SYMBOL_OVERRIDES.
Test plan
-
pnpm buildpasses inlib/ -
pnpm testpasses inlib/ - Spot-check in Word:
\binom{n}{k},\int_0^1,\stackrel{def}{=},\mathrm{ABC},\prod_{i=1}^n
feae6c4 to
977dd65
Compare
Map n-ary operators, binom, stackrel, accents, and font wrappers to proper Word OMML instead of Unicode fallbacks; fix quad/ne/cdots codegen overrides.
977dd65 to
f05e5b5
Compare
Log console errors and omit unrenderable OMML instead of emitting empty <m:oMath> elements that break Microsoft Word.
Summary
Closes #6.
Replaces the hand-maintained
LATEX_SYMBOLSmap (~120 entries) inlib/src/index.tswith generated symbol tables to support substantially more LaTeX commands in DOCX output.KaTeX v0.16.22 source snippets are used as a practical seed — they provide a large, well-structured baseline that is easy to vendor and codegen from. The goal is broad LaTeX command coverage, not parity with any particular renderer; other sources and manual overrides can be layered on later.
\tilde,\bar,\vec, etc.) now produce OMML accent characters\sin,\log, etc.) render as literal textpnpm generate:katexto regenerate tables from vendored source./src/index.tsso generated data files bundle into the main exportTest plan
pnpm typecheckpasses inlib/pnpm buildpasses inlib/pnpm testpasses inlib/\neq,\alpha,\sum,\hat{x})