Skip to content

feat(demos): render LaTeX in math standards as plain Unicode - #166

Open
michael-berger-czi wants to merge 4 commits into
mainfrom
mberger/display-LaTeX-equations-better
Open

feat(demos): render LaTeX in math standards as plain Unicode#166
michael-berger-czi wants to merge 4 commits into
mainfrom
mberger/display-LaTeX-equations-better

Conversation

@michael-berger-czi

@michael-berger-czi michael-berger-czi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Low lift implementation for handling various latex equations in the typescript demo app. This doesn't handle all cases, but should clean up quite a few non handled cases.

Screenshot 2026-08-14 at 11 09 32 AM

AI summary:

Standard descriptions from the Knowledge Graph contain raw LaTeX ($\frac{1}{2}$, $5 = \Box \div 3$) plus Markdown emphasis (For example, ...), which displayed verbatim in the standards picker and evaluator output. The evaluator's LLM-generated reasoning mirrors the same notation.

Add a latexToUnicode helper that converts this markup to readable Unicode (½, □ ÷, x², ⅔ × 6) using unicodeit for symbol conversion, with supplemental handling for what it doesn't cover:

  • strip (...)/[...] delimiters and unwrap $...$ spans, with a heuristic that leaves dollar amounts in word problems untouched
  • convert \frac{a}{b} to vulgar fractions (½) or a/b
  • strip Markdown emphasis pairs (lone asterisks like 3 * 4 survive)
  • map \Box to the hollow □ unicodeit lacks
  • restore prose hyphens unicodeit turns into minus signs, and unwrap leftover grouping braces ({π}² → π²)

Applied display-only in MathStandardsAlignmentPage to picker labels and (recursively) to evaluator result JSON; the question and statement codes sent to the evaluator are unchanged.

Thanks for your interest in our project!

This repository is currently being maintained internally, so we’re not accepting external contributors.

However, if you’ve discovered a bug or have a feature suggestion, please feel free to open an issue or reach out to us at support@learningcommons.org.

If you believe you have found a security issue, please responsibly disclose by contacting us at security@learningcommons.org.

If you are interested in partnering with us, fill out this form to get in touch.

@michael-berger-czi
michael-berger-czi force-pushed the mberger/display-LaTeX-equations-better branch from 239a603 to 0f027ef Compare August 19, 2026 18:07
@michael-berger-czi
michael-berger-czi requested a review from a team August 19, 2026 18:07
@michael-berger-czi
michael-berger-czi marked this pull request as ready for review August 19, 2026 18:07
@adnanrhussain
adnanrhussain requested a lite review from Copilot August 20, 2026 00:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the TypeScript demo’s math standards UI by converting mixed LaTeX/Markdown fragments in standard descriptions and evaluator output into readable Unicode for display, without changing the underlying evaluator inputs.

Changes:

  • Apply LaTeX→Unicode conversion to standards picker labels and evaluator JSON output display.
  • Introduce latexToUnicode / latexToUnicodeDeep helpers to unwrap common math delimiters, convert fractions, strip emphasis markers, and delegate symbol conversion to unicodeit.
  • Add the unicodeit dependency to the demo app.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
demos/typescript/src/pages/MathStandardsAlignmentPage.tsx Uses display-only LaTeX→Unicode conversion for picker labels and rendered JSON output.
demos/typescript/src/latex.ts Adds LaTeX/Markdown cleanup + deep string conversion utility for JSON-like values.
demos/typescript/package.json Adds unicodeit runtime dependency.
demos/typescript/package-lock.json Locks unicodeit and its transitive dependencies.
Files not reviewed (1)
  • demos/typescript/package-lock.json: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread demos/typescript/src/latex.ts Outdated
Comment thread demos/typescript/src/latex.ts Outdated
Comment thread demos/typescript/src/latex.ts Outdated
Comment on lines +3771 to +3779
"node_modules/unicodeit": {
"version": "0.7.5",
"resolved": "https://registry.npmjs.org/unicodeit/-/unicodeit-0.7.5.tgz",
"integrity": "sha512-IfHeCkRhhf/rvBRw7yMBM6VHzuUg3jSizjFbitT46ATd1VJd9mCYaL78snVzR/vgJEW8a1AczFpNHf3YLSK5dQ==",
"license": "MIT",
"dependencies": {
"@types/typeahead": "^0.11.32",
"typeahead": "^0.2.2"
}
Comment thread demos/typescript/src/latex.ts Outdated
Comment thread demos/typescript/src/latex.ts Outdated
}),
});
setOutput(JSON.stringify(results, null, 2));
setOutput(JSON.stringify(latexToUnicodeDeep(results), null, 2));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldnt, and keep this raw-as-is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think I agree, doesn't seem like we need this.

@michael-berger-czi
michael-berger-czi force-pushed the mberger/display-LaTeX-equations-better branch 2 times, most recently from f18b45c to 1c48bbd Compare August 20, 2026 21:52
michael-berger-czi and others added 4 commits August 31, 2026 09:12
Standard descriptions from the Knowledge Graph contain raw LaTeX
($\frac{1}{2}$, $5 = \Box \div 3$) plus Markdown emphasis (*For
example, ...*), which displayed verbatim in the standards picker and
evaluator output. The evaluator's LLM-generated reasoning mirrors the
same notation.

Add a latexToUnicode helper that converts this markup to readable
Unicode (½, □ ÷, x², ⅔ × 6) using unicodeit for symbol conversion,
with supplemental handling for what it doesn't cover:

- strip \(...\)/\[...\] delimiters and unwrap $...$ spans, with a
  heuristic that leaves dollar amounts in word problems untouched
- convert \frac{a}{b} to vulgar fractions (½) or a/b
- strip Markdown *emphasis* pairs (lone asterisks like 3 * 4 survive)
- map \Box to the hollow □ unicodeit lacks
- restore prose hyphens unicodeit turns into minus signs, and unwrap
  leftover grouping braces ({π}² → π²)

Applied display-only in MathStandardsAlignmentPage to picker labels
and (recursively) to evaluator result JSON; the question and statement
codes sent to the evaluator are unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@adnanrhussain
adnanrhussain force-pushed the mberger/display-LaTeX-equations-better branch from 1c48bbd to d8fc471 Compare August 31, 2026 16:12
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.

3 participants