From 69fc590ee3841a332cfca860efc4911febc0043b Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 30 Mar 2010 21:56:52 +0000 Subject: [PATCH] Decorations via HTML. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33955 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathDecoration.cpp | 50 +++++++++++++++++++++++++----- src/mathed/InsetMathDecoration.h | 3 +- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index 7f8c55f665..4077afbfc8 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -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, "⏞"); t["overleftarrow"] = Attributes(true, "⟵"); t["overleftrightarrow"] = Attributes(true, "⟷"); - t["overline"] = Attributes(false, "¯"); + t["overline"] = Attributes(true, "¯"); t["overrightarrow"] = Attributes(true, "⟶"); t["tilde"] = Attributes(true, "˜"); t["underbar"] = Attributes(false, "_"); @@ -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(""); + } else { + if (!key_->requires.empty()) + features.require(to_utf8(key_->requires)); + } + InsetMathNest::validate(features); +} + } // namespace lyx diff --git a/src/mathed/InsetMathDecoration.h b/src/mathed/InsetMathDecoration.h index 22c9f9bed3..adabcd7c04 100644 --- a/src/mathed/InsetMathDecoration.h +++ b/src/mathed/InsetMathDecoration.h @@ -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; /// -- 2.39.5