Integrals via HTML.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33960 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-03-30 22:51:02 +00:00
parent ab2a59b0a1
commit 36b1623c5b
4 changed files with 60 additions and 10 deletions

View File

@ -11,6 +11,8 @@
#include <config.h>
#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) << "<b>d</b>" << cell(1) << ETag("span");
}
void InsetMathExInt::write(WriteStream &) const
{
LYXERR0("should not happen");
}
} // namespace lyx

View File

@ -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; }

View File

@ -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("<style type=\"text/css\">\n"
"span.limits{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
"span.limits span{display: block;}\n"
"span.intsym{font-size: 150%;}\n"
"sub.limit{font-size: 75%;}\n"
"sup.limit{font-size: 75%;}\n"
"</style>");
} else {
if (!sym_->requires.empty())
features.require(to_utf8(sym_->requires));
}
}
} // namespace lyx

View File

@ -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;
///