Add structural OMML handlers for remaining LaTeX macros#1
Closed
chitwitgit wants to merge 1 commit into
Closed
Conversation
Map n-ary operators, binom, stackrel, accents, and font wrappers to proper Word OMML instead of Unicode fallbacks; fix quad/ne/cdots codegen overrides. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to md2docx#7.
PR md2docx#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.
\wedge→∧).The port still had gaps: some common macros need more than symbol lookup. N-ary operators must emit
m:nary, not a ∫/∏ character in a text run. Layout commands like\binomand\stackrelneed delimiter and limit structures. Font wrappers should render their argument, not the macro name. A few KaTeX macro-only symbols (\quad,\ne,\cdots) were also missing from the generated overrides.This PR adds explicit handlers for those cases (~115 lines on top of md2docx#7).
What changed
lib/src/index.ts(+~110 lines)\prod,\int,\oint,\bigcup,\bigcap,\bigoplus,\bigotimesm:nary\binom{a}{b}m:d(round brackets + fraction)\stackrel{a}{b}m:limLoc+MathLimitUpper\overline,\widetildecreateMathAccentCharacter\mathrm,\mathit,\textbf,\textit,\underline,\overbrace,\underbrace\boxed,\boldsymbol\newline\sumunchanged — already handled viaMathSum.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 → 25KATEX_SYMBOL_OVERRIDES.Test plan
pnpm buildpasses inlib/pnpm testpasses inlib/\binom{n}{k},\int_0^1,\stackrel{def}{=},\mathrm{ABC},\prod_{i=1}^n