From f5bcb24da2821868ae6ce90fff5a2039eee3fd19 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 30 Mar 2010 01:31:25 +0000 Subject: [PATCH] HTML for scripts. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33944 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathScript.cpp | 34 ++++++++++++++++++++++++++++++++++ src/mathed/InsetMathScript.h | 7 +++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp index 1af0e57345..e637e55b8c 100644 --- a/src/mathed/InsetMathScript.cpp +++ b/src/mathed/InsetMathScript.cpp @@ -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(""); +} + } // namespace lyx diff --git a/src/mathed/InsetMathScript.h b/src/mathed/InsetMathScript.h index 569bc79f35..ecdda3b5a7 100644 --- a/src/mathed/InsetMathScript.h +++ b/src/mathed/InsetMathScript.h @@ -60,8 +60,10 @@ public: void maple(MapleStream &) const; /// write content as something readable by Mathematica void mathematica(MathematicaStream &) const; - /// write content as something resembling MathML + /// write content as MathML void mathmlize(MathStream &) const; + /// write content as HTML + void htmlize(HtmlStream &) const; /// write content as something readable by Octave void octave(OctaveStream &) const; @@ -104,7 +106,8 @@ public: void infoize2(odocstream & os) const; /// InsetCode lyxCode() const { return MATH_SCRIPT_CODE; } - + /// + void validate(LaTeXFeatures &features) const; protected: virtual void doDispatch(Cursor & cur, FuncRequest & cmd); private: