]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Fix bug #12772
[lyx.git] / src / mathed / InsetMathHull.cpp
index 8fbd5c29224f7f4f7bee0f6382e0fd6994366bd8..537d6670c5ffa0d090ffb0b2acfd5c372a001f83 100644 (file)
@@ -2532,33 +2532,37 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
 {
        bool const havetable = haveNumbers() || nrows() > 1 || ncols() > 1;
 
-    if (havetable) {
-        if (getType() == hullSimple) {
-               ms << MTag("mtable");
-        } else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
-            string alignment;
-            for (col_type col = 0; col < ncols(); ++col) {
-                alignment += (col % 2) ? "left " : "right ";
-            }
-            ms << MTag("mtable", "displaystyle='true' columnalign='" + alignment + "'");
-           } else {
-               ms << MTag("mtable", "displaystyle='true'");
+       // Simplest case: single row, single column, no numbering.
+       if (!havetable) {
+               ms << cell(index(0, 0));
+               return;
+       }
+
+       // More complex case: wrap elements in a table.
+    if (getType() == hullSimple) {
+        ms << MTag("mtable");
+    } else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
+               // hullAlign, hullAlignAt, hullXAlignAt, hullXXAlignAt
+        string alignment;
+        for (col_type col = 0; col < ncols(); ++col) {
+            alignment += (col % 2) ? "left " : "right ";
         }
+        ms << MTag("mtable", "displaystyle='true' columnalign='" + alignment + "'");
+    } else {
+        ms << MTag("mtable", "displaystyle='true'");
     }
 
-       char const * const celltag = havetable ? "mtd" : "mrow";
-       // FIXME There does not seem to be wide support at the moment
-       // for mlabeledtr, so we have to use just mtr for now.
-       // char const * const rowtag = haveNumbers() ? "mlabeledtr" : "mtr";
-       char const * const rowtag = "mtr";
        for (row_type row = 0; row < nrows(); ++row) {
-               if (havetable)
-                       ms << MTag(rowtag);
+               // No Wed browser supports mlabeledtr in 2023, even though it has been introduced in
+               // MathML 2 (2003). Moreover, it is not supported in MathML 4 Core.
+               ms << MTag("mtr");
+
                for (col_type col = 0; col < ncols(); ++col) {
-                       ms << MTag(celltag)
+                       ms << MTag("mtd")
                           << cell(index(row, col))
-                          << ETag(celltag);
+                          << ETag("mtd");
                }
+
                // fleqn?
                if (haveNumbers()) {
                        ms << MTag("mtd");
@@ -2567,18 +2571,18 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
                                ms << MTagInline("mtext") << '(' << num << ')' << ETagInline("mtext");
                    ms << ETag("mtd");
                }
-               if (havetable)
-                       ms << ETag(rowtag);
+
+               ms << ETag("mtr");
        }
-       if (havetable)
-               ms << ETag("mtable");
+
+       ms << ETag("mtable");
 }
 
 
 void InsetMathHull::mathAsLatex(TeXMathStream & os) const
 {
        MathEnsurer ensurer(os, false);
-       bool havenumbers = haveNumbers();
+       bool const havenumbers = haveNumbers();
        bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
 
        if (!havetable) {
@@ -2599,7 +2603,7 @@ void InsetMathHull::mathAsLatex(TeXMathStream & os) const
                        docstring const & num = numbers_[row];
                        if (!num.empty())
                                os << '(' << num << ')';
-                 os << "</td>";
+                   os << "</td>";
                }
                os << "</tr>";
        }