Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(mathml2omml): call includes() instead of indexing it#681

Open
ly-wang19 wants to merge 1 commit into
THU-MAIC:main from
ly-wang19:fix/mathml2omml-includes-call
Open

fix(mathml2omml): call includes() instead of indexing it #681
ly-wang19 wants to merge 1 commit into
THU-MAIC:main from
ly-wang19:fix/mathml2omml-includes-call

Conversation

@ly-wang19

@ly-wang19 ly-wang19 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What & why

packages/mathml2omml/src/parse-stringify/parse.js line 82 reads:

textContainerNames.includes[arr[level].name] &&

textContainerNames is an array (["mtext","mi","mn","mo","ms"], line 8) and Array.prototype.includes is a method. includes[name] reads a property of the function objectundefined for any tag name — so the condition is always falsy and the "trailing text node" branch never runs. Line 48 of the same file already uses the correct form: textContainerNames.includes(current.name).

Result: trailing text after a nested closing tag inside a text container (mtext/mi/mn/mo/ms) is dropped from the OMML, affecting math exported to PPTX via latexToOmml.

Closes #680.

Fix

One character — call the method: textContainerNames.includes(arr[level].name).

Notes

  • packages/mathml2omml/dist/ is gitignored and rebuilt by the repo’s postinstall (npm run build), so the runtime bundle picks up the fix on install. I rebuilt locally to confirm: the build succeeds and the rebuilt dist/index.js contains the corrected call (0 buggy occurrences, 1 fixed).
  • No bespoke test: the package has no committed test suite, and correctness is established by the in-file precedent (line 48) plus the verified rebuild. Happy to add a package-level case if you’d prefer.

AI-assisted (Claude), self-reviewed.

parse.js used `textContainerNames.includes[arr[level].name]`, which reads a
property of the includes function (always undefined) instead of calling it,
so the "trailing text node" branch never ran and trailing text inside a
MathML text container (mtext/mi/mn/mo/ms) was dropped from the OMML. Line 48
of the same file already uses the correct `includes(...)` form.
dist/ is gitignored and rebuilt by postinstall, so the runtime bundle picks
up the fix on install.
Closes THU-MAIC#680
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

mathml2omml drops trailing text in text containers (includes indexed, not called)

1 participant

AltStyle によって変換されたページ (->オリジナル) /