]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathScript.cpp
HTML for scripts.
[features.git] / src / mathed / InsetMathScript.cpp
index 1af0e573459938104334cf93fa251f7cf501e6f3..e637e55b8c1afdc2bbcafc98bddcf40230f86faa 100644 (file)
@@ -17,6 +17,7 @@
 #include "InsetMathFont.h"
 #include "InsetMathScript.h"
 #include "InsetMathSymbol.h"
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathSupport.h"
@@ -644,6 +645,26 @@ void InsetMathScript::mathmlize(MathStream & os) const
 }
 
 
+void InsetMathScript::htmlize(HtmlStream & os) const
+{
+       bool d = hasDown() && down().size();
+       bool u = hasUp() && up().size();
+
+       if (nuc().size())
+               os << nuc();
+
+       if (u && d)
+               os << MTag("span", "class='scripts'")
+                        << MTag("span", "class='sup'") << up() << ETag("span")
+                        << MTag("span", "class='sub'") << down() << ETag("span")
+                        << ETag("span");
+       else if (u)
+               os << MTag("sup", "class='math'") << up() << ETag("sup");
+       else if (d)
+               os << MTag("sub", "class='math'") << down() << ETag("sub");
+}
+
+
 void InsetMathScript::octave(OctaveStream & os) const
 {
        if (nuc().size())
@@ -751,4 +772,17 @@ void InsetMathScript::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
+// the idea for dual scripts came from the eLyXer code
+void InsetMathScript::validate(LaTeXFeatures & features) const
+{
+       if (features.runparams().flavor == OutputParams::HTML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.scripts{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
+                       "span.sup{display: block;}\n"
+                       "span.sub{display: block;}\n"
+                       "sub.math{font-size: 75%;}\n"
+                       "sup.math{font-size: 75%;}\n"
+                       "</style>");
+}
+
 } // namespace lyx