}
-void InsetMath::mathmlize(MathStream & os) const
+void InsetMath::mathmlize(MathStream & ms) const
{
- os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
- os << MTag("mi");
- NormalStream ns(os.os());
+ ms << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
+ ms << MTag("mi");
+ NormalStream ns(ms.os());
normalize(ns);
- os << ETag("mi");
+ ms << ETag("mi");
}
}
-void InsetMathBig::mathmlize(MathStream & os) const
+void InsetMathBig::mathmlize(MathStream & ms) const
{
- os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>"
+ ms << "<" << from_ascii(ms.namespacedTag("mo"))
+ << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
<< convertDelimToXMLEscape(delim_)
- << "</mo>";
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
}
}
-void InsetMathBoldSymbol::mathmlize(MathStream & os) const
+void InsetMathBoldSymbol::mathmlize(MathStream & ms) const
{
- os << "<mstyle mathvariant='bold'>" << cell(0) << "</mstyle>";
+ ms << "<" << from_ascii(ms.namespacedTag("mstyle")) << " mathvariant='bold'>"
+ << cell(0)
+ << "</" << from_ascii(ms.namespacedTag("mstyle")) << ">";
}
}
-void InsetMathBrace::mathmlize(MathStream & os) const
+void InsetMathBrace::mathmlize(MathStream & ms) const
{
- os << MTag("mrow") << cell(0) << ETag("mrow");
+ ms << MTag("mrow") << cell(0) << ETag("mrow");
}
}
-void InsetMathCancel::mathmlize(MathStream & os) const
+void InsetMathCancel::mathmlize(MathStream & ms) const
{
switch (kind_) {
case cancel:
- os << MTag("menclose", "notation='updiagonalstrike'")
+ ms << MTag("menclose", "notation='updiagonalstrike'")
<< cell(0)
<< ETag("menclose");
break;
case bcancel:
- os << MTag("menclose", "notation='downdiagonalstrike'")
+ ms << MTag("menclose", "notation='downdiagonalstrike'")
<< cell(0)
<< ETag("menclose");
break;
case xcancel:
- os << MTag("menclose", "notation='updiagonalstrike'")
+ ms << MTag("menclose", "notation='updiagonalstrike'")
<< MTag("menclose", "notation='downdiagonalstrike'")
<< cell(0)
<< ETag("menclose")
void InsetMathCases::mathmlize(MathStream & ms) const
{
- ms << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>{</mo>";
+ ms << "<" << from_ascii(ms.namespacedTag("mo"))
+ << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
+ << "{"
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
InsetMathGrid::mathmlize(ms);
}
}
if (!entity.empty()) {
- ms << "<mo>" << from_ascii(entity) << "</mo>";
+ ms << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << from_ascii(entity)
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
return;
}
char const * type =
(isAlphaASCII(char_) || Encodings::isMathAlpha(char_))
? "mi" : "mo";
- // we don't use MTag and ETag because we do not want the spacing
- ms << "<" << type << ">" << char_type(char_) << "</" << type << ">";
+ // we don't use MTag and ETag because we do not want the spacing before the end tag.
+ docstring tag = from_ascii(ms.namespacedTag(type));
+ ms << "<" << tag << ">" << char_type(char_) << "</" << tag << ">";
}
}
-void InsetMathComment::mathmlize(MathStream & os) const
+void InsetMathComment::mathmlize(MathStream & ms) const
{
- os << MTag("comment") << cell(0) << ETag("comment");
+ ms << MTag("comment") << cell(0) << ETag("comment");
}
}
} // namespace
-void InsetMathDecoration::mathmlize(MathStream & os) const
+void InsetMathDecoration::mathmlize(MathStream & ms) const
{
TranslationMap const & t = translationMap();
TranslationMap::const_iterator cur = t.find(to_utf8(key_->name));
LASSERT(cur != t.end(), return);
char const * const outag = cur->second.over ? "mover" : "munder";
- os << MTag(outag)
- << MTag("mrow") << cell(0) << ETag("mrow")
- << from_ascii("<mo stretchy=\"true\">" + cur->second.tag + "</mo>")
- << ETag(outag);
+ ms << MTag(outag)
+ << MTag("mrow") << cell(0) << ETag("mrow")
+ << "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">"
+ << from_ascii(cur->second.tag)
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << ETag(outag);
}
}
-void InsetMathDelim::mathmlize(MathStream & os) const
+void InsetMathDelim::mathmlize(MathStream & ms) const
{
- os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>"
- << "<mrow>"
+ ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true'>"
+ << "<" << from_ascii(ms.namespacedTag("mrow")) << ">"
<< convertDelimToXMLEscape(left_)
- << "</mrow>"
- << "</mo>\n"
+ << "</" << from_ascii(ms.namespacedTag("mrow")) << ">"
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << "\n"
<< cell(0)
- << "\n<mo form='postfix' fence='true' stretchy='true' symmetric='true'>"
- << "<mrow>"
+ << "\n"
+ << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true'>"
+ << "<" << from_ascii(ms.namespacedTag("mrow")) << ">"
<< convertDelimToXMLEscape(right_)
- << "</mrow>"
- << "</mo>\n";
+ << "</" << from_ascii(ms.namespacedTag("mrow")) << ">"
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << "\n";
}
}
-void InsetMathDots::mathmlize(MathStream & os) const
+void InsetMathDots::mathmlize(MathStream & ms) const
{
// which symbols we support is decided by what is listed in
// lib/symbols as generating a dots inset
ent = "⋮";
else
LASSERT(false, ent = "…");
- os << MTag("mi") << from_ascii(ent) << ETag("mi");
+ ms << MTag("mi") << from_ascii(ent) << ETag("mi");
}
///
InsetCode lyxCode() const { return MATH_DOTS_CODE; }
///
- void mathmlize(MathStream & os) const;
+ void mathmlize(MathStream & ms) const;
///
void htmlize(HtmlStream & os) const;
protected:
}
-void InsetMathEnsureMath::mathmlize(MathStream & os) const
+void InsetMathEnsureMath::mathmlize(MathStream & ms) const
{
- SetMode mathmode(os, false);
- os << MTag("mstyle", "class='math'")
+ SetMode mathmode(ms, false);
+ ms << MTag("mstyle", "class='math'")
<< cell(0)
<< ETag("mstyle");
}
}
-void InsetMathExFunc::mathmlize(MathStream & os) const
+void InsetMathExFunc::mathmlize(MathStream & ms) const
{
- os << "<mi>" << name_ << "</mi><mo>⁡</mo>";
- os << cell(0);
+ ms << "<" << from_ascii(ms.namespacedTag("mi")) << ">"
+ << name_
+ << "</" << from_ascii(ms.namespacedTag("mi")) << ">"
+ << "<" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << "⁡"
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << cell(0);
}
}
-void InsetMathExInt::mathmlize(MathStream & os) const
+void InsetMathExInt::mathmlize(MathStream & ms) const
{
// At the moment, we are not extracting sums and the like for MathML.
// If we should decide to do so later, then we'll need to re-merge
bool const lower = !cell(2).empty();
bool const upper = !cell(3).empty();
if (lower && upper)
- os << MTag("msubsup");
+ ms << MTag("msubsup");
else if (lower)
- os << MTag("msub");
+ ms << MTag("msub");
else if (upper)
- os << MTag("msup");
- os << MTag("mrow");
- sym.mathmlize(os);
- os << ETag("mrow");
+ ms << MTag("msup");
+ ms << MTag("mrow");
+ sym.mathmlize(ms);
+ ms << ETag("mrow");
if (lower)
- os << MTag("mrow") << cell(2) << ETag("mrow");
+ ms << MTag("mrow") << cell(2) << ETag("mrow");
if (upper)
- os << MTag("mrow") << cell(3) << ETag("mrow");
+ ms << MTag("mrow") << cell(3) << ETag("mrow");
if (lower && upper)
- os << ETag("msubsup");
+ ms << ETag("msubsup");
else if (lower)
- os << ETag("msub");
+ ms << ETag("msub");
else if (upper)
- os << ETag("msup");
- os << cell(0) << "<mo> ⁢ </mo>"
- << MTag("mrow") << "<mo> ⅆ </mo>"
- << cell(1) << ETag("mrow");
+ ms << ETag("msup");
+ ms << cell(0)
+ << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
+ << " ⁢ "
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << MTag("mrow")
+ << "<" << from_ascii(ms.namespacedTag("mo")) << "> "
+ << " ⅆ "
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << cell(1)
+ << ETag("mrow");
}
// The fonts we want to support are listed in lib/symbols
-void InsetMathFont::mathmlize(MathStream & os) const
+void InsetMathFont::mathmlize(MathStream & ms) const
{
// FIXME These are not quite right, because they do not nest
// correctly. A proper fix would presumably involve tracking
// no support at present for textipa, textsc, noun
if (!variant.empty())
- os << MTag("mstyle", "mathvariant='" + variant + "'")
+ ms << MTag("mstyle", "mathvariant='" + variant + "'")
<< cell(0)
<< ETag("mstyle");
else
- os << cell(0);
+ ms << cell(0);
}
}
-void InsetMathFrac::mathmlize(MathStream & os) const
+void InsetMathFrac::mathmlize(MathStream & ms) const
{
switch (kind_) {
case ATOP:
- os << MTag("mfrac", "linethickeness='0'")
+ ms << MTag("mfrac", "linethickness='0'")
<< MTag("mrow") << cell(0) << ETag("mrow")
- << MTag("mrow") << cell(1) << ETag("mrow")
- << ETag("mfrac");
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
break;
// we do not presently distinguish these
case CFRAC:
case CFRACLEFT:
case CFRACRIGHT:
- os << MTag("mfrac")
+ ms << MTag("mfrac")
<< MTag("mrow") << cell(0) << ETag("mrow")
- << MTag("mrow") << cell(1) << ETag("mrow")
- << ETag("mfrac");
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
break;
case NICEFRAC:
- os << MTag("mfrac", "bevelled='true'")
+ ms << MTag("mfrac", "bevelled='true'")
<< MTag("mrow") << cell(0) << ETag("mrow")
- << MTag("mrow") << cell(1) << ETag("mrow")
- << ETag("mfrac");
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
break;
case UNITFRAC:
if (nargs() == 3)
- os << cell(2);
- os << MTag("mfrac", "bevelled='true'")
+ ms << cell(2);
+ ms << MTag("mfrac", "bevelled='true'")
<< MTag("mrow") << cell(0) << ETag("mrow")
- << MTag("mrow") << cell(1) << ETag("mrow")
- << ETag("mfrac");
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
break;
case UNIT:
// FIXME This is not right, because we still output mi, etc,
// when we output the cell. So we need to prevent that somehow.
if (nargs() == 2)
- os << cell(0)
- << MTag("mstyle mathvariant='normal'")
- << cell(1)
+ ms << cell(0)
+ << MTag("mstyle mathvariant='normal'")
+ << cell(1)
<< ETag("mstyle");
else
- os << MTag("mstyle mathvariant='normal'")
+ ms << MTag("mstyle mathvariant='normal'")
<< cell(0)
<< ETag("mstyle");
}
}
-void InsetMathBinom::mathmlize(MathStream & os) const
+void InsetMathBinom::mathmlize(MathStream & ms) const
{
char ldelim = ' ';
char rdelim = ' ';
rdelim = ']';
break;
}
- os << "<mo fence='true' stretchy='true' form='prefix'>" << ldelim << "</mo>"
- << "<mfrac linethickness='0'>"
+ ms << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' stretchy='true' form='prefix'>"
+ << ldelim
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
+ << "<" << from_ascii(ms.namespacedTag("mfrac")) << " linethickness='0'>"
<< cell(0) << cell(1)
- << "</mfrac>"
- << "<mo fence='true' stretchy='true' form='postfix'>" << rdelim << "</mo>";
+ << "</" << from_ascii(ms.namespacedTag("mfrac")) << ">"
+ << "<" << from_ascii(ms.namespacedTag("mo")) << " fence='true' stretchy='true' form='postfix'>"
+ << rdelim
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
}
}
-void InsetMathGrid::mathmlize(MathStream & os) const
+void InsetMathGrid::mathmlize(MathStream & ms) const
{
bool const havetable = nrows() > 1 || ncols() > 1;
if (havetable)
- os << MTag("mtable");
+ ms << MTag("mtable");
char const * const celltag = havetable ? "mtd" : "mrow";
for (row_type row = 0; row < nrows(); ++row) {
if (havetable)
- os << MTag("mtr");
+ ms << MTag("mtr");
for (col_type col = 0; col < ncols(); ++col) {
idx_type const i = index(row, col);
if (cellinfo_[i].multi != CELL_PART_OF_MULTICOLUMN) {
ostringstream attr;
if (havetable && cellcols > 1)
attr << "colspan='" << cellcols << '\'';
- os << MTag(celltag, attr.str());
- os << cell(index(row, col));
- os << ETag(celltag);
+ ms << MTag(celltag, attr.str());
+ ms << cell(index(row, col));
+ ms << ETag(celltag);
}
}
if (havetable)
- os << ETag("mtr");
+ ms << ETag("mtr");
}
if (havetable)
- os << ETag("mtable");
+ ms << ETag("mtable");
}
// this duplicates code from InsetMathGrid, but
// we need access here to number information,
// and we simply do not have that in InsetMathGrid.
-void InsetMathHull::mathmlize(MathStream & os) const
+void InsetMathHull::mathmlize(MathStream & ms) const
{
bool const havenumbers = haveNumbers();
bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
if (havetable)
- os << MTag("mtable");
+ ms << MTag("mtable");
char const * const celltag = havetable ? "mtd" : "mrow";
// FIXME There does not seem to be wide support at the moment
// for mlabeledtr, so we have to use just mtr for now.
char const * const rowtag = "mtr";
for (row_type row = 0; row < nrows(); ++row) {
if (havetable)
- os << MTag(rowtag);
+ ms << MTag(rowtag);
for (col_type col = 0; col < ncols(); ++col) {
- os << MTag(celltag)
+ ms << MTag(celltag)
<< cell(index(row, col))
<< ETag(celltag);
}
// fleqn?
if (havenumbers) {
- os << MTag("mtd");
+ ms << MTag("mtd");
docstring const & num = numbers_[row];
if (!num.empty())
- os << '(' << num << ')';
- os << ETag("mtd");
+ ms << '(' << num << ')';
+ ms << ETag("mtd");
}
if (havetable)
- os << ETag(rowtag);
+ ms << ETag(rowtag);
}
if (havetable)
- os << ETag("mtable");
+ ms << ETag("mtable");
}
}
-void InsetMathMacro::mathmlize(MathStream & os) const
+void InsetMathMacro::mathmlize(MathStream & ms) const
{
// macro_ is 0 if this is an unknown macro
LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
docstring const xmlname = d->macro_->xmlname();
if (!xmlname.empty()) {
char const * type = d->macro_->MathMLtype();
- os << '<' << type << "> " << xmlname << " </"
- << type << '>';
+ ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
+ << xmlname
+ << "</" << from_ascii(ms.namespacedTag(type)) << ">";
return;
}
}
// this means that we do not recognize the macro
throw MathExportException();
}
- os << d->expanded_;
+ ms << d->expanded_;
}
}
-void InsetMathMatrix::mathmlize(MathStream & os) const
+void InsetMathMatrix::mathmlize(MathStream & ms) const
{
- os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
- << convertDelimToXMLEscape(left_)
- << "</mo>"
+ ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+ << convertDelimToXMLEscape(left_)
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
<< MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) {
- os << MTag("mtr");
+ ms << MTag("mtr");
for (col_type col = 0; col < ncols(); ++col) {
idx_type const i = index(row, col);
if (cellinfo(i).multi != CELL_PART_OF_MULTICOLUMN) {
ostringstream attr;
if (cellcols > 1)
attr << "columnspan='" << cellcols << '\'';
- os << MTag("mtd", attr.str()) << cell(i) << ETag("mtd");
+ ms << MTag("mtd", attr.str()) << cell(i) << ETag("mtd");
}
}
- os << ETag("mtr");
+ ms << ETag("mtr");
}
- os << ETag("mtable");
- os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
- << convertDelimToXMLEscape(right_)
- << "</mo>";
+ ms << ETag("mtable")
+ << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
+ << convertDelimToXMLEscape(right_)
+ << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
}
}
-void InsetMathNumber::mathmlize(MathStream & os) const
+void InsetMathNumber::mathmlize(MathStream & ms) const
{
- os << "<mn>" << str_ << "</mn>";
+ ms << "<" << from_ascii(ms.namespacedTag("mn")) << ">"
+ << str_
+ << "</" << from_ascii(ms.namespacedTag("mn")) << ">";
}
void InsetMathOverset::mathmlize(MathStream & ms) const
{
- ms << "<mover accent='false'>" << cell(0) << cell(1) << "</mover>";
+ ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+ << cell(0) << cell(1)
+ << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
}
void InsetMathOverset::htmlize(HtmlStream & os) const
{
os << MTag("span", "class='overset'")
- << MTag("span", "class='top'") << cell(1) << ETag("span")
- << MTag("span") << cell(0) << ETag("span")
- << ETag("span");
+ << MTag("span", "class='top'") << cell(1) << ETag("span")
+ << MTag("span") << cell(0) << ETag("span")
+ << ETag("span");
}
}
-void InsetMathRoot::mathmlize(MathStream & os) const
+void InsetMathRoot::mathmlize(MathStream & ms) const
{
- os << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
+ ms << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
}
}
-void InsetMathScript::mathmlize(MathStream & os) const
+void InsetMathScript::mathmlize(MathStream & ms) const
{
bool d = hasDown() && !down().empty();
bool u = hasUp() && !up().empty();
bool l = hasLimits();
if (u && d)
- os << MTag(l ? "munderover" : "msubsup");
+ ms << MTag(l ? "munderover" : "msubsup");
else if (u)
- os << MTag(l ? "mover" : "msup");
+ ms << MTag(l ? "mover" : "msup");
else if (d)
- os << MTag(l ? "munder" : "msub");
+ ms << MTag(l ? "munder" : "msub");
if (!nuc().empty())
- os << MTag("mrow") << nuc() << ETag("mrow");
+ ms << MTag("mrow") << nuc() << ETag("mrow");
else
- os << "<mrow />";
+ ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
if (u && d)
- os << MTag("mrow") << down() << ETag("mrow")
+ ms << MTag("mrow") << down() << ETag("mrow")
<< MTag("mrow") << up() << ETag("mrow")
<< ETag(l ? "munderover" : "msubsup");
else if (u)
- os << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" : "msup");
+ ms << MTag("mrow") << up() << ETag("mrow") << ETag(l ? "mover" : "msup");
else if (d)
- os << MTag("mrow") << down() << ETag("mrow") << ETag(l ? "munder" : "msub");
+ ms << MTag("mrow") << down() << ETag("mrow") << ETag(l ? "munder" : "msub");
}
}
-void InsetMathSideset::mathmlize(MathStream & os) const
+void InsetMathSideset::mathmlize(MathStream & ms) const
{
// FIXME This is only accurate if both scriptl_ and scriptr_ are true
if (!scriptl_)
- os << MTag("mrow") << bl() << ETag("mrow");
+ ms << MTag("mrow") << bl() << ETag("mrow");
if (scriptl_ || scriptr_) {
- os << MTag("mmultiscripts");
+ ms << MTag("mmultiscripts");
if (nuc().empty())
- os << "<mrow />";
+ ms << "<" << from_ascii(ms.namespacedTag("mrow")) << " />";
else
- os << MTag("mrow") << nuc() << ETag("mrow");
+ ms << MTag("mrow") << nuc() << ETag("mrow");
if (br().empty() || !scriptr_)
- os << "<none />";
+ ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
else
- os << MTag("mrow") << br() << ETag("mrow");
+ ms << MTag("mrow") << br() << ETag("mrow");
if (tr().empty() || !scriptr_)
- os << "<none />";
+ ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
else
- os << MTag("mrow") << tr() << ETag("mrow");
+ ms << MTag("mrow") << tr() << ETag("mrow");
if (bl().empty() || !scriptl_)
- os << "<none />";
+ ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
else
- os << MTag("mrow") << bl() << ETag("mrow");
+ ms << MTag("mrow") << bl() << ETag("mrow");
if (tl().empty() || !scriptl_)
- os << "<none />";
+ ms << "<" << from_ascii(ms.namespacedTag("none")) << " />";
else
- os << MTag("mrow") << tl() << ETag("mrow");
+ ms << MTag("mrow") << tl() << ETag("mrow");
- os << ETag("mmultiscripts");
+ ms << ETag("mmultiscripts");
}
if (!scriptr_)
- os << MTag("mrow") << br() << ETag("mrow");
+ ms << MTag("mrow") << br() << ETag("mrow");
}
l = ss.str() + "px";
}
- ms << "<mspace";
+ ms << "<" << from_ascii(ms.namespacedTag("mspace"));
if (!l.empty())
ms << " width=\"" << from_ascii(l) << "\"";
ms << " />";
}
-void InsetMathSqrt::mathmlize(MathStream & os) const
+void InsetMathSqrt::mathmlize(MathStream & ms) const
{
- os << MTag("msqrt") << cell(0) << ETag("msqrt");
+ ms << MTag("msqrt") << cell(0) << ETag("msqrt");
}
void InsetMathStackrel::mathmlize(MathStream & ms) const
{
if (nargs() > 2)
- ms << "<munderover>" << cell(0) << cell(2) << cell(1) << "</munderover>";
+ ms << "<" << from_ascii(ms.namespacedTag("munderover")) << ">"
+ << cell(0) << cell(2) << cell(1)
+ << "</" << from_ascii(ms.namespacedTag("munderover")) << ">";
else
- ms << "<mover accent='false'>" << cell(0) << cell(1) << "</mover>";
+ ms << "<" << from_ascii(ms.namespacedTag("mover")) << " accent='false'>"
+ << cell(0) << cell(1)
+ << "</" << from_ascii(ms.namespacedTag("mover")) << ">";
}
}
-void InsetMathSubstack::mathmlize(MathStream & os) const
+void InsetMathSubstack::mathmlize(MathStream & ms) const
{
int movers = 0;
row_type const numrows = nrows();
for (row_type row = 0; row < nrows(); ++row) {
if (row < numrows - 1) {
movers ++;
- os << MTag("munder");
+ ms << MTag("munder");
}
- os << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
+ ms << MTag("mrow") << cell(index(row, 0)) << ETag("mrow");
}
for (int i = 1; i <= movers; ++i)
- os << ETag("munder");
+ ms << ETag("munder");
}
}
-void InsetMathSymbol::mathmlize(MathStream & os) const
+void InsetMathSymbol::mathmlize(MathStream & ms) const
{
// FIXME We may need to do more interesting things
// with MathMLtype.
- char const * type = sym_->MathMLtype();
- os << '<' << type << "> ";
+ docstring tag = from_ascii(ms.namespacedTag(sym_->MathMLtype()));
+ ms << '<' << tag << ">";
if (sym_->xmlname == "x")
// unknown so far
- os << name();
+ ms << name();
else
- os << sym_->xmlname;
- os << " </" << type << '>';
+ ms << sym_->xmlname;
+ ms << "</" << tag << '>';
}
void InsetMathUnderset::mathmlize(MathStream & ms) const
{
- ms << "<munder accent='false'>" << cell(0) << cell(1) << "</munder>";
+ ms << "<" << from_ascii(ms.namespacedTag("munder")) << " accent='false'>"
+ << cell(0) << cell(1)
+ << "</" << from_ascii(ms.namespacedTag("munder")) << ">";
}
lyxerr << "mathmlize conversion for '" << name_ << "' not implemented" << endl;
LASSERT(false, arrow = "→");
}
- ms << "<munderover accent='false' accentunder='false'>"
+ ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>"
<< arrow << cell(1) << cell(0)
- << "</munderover>";
+ << "</" << from_ascii(ms.namespacedTag("munderover"))<< ">";
}
}
-void mathmlize(MathData const & dat, MathStream & os)
+void mathmlize(MathData const & dat, MathStream & ms)
{
MathData ar = dat;
extractStructure(ar, MATHML);
if (ar.empty())
- os << "<mrow/>";
+ ms << "<" << from_ascii(ms.namespacedTag("mrow")) << "/>";
else if (ar.size() == 1)
- os << ar.front();
+ ms << ar.front();
else {
- os << MTag("mrow");
+ ms << MTag("mrow");
for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
- (*it)->mathmlize(os);
- os << ETag("mrow");
+ (*it)->mathmlize(ms);
+ ms << ETag("mrow");
}
}
//////////////////////////////////////////////////////////////////////
-MathStream::MathStream(odocstream & os)
- : os_(os), tab_(0), line_(0), in_text_(false)
+MathStream::MathStream(odocstream & os, std::string xmlns)
+ : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
{}
{
++ms.tab();
ms.cr();
- ms.os() << '<' << from_ascii(t.tag_);
+ ms.os() << '<' << from_ascii(ms.namespacedTag(t.tag_));
if (!t.attr_.empty())
ms.os() << " " << from_ascii(t.attr_);
- ms << '>';
+ ms << ">";
return ms;
}
ms.cr();
if (ms.tab() > 0)
--ms.tab();
- ms.os() << "</" << from_ascii(t.tag_) << '>';
+ ms.os() << "</" << from_ascii(ms.namespacedTag(t.tag_)) << ">";
+ return ms;
+}
+
+
+MathStream & operator<<(MathStream & ms, CTag const & t)
+{
+ ms.cr();
+ ms.os() << "<" << from_ascii(ms.namespacedTag(t.tag_));
+ if (!t.attr_.empty())
+ ms.os() << " " << from_utf8(t.attr_);
+ ms.os() << "/>";
return ms;
}
//////////////////////////////////////////////////////////////////////
-SetMode::SetMode(MathStream & os, bool text)
- : os_(os)
+SetMode::SetMode(MathStream & ms, bool text)
+ : ms_(ms)
{
- was_text_ = os_.inText();
- os_.setTextMode(text);
+ was_text_ = ms_.inText();
+ ms_.setTextMode(text);
}
SetMode::~SetMode()
{
- os_.setTextMode(was_text_);
+ ms_.setTextMode(was_text_);
}
// MathML
//
+
+/// Start tag.
class MTag {
public:
///
std::string attr_;
};
+
+/// End tag.
class ETag {
public:
///
};
+/// Compound tag (no content, directly closed).
+class CTag {
+public:
+ ///
+ CTag(char const * const tag, std::string attr = "")
+ : tag_(tag), attr_(attr) {}
+ ///
+ char const * const tag_;
+ ///
+ std::string attr_;
+};
+
+
/// Throw MathExportException to signal that the attempt to export
/// some math in the current format did not succeed. E.g., we can't
/// export xymatrix as MathML, so that will throw, and we'll fall back
class MathStream {
public:
- ///
- explicit MathStream(odocstream & os);
+ /// Builds a stream proxy for os; the MathML namespace is given by xmlns (supposed to be already defined elsewhere in the document).
+ explicit MathStream(odocstream & os, std::string xmlns="");
///
void cr();
///
docstring deferred() const;
///
bool inText() const { return in_text_; }
+ ///
+ std::string xmlns() const { return xmlns_; }
+ /// Returns the tag name prefixed by the name space if needed.
+ std::string namespacedTag(std::string tag) const { return ((xmlns().empty()) ? "" : xmlns() + ":") + tag; }
private:
///
void setTextMode(bool t) { in_text_ = t; }
///
odocstringstream deferred_;
///
+ std::string xmlns_;
+ ///
friend class SetMode;
};
MathStream & operator<<(MathStream &, MTag const &);
///
MathStream & operator<<(MathStream &, ETag const &);
+///
+MathStream & operator<<(MathStream &, CTag const &);
/// A simpler version of ModeSpecifier, for MathML
class SetMode {
public:
///
- explicit SetMode(MathStream & os, bool text);
+ explicit SetMode(MathStream & ms, bool text);
///
~SetMode();
private:
///
- MathStream & os_;
+ MathStream & ms_;
///
bool was_text_;
};