Skip to content

Merge KaTeX symbol tables into single lookup map (depends on #7)#8

Closed
chitwitgit wants to merge 8 commits into
md2docx:mainfrom
chitwitgit:feat/merge-katex-symbols
Closed

Merge KaTeX symbol tables into single lookup map (depends on #7)#8
chitwitgit wants to merge 8 commits into
md2docx:mainfrom
chitwitgit:feat/merge-katex-symbols

Conversation

@chitwitgit

Copy link
Copy Markdown

Summary

Depends on #7 — merge that first, then this adds one commit on top.

Merges the generated katexSymbols.ts and katexMeta.ts alias/override tables into a single katexData.ts with one flat lookup map at runtime.

  • Flatten symbol + alias + override entries at codegen (641 merged entries)
  • Replace 3-table lookup chain with KATEX_SYMBOLS[name]
  • Emit compact object literal (minifies better than JSON.parse blobs)
  • Adds lib/scripts/benchmark-bundle-formats.ts to compare serialization formats

Bundle size (local pnpm build in lib/)

Version gzip CJS
PR #7 (3-table) 6,284 B
This PR (merged) 6,168 B
Savings −116 B (−1.8%)

Full symbol coverage is unchanged — this is a serialization/layout optimization only.

Test plan

  • pnpm build passes in lib/
  • pnpm test passes in lib/
  • Benchmark script confirms merged object literal is the best maintainable format among 8 variants tried

chitwitgit and others added 6 commits June 9, 2026 13:51
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
Map n-ary operators, binom, stackrel, accents, and font wrappers to proper
Word OMML instead of Unicode fallbacks; fix quad/ne/cdots codegen overrides.
Log console errors and omit unrenderable OMML instead of emitting empty <m:oMath> elements that break Microsoft Word.
Add concrete newly-supported LaTeX examples to sample.md so DOCX
benefits are easy to spot. Replace vendored KaTeX snippets with
codegen that fetches KaTeX v0.16.22 from GitHub (symbols.js,
macros.js, functions/op.js).
@deepsource-io

deepsource-io Bot commented Jun 14, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 32d1f5d...a2bab65 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 18, 2026 1:55a.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.

@mayank1513

Copy link
Copy Markdown
Contributor

Hi,

Thanks and sorry for the delay. A bit busy. Can you please merge both of your branches and update this PR with main. There were some issues with pnpm etc. so I had to push a few updates to the infra.

Thanks and regards,

chitwitgit and others added 2 commits June 18, 2026 09:25
Flatten symbol, alias, and override entries into one generated
katexData.ts object literal for a smaller minified bundle (~1.7%
gzip savings vs three-table lookup). Add a benchmark script to compare
serialization formats.
@chitwitgit chitwitgit force-pushed the feat/merge-katex-symbols branch from f883df0 to a2bab65 Compare June 18, 2026 01:54
@chitwitgit

Copy link
Copy Markdown
Author

Folded into #7 — both branches are now merged on feat/expand-latex-symbol-coverage and rebased on latest main.

@chitwitgit chitwitgit closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants