[LyX features/biginset] MathML: don't let the processor stretch operators when they are single characters for LyX.

Thibaut Cuvelier tcuvelier at lyx.org
Fri Apr 5 13:41:43 UTC 2024


commit 7e6597a5b47c22ed22966a75c149264dacd6e289
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Mon Mar 11 02:00:47 2024 +0100

    MathML: don't let the processor stretch operators when they are single characters for LyX.
    
    The main goal is to match TeX' behaviour. If you want stretchy operators, use InsetMathDelim / \left & \right. This patch will change the output in many files, but making the rendering much closer to that of TeX (which users should expect, due to LyX' roots in TeX).
---
 src/mathed/InsetMathChar.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 71aba6f6f7..a642a5e6da 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -230,6 +230,8 @@ void InsetMathChar::octave(OctaveStream & os) const
 // mathalpha, then we'll treat it as an identifier, otherwise as an
 // operator.
 // Worst case: We get bad spacing, or bad italics.
+// In any case, never let MathML stretch a single character when it
+// is recognised as an operator, to match TeX' behaviour.
 void InsetMathChar::mathmlize(MathMLStream & ms) const
 {
 	std::string entity;
@@ -253,7 +255,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 	}
 
 	if (!entity.empty()) {
-		ms << MTagInline("mo")
+		ms << MTagInline("mo", "stretchy='false'")
 		   << from_ascii(entity)
 		   << ETagInline("mo");
 		return;
@@ -262,7 +264,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 	char const * type =
 		(isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
 			? "mi" : "mo";
-	ms << MTagInline(type)
+	ms << MTagInline(type, std::string(type) == "mo" ? "stretchy='false'" : "")
 	   << char_type(char_)
 	   << ETagInline(type);
 }


More information about the lyx-cvs mailing list