-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(mathml2omml): call includes() instead of indexing it#681
Open
ly-wang19 wants to merge 1 commit into
Open
Conversation
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>
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.
What & why
packages/mathml2omml/src/parse-stringify/parse.jsline 82 reads:textContainerNamesis an array (["mtext","mi","mn","mo","ms"], line 8) andArray.prototype.includesis a method.includes[name]reads a property of the function object —undefinedfor 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 vialatexToOmml.Closes #680.
Fix
One character — call the method:
textContainerNames.includes(arr[level].name).Notes
packages/mathml2omml/dist/is gitignored and rebuilt by the repo’spostinstall(npm run build), so the runtime bundle picks up the fix on install. I rebuilt locally to confirm: the build succeeds and the rebuiltdist/index.jscontains the corrected call (0 buggy occurrences, 1 fixed).AI-assisted (Claude), self-reviewed.