]> git.lyx.org Git - features.git/commitdiff
Integrals via HTML.
authorRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 22:51:02 +0000 (22:51 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 22:51:02 +0000 (22:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33960 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathExInt.cpp
src/mathed/InsetMathExInt.h
src/mathed/InsetMathSymbol.cpp
src/mathed/InsetMathSymbol.h

index 88970e0e9634dbf54783b7d9f9fb0f8b2a0c2f64..ac5409f469aca3e432a9173967890fe357f6d71e 100644 (file)
@@ -11,6 +11,8 @@
 #include <config.h>
 
 #include "InsetMathExInt.h"
+
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathStream.h"
@@ -156,10 +158,35 @@ void InsetMathExInt::mathmlize(MathStream & os) const
 }
 
 
+void InsetMathExInt::htmlize(HtmlStream & os) const
+{
+       // At the moment, we are not extracting sums and the like for HTML.
+       // So right now this only handles integrals.
+       InsetMathSymbol sym(symbol_);
+       bool const lower = !cell(2).empty();
+       bool const upper = !cell(3).empty();
+       
+       os << MTag("span", "class='integral'")
+          << MTag("span", "class='intsym'");
+       sym.htmlize(os, false);
+       os << ETag("span");
+       
+       if (lower && upper) {
+               os << MTag("span", "class='limits'")
+                  << MTag("span") << cell(2) << ETag("span")
+                        << MTag("span") << cell(3) << ETag("span")
+                        << ETag("span");
+       } else if (lower)
+               os << MTag("sub", "class='limit'") << cell(2) << ETag("sub");
+       else if (upper)
+               os << MTag("sup", "class='limit'") << cell(3) << ETag("sup");
+       os << cell(0) << "<b>d</b>" << cell(1) << ETag("span");
+}
+
+
 void InsetMathExInt::write(WriteStream &) const
 {
        LYXERR0("should not happen");
 }
 
-
 } // namespace lyx
index ced825b89074d668e31e1015a2f7baa49f140140..5254166d664ea7c4dd0e7a6958774e417a1b0396 100644 (file)
@@ -54,6 +54,8 @@ public:
        ///
        void mathmlize(MathStream &) const;
        ///
+       void htmlize(HtmlStream &) const;
+       ///
        void write(WriteStream & os) const;
        ///
        InsetCode lyxCode() const { return MATH_EXINT_CODE; }
index 522793cedd13889466d29823d12326e2920dd6ce..5ca45a16fe0804ffbf8f4cc5c88d988b08c123cf 100644 (file)
@@ -130,13 +130,6 @@ bool InsetMathSymbol::takesLimits() const
 }
 
 
-void InsetMathSymbol::validate(LaTeXFeatures & features) const
-{
-       if (!sym_->requires.empty())
-               features.require(to_utf8(sym_->requires));
-}
-
-
 void InsetMathSymbol::normalize(NormalStream & os) const
 {
        os << "[symbol " << name() << ']';
@@ -199,7 +192,7 @@ void InsetMathSymbol::mathmlize(MathStream & os) const
 }
 
 
-void InsetMathSymbol::htmlize(HtmlStream & os) const
+void InsetMathSymbol::htmlize(HtmlStream & os, bool spacing) const
 {
        // FIXME We may need to do more interesting things 
        // with MathMLtype.
@@ -209,13 +202,19 @@ void InsetMathSymbol::htmlize(HtmlStream & os) const
        if (sym_->xmlname == "x") 
                // unknown so far
                os << ' ' << name() << ' ';
-       else if (op) 
+       else if (op && spacing
                os << ' ' << sym_->xmlname << ' ';
        else
                os << sym_->xmlname;
 }
 
 
+void InsetMathSymbol::htmlize(HtmlStream & os) const
+{
+       htmlize(os, true);
+}
+
+
 void InsetMathSymbol::octave(OctaveStream & os) const
 {
        if (name() == "cdot")
@@ -246,4 +245,23 @@ void InsetMathSymbol::infoize2(odocstream & os) const
 }
 
 
+void InsetMathSymbol::validate(LaTeXFeatures & features) const
+{
+       // this is not really the ideal place to do this, but we can't
+       // validate in InsetMathExInt.
+       if (features.runparams().flavor == OutputParams::HTML
+           && sym_->name == from_ascii("int")) {
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.limits{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
+                       "span.limits span{display: block;}\n"
+                       "span.intsym{font-size: 150%;}\n"
+                       "sub.limit{font-size: 75%;}\n"
+                       "sup.limit{font-size: 75%;}\n"
+                       "</style>");
+       } else {
+               if (!sym_->requires.empty())
+                       features.require(to_utf8(sym_->requires));
+       }
+}
+
 } // namespace lyx
index 59df8fb02c8c768ffe773942bc753873353ac1ad..4730513dec0bd7ce5b52be3ab13066a7468d9e06 100644 (file)
@@ -64,6 +64,9 @@ public:
        void mathmlize(MathStream &) const;
        ///
        void htmlize(HtmlStream &) const;
+       /// \param spacing controls whether we print spaces around
+       /// "operator"-type symbols or just print them raw
+       void htmlize(HtmlStream &, bool spacing) const;
        ///
        void octave(OctaveStream &) const;
        ///