From: Richard Heck Date: Tue, 30 Mar 2010 22:51:02 +0000 (+0000) Subject: Integrals via HTML. X-Git-Tag: 2.0.0~3620 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=36b1623c5bf3e51d4a4b104cb32d3e9af578016a;p=features.git Integrals via HTML. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33960 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathExInt.cpp b/src/mathed/InsetMathExInt.cpp index 88970e0e96..ac5409f469 100644 --- a/src/mathed/InsetMathExInt.cpp +++ b/src/mathed/InsetMathExInt.cpp @@ -11,6 +11,8 @@ #include #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) << "d" << cell(1) << ETag("span"); +} + + void InsetMathExInt::write(WriteStream &) const { LYXERR0("should not happen"); } - } // namespace lyx diff --git a/src/mathed/InsetMathExInt.h b/src/mathed/InsetMathExInt.h index ced825b890..5254166d66 100644 --- a/src/mathed/InsetMathExInt.h +++ b/src/mathed/InsetMathExInt.h @@ -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; } diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index 522793cedd..5ca45a16fe 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -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(""); + } else { + if (!sym_->requires.empty()) + features.require(to_utf8(sym_->requires)); + } +} + } // namespace lyx diff --git a/src/mathed/InsetMathSymbol.h b/src/mathed/InsetMathSymbol.h index 59df8fb02c..4730513dec 100644 --- a/src/mathed/InsetMathSymbol.h +++ b/src/mathed/InsetMathSymbol.h @@ -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; ///