diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index 969dd472c7..293ff8b80d 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -107,48 +107,9 @@ void InsetMathBig::normalize(NormalStream & os) const
void InsetMathBig::mathmlize(MathStream & os) const
{
- os << "";
- if (delim_ == "(" || delim_ == ")"
- || delim_ == "[" || delim_ == "]"
- || delim_ == "|" || delim_ == "/")
- os << delim_;
- else if (delim_ == "\\{" || delim_ == "\\lbrace")
- os << "{";
- else if (delim_ == "\\}" || delim_ == "\\rbrace")
- os << "}";
- else if (delim_ == "\\slash")
- os << "/";
- else if (delim_ == "\\|" || delim_ == "\\vert")
- os << "|";
- else if (delim_ == "\\Vert")
- os << "∥";
- else if (delim_ == "\\\\" || delim_ == "\\backslash")
- os <<" \\";
- else if (delim_ == "\\langle")
- os << "<";
- else if (delim_ == "\\rangle")
- os << ">";
- else if (delim_ == "\\lceil")
- os << "⌈";
- else if (delim_ == "\\rceil")
- os << "⌉";
- else if (delim_ == "\\lfloor")
- os << "⌊";
- else if (delim_ == "\\rfloor")
- os << "⌋";
- else if (delim_ == "\\downarrow")
- os << "↓";
- else if (delim_ == "\\uparrow")
- os << "↑";
- else if (delim_ == "\\Downarrow")
- os << "⇓";
- else if (delim_ == "\\Uparrow")
- os << "⇑";
- else if (delim_ == "\\updownarrow")
- os << "↕";
- else if (delim_ == "\\Updownarrow")
- os << "⇕";
- os << "";
+ os << ""
+ << convertDelimToXMLEscape(delim_)
+ << "";
}
@@ -161,48 +122,9 @@ void InsetMathBig::htmlize(HtmlStream & os) const
case 4: case 5: name = "biggg"; break;
default: name = "big"; break;
}
- os << MTag("span", "class='" + name + "symbol'");
- if (delim_ == "(" || delim_ == ")"
- || delim_ == "[" || delim_ == "]"
- || delim_ == "|" || delim_ == "/")
- os << delim_;
- else if (delim_ == "\\{" || delim_ == "\\lbrace")
- os << "{";
- else if (delim_ == "\\}" || delim_ == "\\rbrace")
- os << "}";
- else if (delim_ == "\\slash")
- os << "/";
- else if (delim_ == "\\|" || delim_ == "\\vert")
- os << "|";
- else if (delim_ == "\\Vert")
- os << "∥";
- else if (delim_ == "\\\\" || delim_ == "\\backslash")
- os <<" \\";
- else if (delim_ == "\\langle")
- os << "<";
- else if (delim_ == "\\rangle")
- os << ">";
- else if (delim_ == "\\lceil")
- os << "⌈";
- else if (delim_ == "\\rceil")
- os << "⌉";
- else if (delim_ == "\\lfloor")
- os << "⌊";
- else if (delim_ == "\\rfloor")
- os << "⌋";
- else if (delim_ == "\\downarrow")
- os << "↓";
- else if (delim_ == "\\uparrow")
- os << "↑";
- else if (delim_ == "\\Downarrow")
- os << "⇓";
- else if (delim_ == "\\Uparrow")
- os << "⇑";
- else if (delim_ == "\\updownarrow")
- os << "↕";
- else if (delim_ == "\\Updownarrow")
- os << "⇕";
- os << ETag("span");
+ os << MTag("span", "class='" + name + "symbol'")
+ << convertDelimToXMLEscape(delim_)
+ << ETag("span");
}
diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp
index b10d37ad69..68e4430514 100644
--- a/src/mathed/InsetMathDelim.cpp
+++ b/src/mathed/InsetMathDelim.cpp
@@ -193,14 +193,21 @@ void InsetMathDelim::mathematica(MathematicaStream & os) const
void InsetMathDelim::mathmlize(MathStream & os) const
{
- os << "" << left_ << ""
- << cell(0) << "" << right_ << "";
+ os << ""
+ << convertDelimToXMLEscape(left_)
+ << "\n"
+ << cell(0)
+ << "\n"
+ << convertDelimToXMLEscape(right_)
+ << "\n";
}
void InsetMathDelim::htmlize(HtmlStream & os) const
{
- os << left_ << cell(0) << right_;
+ os << convertDelimToXMLEscape(left_)
+ << cell(0)
+ << convertDelimToXMLEscape(right_);
}
diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 78838ccd0a..c1c0830f5a 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -12,6 +12,7 @@
#include "MathStream.h"
+#include "MathFactory.h"
#include "MathData.h"
#include "MathExtern.h"
@@ -694,4 +695,25 @@ OctaveStream & operator<<(OctaveStream & os, string const & s)
}
+docstring convertDelimToXMLEscape(docstring const & name)
+{
+ if (name.size() == 1) {
+ char_type const c = name[0];
+ if (c == '<')
+ return from_ascii("<");
+ else if (c == '>')
+ return from_ascii(">");
+ else
+ return name;
+ }
+ MathWordList const & words = mathedWordList();
+ MathWordList::const_iterator it = words.find(name);
+ if (it != words.end()) {
+ docstring const escape = it->second.xmlname;
+ return escape;
+ }
+ LYXERR0("Unable to find `" << name <<"' in the mathWordList.");
+ return name;
+}
+
} // namespace lyx
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 479e9d459e..a9465cc494 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -584,6 +584,9 @@ OctaveStream & operator<<(OctaveStream &, char);
///
OctaveStream & operator<<(OctaveStream &, int);
+
+docstring convertDelimToXMLEscape(docstring const & name);
+
} // namespace lyx
#endif