Skip to content

Merge KaTeX symbol tables into single lookup map - #2

Merged
chitwitgit merged 1 commit into
feat/expand-latex-symbol-coveragefrom
feat/merge-katex-symbols
Jun 18, 2026
Merged

Merge KaTeX symbol tables into single lookup map#2
chitwitgit merged 1 commit into
feat/expand-latex-symbol-coveragefrom
feat/merge-katex-symbols

Conversation

@chitwitgit

Copy link
Copy Markdown
Owner

Summary

Follow-up to md2docx/math#7. 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/)

Versiongzip CJS
PR md2docx#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

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
chitwitgitforce-pushed the feat/merge-katex-symbols branch from f883df0 to a2bab65CompareJune 18, 2026 01:54
@github-actions

Copy link
Copy Markdown

🛡️ PromptShield Workspace Report

Date: 6/18/2026, 1:55:13 AM
Total Threats: 59
Files Affected: 2


📄 lib/src/index.ts — 5 Medium
⚠️MEDIUM — 5 threats
Line 57 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 58 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 60 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 61 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 336 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
📄 lib/src/katexData.ts — 43 Medium, 11 Low
⚠️MEDIUM — 43 threats
Line 13 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 50 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 55 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 56 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 57 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 75 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 104 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 109 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 131 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 147 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 157 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 171 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 188 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 216 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 229 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 234 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 239 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 241 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 242 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 270 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 333 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 334 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 391 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 392 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 408 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 431 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 537 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 552 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 570 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 614 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 617 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 619 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 621 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 649 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 652 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 656 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 657 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 661 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 663 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 664 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 665 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 666 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 668 — 1 threat
  • NORMALIZATIONPSN002: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
💡 LOW — 11 threats
Line 3 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 127 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 185 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 243 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 244 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 363 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 429 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 430 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 441 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 442 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])
Line 485 — 1 threat
  • NORMALIZATIONPSN001: Text changes under Unicode NFKC normalization. This may cause ambiguity between displayed and interpreted content. (Hidden: [NFKC_DIFF])

🛡️ PromptShield — Found an edge case? Report it. Love the shield? ⭐ Star the repo.

@chitwitgit
chitwitgit merged commit a2bab65 into feat/expand-latex-symbol-coverageJun 18, 2026
3 of 4 checks passed
Sign up for freeto 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.

1 participant

@chitwitgit