mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
Use SetMode() to manage text and math mode.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32703 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4479a7f689
commit
0b8c6246ff
@ -167,13 +167,27 @@ void InsetMathChar::octave(OctaveStream & os) const
|
|||||||
// Worst case: We get bad spacing, or bad italics.
|
// Worst case: We get bad spacing, or bad italics.
|
||||||
void InsetMathChar::mathmlize(MathStream & ms) const
|
void InsetMathChar::mathmlize(MathStream & ms) const
|
||||||
{
|
{
|
||||||
|
std::string entity;
|
||||||
switch (char_) {
|
switch (char_) {
|
||||||
case '<': ms << "<mo><</mo>"; return;
|
case '<': entity = "<"; break;
|
||||||
case '>': ms << "<mo>></mo>"; return;
|
case '>': entity = ">"; break;
|
||||||
case '&': ms << "<mo>&</mo>"; return;
|
case '&': entity = "&"; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ms.inText()) {
|
||||||
|
if (entity.empty())
|
||||||
|
ms << char_type(char_);
|
||||||
|
else
|
||||||
|
ms << from_ascii(entity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.empty()) {
|
||||||
|
ms << "<mo>" << from_ascii(entity) << "</mo>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char const * type =
|
char const * type =
|
||||||
(isalpha(char_) || Encodings::isMathAlpha(char_))
|
(isalpha(char_) || Encodings::isMathAlpha(char_))
|
||||||
? "mi" : "mo";
|
? "mi" : "mo";
|
||||||
|
@ -113,33 +113,39 @@ void InsetMathFont::mathmlize(MathStream & os) const
|
|||||||
// correctly. A proper fix would presumably involve tracking
|
// correctly. A proper fix would presumably involve tracking
|
||||||
// the fonts already in effect.
|
// the fonts already in effect.
|
||||||
std::string variant;
|
std::string variant;
|
||||||
if (key_->name == "mathnormal" || key_->name == "mathrm"
|
docstring const & tag = key_->name;
|
||||||
|| key_->name == "text" || key_->name == "textnormal"
|
if (tag == "mathnormal" || tag == "mathrm"
|
||||||
|| key_->name == "textrm" || key_->name == "textup"
|
|| tag == "text" || tag == "textnormal"
|
||||||
|| key_->name == "textmd")
|
|| tag == "textrm" || tag == "textup"
|
||||||
|
|| tag == "textmd")
|
||||||
variant = "normal";
|
variant = "normal";
|
||||||
else if (key_->name == "frak" || key_->name == "mathfrak")
|
else if (tag == "frak" || tag == "mathfrak")
|
||||||
variant = "fraktur";
|
variant = "fraktur";
|
||||||
else if (key_->name == "mathbb" || key_->name == "mathbf"
|
else if (tag == "mathbb" || tag == "mathbf"
|
||||||
|| key_->name == "textbf")
|
|| tag == "textbf")
|
||||||
variant = "bold";
|
variant = "bold";
|
||||||
else if (key_->name == "mathcal")
|
else if (tag == "mathcal")
|
||||||
variant == "script";
|
variant == "script";
|
||||||
else if (key_->name == "mathit" || key_->name == "textsl"
|
else if (tag == "mathit" || tag == "textsl"
|
||||||
|| key_->name == "emph")
|
|| tag == "emph")
|
||||||
variant = "italic";
|
variant = "italic";
|
||||||
else if (key_->name == "mathsf" || key_->name == "textit"
|
else if (tag == "mathsf" || tag == "textit"
|
||||||
|| key_->name == "textsf")
|
|| tag == "textsf")
|
||||||
variant = "sans-serif";
|
variant = "sans-serif";
|
||||||
else if (key_->name == "mathtt" || key_->name == "texttt")
|
else if (tag == "mathtt" || tag == "texttt")
|
||||||
variant = "monospace";
|
variant = "monospace";
|
||||||
// no support at present for textipa, textsc, noun
|
// no support at present for textipa, textsc, noun
|
||||||
|
|
||||||
// FIXME We need some kind of "mode tracker", so we can
|
// FIXME We need some kind of "mode tracker", so we can
|
||||||
// just output verbatim text in some cases.
|
// just output verbatim text in some cases.
|
||||||
if (!variant.empty())
|
docstring const beg = (tag.size() < 4) ? from_ascii("") : tag.substr(0, 4);
|
||||||
os << "<mstyle mathvariant='" << from_utf8(variant) << "'>"
|
bool const textmode = (beg == "text");
|
||||||
<< cell(0) << "</mstyle>";
|
if (!variant.empty()) {
|
||||||
|
os << "<mstyle mathvariant='" << from_utf8(variant) << "'>";
|
||||||
|
SetMode sm(os, textmode);
|
||||||
|
os << cell(0);
|
||||||
|
os << "</mstyle>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user