[prev in list] [next in list] [prev in thread] [next in thread]
List: lyx-cvs
Subject: [LyX/master] Use symbols file to lookup entities for delimiters. Fixes bug #8280.
From: Richard Heck <rgheck () lyx ! org>
Date: 2016-06-30 2:40:30
Message-ID: 20160630024030.D3BB128025D () lyx ! lyx ! org
[Download RAW message or body]
commit 04b8f5cdc4b26105ea855fb9ec5b23227dfd55cb
Author: Richard Heck <rgheck@lyx.org>
Date: Wed Jun 29 22:39:42 2016 -0400
Use symbols file to lookup entities for delimiters. Fixes bug #8280.
Based upon work by Josh Hieronymus.
---
src/mathed/InsetMathBig.cpp | 90 +++--------------------------------------
src/mathed/InsetMathDelim.cpp | 13 +++++-
src/mathed/MathStream.cpp | 22 ++++++++++
src/mathed/MathStream.h | 3 +
4 files changed, 41 insertions(+), 87 deletions(-)
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index 969dd47..293ff8b 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 << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>";
- 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 << "</mo>";
+ os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>"
+ << convertDelimToXMLEscape(delim_)
+ << "</mo>";
}
@@ -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 b10d37a..68e4430 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 << "<mo form='prefix' fence='true' stretchy='true' symmetric='true'>" << left_ \
<< "</mo>"
- << cell(0) << "<mo form='postfix' fence='true' stretchy='true' symmetric='true'>" \
<< right_ << "</mo>"; + os << "<mo form='prefix' fence='true' stretchy='true' \
symmetric='true'>" + << convertDelimToXMLEscape(left_)
+ << "</mo>\n"
+ << cell(0)
+ << "\n<mo form='postfix' fence='true' stretchy='true' symmetric='true'>"
+ << convertDelimToXMLEscape(right_)
+ << "</mo>\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 78838cc..c1c0830 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 479e9d4..a9465cc 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic