]> git.lyx.org Git - features.git/commitdiff
HTML for math boxes.
authorRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 02:37:05 +0000 (02:37 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 02:37:05 +0000 (02:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33948 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathBox.cpp
src/mathed/InsetMathBox.h
src/mathed/MathStream.cpp
src/mathed/MathStream.h

index 17d2b13346d78f187f7d565db3211d54b7aee2e6..b3cc30abcb06661182d79b7fa32451ce18a427e9 100644 (file)
@@ -59,6 +59,13 @@ void InsetMathBox::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathBox::htmlize(HtmlStream & ms) const
+{
+       SetHTMLMode textmode(ms, true);
+       ms << cell(0);
+}
+
+
 void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        FontSetChanger dummy(mi.base, "textnormal");
@@ -85,6 +92,7 @@ void InsetMathBox::validate(LaTeXFeatures & features) const
 {
        if (name_ == "tag" || name_ == "tag*")
                features.require("amsmath");
+
        cell(0).validate(features);
 }
 
@@ -141,6 +149,13 @@ void InsetMathFBox::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathFBox::htmlize(HtmlStream & ms) const
+{
+       SetHTMLMode textmode(ms, true, "class='fbox'");
+       ms << cell(0);
+}
+
+
 void InsetMathFBox::infoize(odocstream & os) const
 {
        os << "FBox: ";
@@ -155,6 +170,7 @@ void InsetMathFBox::validate(LaTeXFeatures & features) const
        if (features.runparams().flavor == OutputParams::HTML)
                features.addPreambleSnippet("<style type=\"text/css\">\n"
                        "mtext.fbox { border: 1px solid black; }\n"
+                       "span.fbox { border: 1px solid black; }\n"
                        "</style>");
 }
 
@@ -275,6 +291,15 @@ void InsetMathMakebox::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathMakebox::htmlize(HtmlStream & ms) const
+{
+       // FIXME We could do something with the other arguments.
+       std::string const cssclass = framebox_ ? "framebox" : "makebox";
+       SetHTMLMode textmode(ms, true, "class='" + cssclass + "'");
+       ms << cell(2);
+}
+
+
 void InsetMathMakebox::validate(LaTeXFeatures & features) const
 {
        // FIXME XHTML
@@ -283,6 +308,7 @@ void InsetMathMakebox::validate(LaTeXFeatures & features) const
        if (features.runparams().flavor == OutputParams::HTML)
                features.addPreambleSnippet("<style type=\"text/css\">\n"
                        "mtext.framebox { border: 1px solid black; }\n"
+                       "span.framebox { border: 1px solid black; }\n"
                        "</style>");
 }
 
@@ -342,6 +368,13 @@ void InsetMathBoxed::mathmlize(MathStream & ms) const
 }
 
 
+void InsetMathBoxed::htmlize(HtmlStream & ms) const
+{
+       SetHTMLMode mathmode(ms, false, "class='boxed'");
+       ms << cell(0);
+}
+
+
 void InsetMathBoxed::validate(LaTeXFeatures & features) const
 {
        features.require("amsmath");
@@ -351,6 +384,7 @@ void InsetMathBoxed::validate(LaTeXFeatures & features) const
        if (features.runparams().flavor == OutputParams::HTML)
                features.addPreambleSnippet("<style type=\"text/css\">\n"
                        "mstyle.boxed { border: 1px solid black; }\n"
+                       "span.boxed { border: 1px solid black; }\n"
                        "</style>");
        InsetMathNest::validate(features);
 }
index 5a958f4b7845eedcc561b16145aa4b9c236785bf..3dfe2286c3a13e49f79ff3cbfa848b247d384f72 100644 (file)
@@ -37,6 +37,8 @@ public:
        ///
        void mathmlize(MathStream & ms) const;
        ///
+       void htmlize(HtmlStream & ms) const;
+       ///
        void infoize(odocstream & os) const;
        ///
        void validate(LaTeXFeatures & features) const;
@@ -68,6 +70,8 @@ public:
        ///
        void mathmlize(MathStream & ms) const;
        ///
+       void htmlize(HtmlStream & ms) const;
+       ///
        void infoize(odocstream & os) const;
        ///
        void validate(LaTeXFeatures & features) const;
@@ -93,6 +97,8 @@ public:
        ///
        void mathmlize(MathStream & ms) const;
        ///
+       void htmlize(HtmlStream & ms) const;
+       ///
        mode_type currentMode() const { return TEXT_MODE; }
        ///
        void infoize(odocstream & os) const;
@@ -121,6 +127,8 @@ public:
        void write(WriteStream & os) const;
        ///
        void mathmlize(MathStream & ms) const;
+       ///
+       void htmlize(HtmlStream & ms) const;
        /// write normalized content
        void normalize(NormalStream & ns) const;
        ///
index 25bb288a50847b6b9114b80cf6f5016eafc0ed53..8f2534bbb16e2d00a91061b78ccb9841b0dce002 100644 (file)
@@ -490,6 +490,43 @@ SetMode::~SetMode()
 //////////////////////////////////////////////////////////////////////
 
 
+SetHTMLMode::SetHTMLMode(HtmlStream & os, bool text)
+       : os_(os), opened_(false)
+{
+       was_text_ = os_.inText();
+       if (text)
+               os_.setTextMode();
+       else
+               os_.setMathMode();
+}
+
+
+SetHTMLMode::SetHTMLMode(HtmlStream & os, bool text, string attrs)
+       : os_(os), opened_(true)
+{
+       was_text_ = os_.inText();
+       if (text) {
+               os_.setTextMode();
+               os_ << MTag("span", attrs);
+       } else
+               os_.setMathMode();
+}
+
+
+SetHTMLMode::~SetHTMLMode()
+{
+       if (opened_)
+               os_ << ETag("span");
+       if (was_text_)
+               os_.setTextMode();
+       else
+               os_.setMathMode();
+}
+
+
+//////////////////////////////////////////////////////////////////////
+
+
 MapleStream & operator<<(MapleStream & ms, MathAtom const & at)
 {
        at->maple(ms);
index cf08afe23c5890405a6664fb4ce4617a7bbacf2d..502848d23419ff6936870a9057c7c5bc8b7b7245 100644 (file)
@@ -392,7 +392,7 @@ private:
        ///
        odocstringstream deferred_;
        ///
-       friend class SetMode;
+       friend class SetHTMLMode;
 };
 
 ///
@@ -413,6 +413,24 @@ HtmlStream & operator<<(HtmlStream &, MTag const &);
 HtmlStream & operator<<(HtmlStream &, ETag const &);
 
 
+class SetHTMLMode {
+public:
+       ///
+       explicit SetHTMLMode(HtmlStream & os, bool text, std::string attrs);
+       ///
+       explicit SetHTMLMode(HtmlStream & os, bool text);
+       ///
+       ~SetHTMLMode();
+private:
+       ///
+       HtmlStream & os_;
+       ///
+       bool opened_;
+       ///
+       bool was_text_;
+};
+
+
 //
 // Debugging
 //