Repository navigation
OMML writer: don't fill hidden empty n-ary sub/sup with ZWSP - #309
Merged
Merged
Conversation
makeNary already sets subHide/supHide="on" for empty sub/sup (EGrouped []), so Word never renders them. But showExp still filled <m:sub>/<m:sup> with the ZWSP run it injects for empty groups (jgm#118), leaving U+200B in document.xml. That leaks into docx->markdown/latex roundtrips (\sum_{}^{}) and breaks LaTeX compilation. Emit an empty <m:sub/>/<m:sup/> instead, matching what Word itself writes for hidden nary limits.
Owner
|
thanks! |
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.
makeNaryalready setssubHide/supHide="on"for empty limits (EGrouped []), but it still routes the empty group throughshowExp, which — since 76d5a04 (#118) — fills empty groups with U+200B to avoid Word's dashed placeholder box. That ZWSP makes sense for visible empty groups (sSub/sSuphave no hide property), but for n-ary limits it is pure noise: the limit is hidden anyway, yet the invisible character stays inword/document.xml. Downstream consumers trip over it: docx→markdown/LaTeX round-trips yield\sum_{}^{}, and pasting such formulas into LaTeX fails to compile on the invisible character.Note that Word itself writes self-closing elements for hidden n-ary limits — see the existing Word-generated input
test/reader/omml/substack.test, which the OMML reader already accepts.Change: emit an empty
<m:sub/>/<m:sup/>when (and only when) the corresponding hide flag is "on", reusing the sameEGrouped []condition (now namedisEmptySub/isEmptySup). The three ZWSP sites from #118 (empty group, empty identifier,ESpaceotherwise-branch) are untouched, so ordinary visible empty groups keep avoiding the dashed box.Reproduce:
Currently this emits
<m:sub><m:r><m:t>​</m:t></m:r></m:sub>; with this patch it emits<m:sub />.All 3258 tests pass. Five
writer/ommlgoldens with hidden n-ary limits change accordingly (regenerated with--accept; the diffs are only the ZWSP runs collapsing to self-closing tags).On the pandoc side (I rebuilt pandoc 3.14 against this patch): on a formula corpus,
document.xmlU+200B drops from 15 to 5 — the 5 survivors are exactly the non-naryx_{}-type groups that must keep the ZWSP — and the nary hide-flag sequences are identical to the official build, so Word's rendering behavior is unchanged.