From b66969a72a03dd8183cb29d53f50b9c021ee3d84 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 29 Oct 2025 13:19:59 -0400 Subject: [PATCH 1/2] Fix xarrows so that they won't stretch after initial layout. (mathjax/MathJax#3457) --- ts/input/tex/ams/AmsMethods.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ts/input/tex/ams/AmsMethods.ts b/ts/input/tex/ams/AmsMethods.ts index 63545da71..d1ea310da 100644 --- a/ts/input/tex/ams/AmsMethods.ts +++ b/ts/input/tex/ams/AmsMethods.ts @@ -560,7 +560,7 @@ export const AmsMethods: { [key: string]: ParseMethod } = { let arrow = parser.create( 'token', 'mo', - { stretchy: true, texClass: TEXCLASS.REL }, + { stretchy: true, texClass: TEXCLASS.ORD }, // REL is applied in a TeXAtom below String.fromCodePoint(chr) ); if (m) { @@ -588,7 +588,23 @@ export const AmsMethods: { [key: string]: ParseMethod } = { // @test Above Left Arrow, Above Right Arrow, Above Left Arrow in Context, // Above Right Arrow in Context NodeUtil.setProperty(mml, 'subsupOK', true); - parser.Push(mml); + // + // Use an empty item to prevent the xarrow from further stretching (see #3457) + // and enclose both in a TeXAtom to make the combination a REL. + // + parser.Push( + parser.create( + 'node', + 'TeXAtom', + [ + parser.create('node', 'TeXAtom', [], { + texClass: TEXCLASS.NONE, + }), + mml, + ], + { texClass: TEXCLASS.REL } + ) + ); }, /** From bce7b4be11c2ccd75507c7bec957a5d6df04136d Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 29 Oct 2025 13:33:00 -0400 Subject: [PATCH 2/2] Update tests for new output for xarrows. --- testsuite/tests/input/tex/Ams.test.ts | 162 +++--- testsuite/tests/input/tex/Extpfeil.test.ts | 156 ++--- testsuite/tests/input/tex/Mathtools.test.ts | 357 +++++++----- testsuite/tests/input/tex/Mhchem.test.ts | 605 +++++++++++--------- testsuite/tests/input/tex/Tex.test.ts | 33 +- 5 files changed, 727 insertions(+), 586 deletions(-) diff --git a/testsuite/tests/input/tex/Ams.test.ts b/testsuite/tests/input/tex/Ams.test.ts index 02d0a6184..e1d13aaa7 100644 --- a/testsuite/tests/input/tex/Ams.test.ts +++ b/testsuite/tests/input/tex/Ams.test.ts @@ -441,16 +441,19 @@ describe('Ams', () => { toXmlMatch( tex2mml('\\xleftarrow{abcd}'), ` - - - - a - b - c - d - - - + + + + + + a + b + c + d + + + + ` ); }); @@ -461,22 +464,25 @@ describe('Ams', () => { toXmlMatch( tex2mml('\\xleftarrow[xyz]{abcd}'), ` - - - - x - y - z - - - - a - b - c - d - - - + + + + + + x + y + z + + + + a + b + c + d + + + + ` ); }); @@ -488,16 +494,19 @@ describe('Ams', () => { tex2mml('A\\xleftarrow{abcd}B'), ` A - - - - a - b - c - d - - - + + + + + + a + b + c + d + + + + B ` ); @@ -509,16 +518,19 @@ describe('Ams', () => { toXmlMatch( tex2mml('\\xrightarrow{abcd}'), ` - - - - a - b - c - d - - - + + + + + + a + b + c + d + + + + ` ); }); @@ -529,22 +541,25 @@ describe('Ams', () => { toXmlMatch( tex2mml('\\xrightarrow[xyz]{abcd}'), ` - - - - x - y - z - - - - a - b - c - d - - - + + + + + + x + y + z + + + + a + b + c + d + + + + ` ); }); @@ -556,16 +571,19 @@ describe('Ams', () => { tex2mml('A\\xrightarrow{abcd}B'), ` A - - - - a - b - c - d - - - + + + + + + a + b + c + d + + + + B ` ); diff --git a/testsuite/tests/input/tex/Extpfeil.test.ts b/testsuite/tests/input/tex/Extpfeil.test.ts index a9f0181f0..c44882b5c 100644 --- a/testsuite/tests/input/tex/Extpfeil.test.ts +++ b/testsuite/tests/input/tex/Extpfeil.test.ts @@ -15,18 +15,21 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\xtwoheadrightarrow{abcxyz}'), ` - - - - a - b - c - x - y - z - - - + + + + + + a + b + c + x + y + z + + + + ` ); }); @@ -37,18 +40,21 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\xtwoheadleftarrow{abcxyz}'), ` - - - - a - b - c - x - y - z - - - + + + + + + a + b + c + x + y + z + + + + ` ); }); @@ -59,18 +65,21 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\xmapsto{abcxyz}'), ` - - - - a - b - c - x - y - z - - - + + + + + + a + b + c + x + y + z + + + + ` ); }); @@ -81,18 +90,21 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\xlongequal{abcxyz}'), ` - - = - - a - b - c - x - y - z - - - + + + + = + + a + b + c + x + y + z + + + + ` ); }); @@ -103,18 +115,21 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\xtofrom{abcxyz}'), ` - - - - a - b - c - x - y - z - - - + + + + + + a + b + c + x + y + z + + + + ` ); }); @@ -125,15 +140,18 @@ describe('Extpfeil', () => { toXmlMatch( tex2mml('\\Newextarrow{\\ab}{10,20}{8672}\\ab{xyz}'), ` - - - - x - y - z - - - + + + + + + x + y + z + + + + ` ); }); diff --git a/testsuite/tests/input/tex/Mathtools.test.ts b/testsuite/tests/input/tex/Mathtools.test.ts index abdad3a17..e27c549bf 100644 --- a/testsuite/tests/input/tex/Mathtools.test.ts +++ b/testsuite/tests/input/tex/Mathtools.test.ts @@ -743,15 +743,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xleftrightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -762,15 +765,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xLeftarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -781,15 +787,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xRightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -800,15 +809,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xLeftrightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -819,15 +831,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xhookleftarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -838,15 +853,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xhookrightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -857,15 +875,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xmapsto{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -876,15 +897,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xrightharpoondown{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -895,15 +919,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xleftharpoondown{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -914,15 +941,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xrightleftharpoons{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -933,15 +963,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xleftrightharpoons{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -952,15 +985,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xrightharpoonup{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -971,15 +1007,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xleftharpoonup{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -990,15 +1029,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xlongleftarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -1009,15 +1051,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xLongleftarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -1028,15 +1073,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xlongrightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); @@ -1047,15 +1095,18 @@ describe('Mathtools stretchy', () => { toXmlMatch( tex2mml('\\xLongrightarrow{x+y}'), ` - - - - x - + - y - - - + + + + + + x + + + y + + + + ` ); }); diff --git a/testsuite/tests/input/tex/Mhchem.test.ts b/testsuite/tests/input/tex/Mhchem.test.ts index 118dc6637..36ee99b75 100644 --- a/testsuite/tests/input/tex/Mhchem.test.ts +++ b/testsuite/tests/input/tex/Mhchem.test.ts @@ -4027,36 +4027,39 @@ describe('Mhchem8', () => { - - - - - + - - 2 - - - - - OH - - - - - - - A - - - - - - + + + + + + + + + + 2 + + + + + OH - - - - + + + + + + A + + + + + + + + + + + + @@ -4124,36 +4127,39 @@ describe('Mhchem8', () => { - - - - - + - - 2 - - - - - OH - - - - - - - A - - - - - - + + + + + + + + + + 2 + + + + + OH - - - - + + + + + + A + + + + + + + + + + + + @@ -4748,29 +4754,32 @@ describe('Mhchem-Ams', () => { - - - - - I - - - - - - - A - - - - - - + + + + + + + I - - - - + + + + + + A + + + + + + + + + + + + @@ -4796,29 +4805,32 @@ describe('Mhchem-Ams', () => { - - - - - I - - - - - - - A - - - - - - + + + + + + + I - - - - + + + + + + A + + + + + + + + + + + + [ @@ -4895,36 +4907,39 @@ describe('Mhchem-Ams', () => { - - - - - H - - - - - - - A - - - + + + + + + + H - - - - 2 - + + + + + + A + + + + + + + + 2 + + + + + O - - - O - - - - + + + + @@ -4947,23 +4962,26 @@ describe('Mhchem-Ams', () => { - - - - - - text below + + + + + + + + text below + - - - - - - text above - - - - + + + + + text above + + + + + @@ -4986,22 +5004,25 @@ describe('Mhchem-Ams', () => { - - - - - - x - i - - - - - - x - - - + + + + + + + + x + i + + + + + + x + + + + @@ -5070,15 +5091,18 @@ describe('Mhchem-Ams', () => { - - - - - Δ - - - - + + + + + + + Δ + + + + + ( @@ -5213,29 +5237,32 @@ describe('Mhchem-Ams', () => { - - - - - I - - - - - - - A - - - - - - + + + + + + + I - - - - + + + + + + A + + + + + + + + + + + + @@ -5268,29 +5295,32 @@ describe('Mhchem-Ams', () => { - - - - - I - - - - - - - A - - - - - - + + + + + + + I - - - - + + + + + + A + + + + + + + + + + + + @@ -5381,15 +5411,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5412,15 +5445,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5443,15 +5479,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5474,15 +5513,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5505,15 +5547,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5536,15 +5581,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + @@ -5567,15 +5615,18 @@ describe('Mhchem-Ams', () => { - - - - - text - - - - + + + + + + + text + + + + + diff --git a/testsuite/tests/input/tex/Tex.test.ts b/testsuite/tests/input/tex/Tex.test.ts index 29f76e373..a77f12244 100644 --- a/testsuite/tests/input/tex/Tex.test.ts +++ b/testsuite/tests/input/tex/Tex.test.ts @@ -436,21 +436,24 @@ describe('TexParser', () => { toXmlMatch( tex2mml('\\xrightarrow[{[x]}]{a}'), ` - - - - - [ - x - ] - - - - - a - - - + + + + + + + [ + x + ] + + + + + a + + + + ` ); });