]> git.lyx.org Git - lyx.git/commitdiff
Decorations via HTML.
authorRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 21:56:52 +0000 (21:56 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 30 Mar 2010 21:56:52 +0000 (21:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33955 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathDecoration.cpp
src/mathed/InsetMathDecoration.h

index 7f8c55f665c738895929c71b26676ceb0f5293d3..4077afbfc847b5f6fa668eda6a9dd53b464b69a9 100644 (file)
@@ -150,13 +150,6 @@ void InsetMathDecoration::infoize(odocstream & os) const
 }
 
 
-void InsetMathDecoration::validate(LaTeXFeatures & features) const
-{
-       if (!key_->requires.empty())
-               features.require(to_utf8(key_->requires));
-       InsetMathNest::validate(features);
-}
-
 namespace {
        struct Attributes {
                Attributes() {}
@@ -184,7 +177,7 @@ namespace {
                t["overbrace"] = Attributes(true, "&OverBrace;");
                t["overleftarrow"] = Attributes(true, "&xlarr;");
                t["overleftrightarrow"] = Attributes(true, "&xharr;");
-               t["overline"] = Attributes(false, "&macr;");
+               t["overline"] = Attributes(true, "&macr;");
                t["overrightarrow"] = Attributes(true, "&xrarr;");
                t["tilde"] = Attributes(true, "&tilde;");
                t["underbar"] = Attributes(false, "&UnderBar;");
@@ -220,4 +213,45 @@ void InsetMathDecoration::mathmlize(MathStream & os) const
 }
 
 
+void InsetMathDecoration::htmlize(HtmlStream & os) const
+{
+       Translator const & t = translator();
+       Translator::const_iterator cur = t.find(to_utf8(key_->name));
+       LASSERT(cur != t.end(), return);
+       bool symontop = cur->second.over;
+       string const symclass = symontop ? "symontop" : "symonbot";
+       os << MTag("span", "class='symbolpair " + symclass + "'")
+          << '\n';
+       
+       if (symontop)
+               os << MTag("span", "class='symbol'") << from_ascii(cur->second.tag);
+       else
+               os << MTag("span", "class='base'") << cell(0);
+       os << ETag("span") << '\n';
+       if (symontop)
+               os << MTag("span", "class='base'") << cell(0);
+       else
+               os << MTag("span", "class='symbol'") << from_ascii(cur->second.tag);
+       os << ETag("span") << '\n' << ETag("span") << '\n';
+}
+
+
+// ideas borrowed from the eLyXer code
+void InsetMathDecoration::validate(LaTeXFeatures & features) const
+{
+       if (features.runparams().flavor == OutputParams::HTML) {
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.symbolpair{display: inline-block; text-align:center;}\n"
+                       "span.symontop{vertical-align: top;}\n"
+                       "span.symonbot{vertical-align: bottom;}\n"
+                       "span.symbolpair span{display: block;}\n"                       
+                       "span.symbol{height: 0.5ex;}\n"
+                       "</style>");
+       } else {
+               if (!key_->requires.empty())
+                       features.require(to_utf8(key_->requires));
+       }
+       InsetMathNest::validate(features);
+}
+
 } // namespace lyx
index 22c9f9bed35379aa4671860ae7cc195e90fe8cfe..adabcd7c04425d6637e2a88f3fdee77983aec810 100644 (file)
@@ -43,7 +43,8 @@ public:
        InsetCode lyxCode() const { return MATH_DECORATION_CODE; }
        ///
        void mathmlize(MathStream &) const;
-
+       ///
+       void htmlize(HtmlStream &) const;
 private:
        virtual Inset * clone() const;
        ///