else if (tag == "mathcal")
variant == "script";
else if (tag == "mathit" || tag == "textsl"
- || tag == "emph")
+ || tag == "emph" || tag == "textit")
variant = "italic";
- else if (tag == "mathsf" || tag == "textit"
- || tag == "textsf")
+ else if (tag == "mathsf" || tag == "textsf")
variant = "sans-serif";
else if (tag == "mathtt" || tag == "texttt")
variant = "monospace";
// no support at present for textipa, textsc, noun
- // FIXME We need some kind of "mode tracker", so we can
- // just output verbatim text in some cases.
docstring const beg = (tag.size() < 4) ? from_ascii("") : tag.substr(0, 4);
bool const textmode = (beg == "text");
if (!variant.empty()) {
- os << "<mstyle mathvariant='" << from_utf8(variant) << "'>";
- SetMode sm(os, textmode);
+ docstring const attrs = from_ascii("mathvariant='" + variant + "'");
+ SetMode sm(os, textmode, attrs);
+ os << cell(0);
+ } else
os << cell(0);
- os << "</mstyle>";
- }
}
} else if (ar.size() == 1)
os << ar.front();
else {
- os << (os.inText() ? MTag("mtext") : MTag("mrow"));
+ if (!os.inText())
+ os << MTag("mrow");
for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
(*it)->mathmlize(os);
- os << (os.inText() ? ETag("mtext") : ETag("mrow"));
+ if (!os.inText())
+ os << ETag("mrow");
}
}
}
+SetMode::SetMode(MathStream & os, bool text, docstring attrs)
+ : os_(os)
+{
+ was_text_ = os.inText();
+ if (was_text_)
+ os << "</mtext>";
+ if (text) {
+ os.setTextMode();
+ os << "<mtext";
+ if (!attrs.empty())
+ os << " " << attrs;
+ os << ">";
+ } else {
+ if (!attrs.empty())
+ os << "<mstyle " << attrs << ">";
+ os.setMathMode();
+ }
+}
+
+
+SetMode::~SetMode()
+{
+ if (os_.inText())
+ os_ << "</mtext>";
+ if (was_text_) {
+ os_.setTextMode();
+ os_ << "<mtext>";
+ } else {
+ os_.setMathMode();
+ }
+}
+
+
//////////////////////////////////////////////////////////////////////
class SetMode {
public:
///
- explicit SetMode(MathStream & os, bool text)
- : os_(os)
- {
- was_text_ = os.inText();
- if (text)
- os.setTextMode();
- else
- os.setMathMode();
- }
+ explicit SetMode(MathStream & os, bool text, docstring attrs);
+ // not clear yet precisely what we need...
+ // explicit SetMode(MathStream & os, bool text);
///
- ~SetMode()
- {
- if (was_text_)
- os_.setTextMode();
- else
- os_.setMathMode();
- }
+ ~SetMode();
private:
///
MathStream & os_;