]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathEnsureMath.cpp
Small improvement for bug #7509 as suggested by JMarc
[lyx.git] / src / mathed / InsetMathEnsureMath.cpp
index 7221322db0fd054c3275b1a284fbb4831a41e7fb..a4070265905f54b0574eaf837d6b81d96d3d1b00 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "InsetMathEnsureMath.h"
 
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathSupport.h"
@@ -72,19 +73,19 @@ void InsetMathEnsureMath::write(WriteStream & os) const
 
 void InsetMathEnsureMath::mathmlize(MathStream & os) const
 {
-       os << "[EM]";
        SetMode mathmode(os, false);
-       os << cell(0);
-       os << "[/EM]";
+       os << MTag("mstyle", "class='math'")
+          << cell(0)
+          << ETag("mstyle");
 }
 
 
 void InsetMathEnsureMath::htmlize(HtmlStream & os) const
 {
-       os << "[EM]";
        SetHTMLMode mathmode(os, false);
-       os << cell(0);
-       os << "[/EM]";
+       os << MTag("span", "class='math'")
+          << cell(0)
+          << ETag("span");
 }
 
 
@@ -94,4 +95,21 @@ void InsetMathEnsureMath::infoize(odocstream & os) const
 }
 
 
+void InsetMathEnsureMath::validate(LaTeXFeatures & features) const
+{
+       // FIXME XHTML
+       // It'd be better to be able to get this from an InsetLayout, but at present
+       // InsetLayouts do not seem really to work for things that aren't InsetTexts.
+       if (features.runparams().math_flavor == OutputParams::MathAsMathML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "mstyle.math { font-style: italic; }\n"
+                       "</style>");
+       else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.mathbox { font-style: italic; }\n"
+                       "</style>");
+
+       InsetMathNest::validate(features);
+}
+
 } // namespace lyx