LyXHTML: switch the doctype to (X)HTML5 and only output XML entities.

This is a new take on c8e2c17a that was reverted at da67bde61a due to entities no more recognised by the browsers. Corresponding thread on the mailing list: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg213179.html

This patch is a huge cleanup overall, by removing the distinction between HTML and XML entities (the latter arrived due to the DocBook support).

In InsetListingParams, I also changed the mechanism that relied on " to use an XML entity to be consistent with the rest of the code, mostly in case someone looks for HTML entities and wonders why they are still there.
This commit is contained in:
Thibaut Cuvelier 2022-12-23 02:16:08 +01:00
parent d85969b8b8
commit bc73a85778
31 changed files with 171 additions and 393 deletions

View File

@ -64,11 +64,15 @@
* Documents that use TeX fonts can only be compiled with XeTeX if the input * Documents that use TeX fonts can only be compiled with XeTeX if the input
encoding is set to "utf8-plain" or "ascii". encoding is set to "utf8-plain" or "ascii".
* With LyXHTML output, there are now different CSS classees generated for * With LyXHTML output, there are now different CSS classes generated for
different depths: enumi, enumii, enumiii, and enumiv, and similarly for different depths: enumi, enumii, enumiii, and enumiv, and similarly for
itemize: lyxitemi, etc. There is also a new HTMLClass tag, which makes it itemize: lyxitemi, etc. There is also a new HTMLClass tag, which makes it
easier to provide specific classes for paragraphs. easier to provide specific classes for paragraphs.
* HTML support has been updated to output XHTML5 files. A major change is the
use of XML entities instead of HTML ones (e.g., LyX now outputs -
instead of ").
* DocBook support has been revamped and now targets DocBook 5 (i.e. * DocBook support has been revamped and now targets DocBook 5 (i.e.
only XML, SGML is gone). Some supporting files for the previous only XML, SGML is gone). Some supporting files for the previous
implementation have been removed: all examples (lib/examples), implementation have been removed: all examples (lib/examples),

View File

@ -2173,14 +2173,14 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
} }
// Directly output the root tag, based on the current type of document. // Directly output the root tag, based on the current type of document.
string params = "xml:lang=\"" + params().language->code() + '"' string attributes = "xml:lang=\"" + params().language->code() + '"'
+ " xmlns=\"http://docbook.org/ns/docbook\"" + " xmlns=\"http://docbook.org/ns/docbook\""
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ mathmlNamespace + mathmlNamespace
+ " xmlns:xi=\"http://www.w3.org/2001/XInclude\"" + " xmlns:xi=\"http://www.w3.org/2001/XInclude\""
+ " version=\"5.2\""; + " version=\"5.2\"";
os << "<" << from_ascii(tclass.docbookroot()) << " " << from_ascii(params) << ">\n"; os << "<" << from_ascii(tclass.docbookroot()) << " " << from_ascii(attributes) << ">\n";
} }
if (output_body) { if (output_body) {
@ -2238,11 +2238,11 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
output == FullSource || output == OnlyBody || output == IncludedFile; output == FullSource || output == OnlyBody || output == IncludedFile;
if (output_preamble) { if (output_preamble) {
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" os << "<!DOCTYPE html>\n"
<< "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\">\n"
<< "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" << from_ascii(params().language->code()) << "\">\n" << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" << from_ascii(params().language->code()) << "\">\n"
<< "<head>\n" << "<head>\n"
<< "<meta name=\"GENERATOR\" content=\"" << PACKAGE_STRING << "\" />\n" << "<meta name=\"GENERATOR\" content=\"" << PACKAGE_STRING << "\" />\n"
<< "<meta charset=\"UTF-8\" />\n"
// FIXME Presumably need to set this right // FIXME Presumably need to set this right
<< "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n"; << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n";

View File

@ -2164,37 +2164,6 @@ docstring const LaTeXFeatures::getTClassI18nPreamble(bool use_babel,
} }
docstring const LaTeXFeatures::getLyXSGMLEntities() const
{
// Definition of entities used in the document that are LyX related.
odocstringstream entities;
if (mustProvide("lyxarrow")) {
entities << "<!ENTITY lyxarrow \"-&gt;\">" << '\n';
}
return entities.str();
}
docstring const LaTeXFeatures::getIncludedFiles(string const & fname) const
{
odocstringstream sgmlpreamble;
// FIXME UNICODE
docstring const basename(from_utf8(onlyPath(fname)));
FileMap::const_iterator end = IncludedFiles_.end();
for (FileMap::const_iterator fi = IncludedFiles_.begin();
fi != end; ++fi)
// FIXME UNICODE
sgmlpreamble << "\n<!ENTITY " << fi->first
<< (isSGMLFileName(fi->second) ? " SYSTEM \"" : " \"")
<< makeRelPath(from_utf8(fi->second), basename) << "\">";
return sgmlpreamble.str();
}
void LaTeXFeatures::showStruct() const void LaTeXFeatures::showStruct() const
{ {
lyxerr << "LyX needs the following commands when LaTeXing:" lyxerr << "LyX needs the following commands when LaTeXing:"

View File

@ -79,10 +79,6 @@ public:
docstring const getTClassHTMLStyles() const; docstring const getTClassHTMLStyles() const;
/// ///
docstring const getTClassHTMLPreamble() const; docstring const getTClassHTMLPreamble() const;
/// The sgml definitions needed by the document (docbook)
docstring const getLyXSGMLEntities() const;
/// The SGML Required to include the files added with includeFile();
docstring const getIncludedFiles(std::string const & fname) const;
/// Include a file for use with the SGML entities /// Include a file for use with the SGML entities
void includeFile(docstring const & key, std::string const & name); void includeFile(docstring const & key, std::string const & name);
/// The float definitions. /// The float definitions.

View File

@ -515,7 +515,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
case LT_LATEXPARAM: case LT_LATEXPARAM:
lex >> latexparam_; lex >> latexparam_;
latexparam_ = subst(latexparam_, "&quot;", "\""); latexparam_ = subst(latexparam_, "&#34;", "\"");
break; break;
case LT_LEFTDELIM: case LT_LEFTDELIM:
@ -1455,7 +1455,7 @@ void Layout::write(ostream & os) const
if (!latexname_.empty()) if (!latexname_.empty())
os << "\tLatexName \"" << latexname_ << "\"\n"; os << "\tLatexName \"" << latexname_ << "\"\n";
if (!latexparam_.empty()) if (!latexparam_.empty())
os << "\tLatexParam \"" << subst(latexparam_, "\"", "&quot;") os << "\tLatexParam \"" << subst(latexparam_, "\"", "&#34;")
<< "\"\n"; << "\"\n";
if (!leftdelim_.empty()) if (!leftdelim_.empty())
os << "\tLeftDelim " os << "\tLeftDelim "

View File

@ -4046,7 +4046,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
char_type c = getUChar(buf.masterBuffer()->params(), char_type c = getUChar(buf.masterBuffer()->params(),
runparams, i); runparams, i);
if (c == ' ' && (style.free_spacing || runparams.free_spacing)) if (c == ' ' && (style.free_spacing || runparams.free_spacing))
xs << XMLStream::ESCAPE_NONE << "&nbsp;"; xs << XMLStream::ESCAPE_NONE << "&#160;";
else if (c == '\'') else if (c == '\'')
xs << XMLStream::ESCAPE_NONE << "&#8217;"; xs << XMLStream::ESCAPE_NONE << "&#8217;";
else else

View File

@ -312,7 +312,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
break; break;
case IL_LATEXPARAM: case IL_LATEXPARAM:
lex >> tmp; lex >> tmp;
latexparam_ = subst(tmp, "&quot;", "\""); latexparam_ = subst(tmp, "&#34;", "\"");
break; break;
case IL_LEFTDELIM: case IL_LEFTDELIM:
lex >> leftdelim_; lex >> leftdelim_;

View File

@ -1139,10 +1139,10 @@ string InsetListingsParams::encodedString() const
// '"' is handled differently because it will // '"' is handled differently because it will
// terminate a lyx token. // terminate a lyx token.
string par = params(); string par = params();
// '"' is now &quot; ==> '"' is now &amp;quot; // '"' is now &#34; ==> '"' is now &amp;#34;
par = subst(par, "&", "&amp;"); par = subst(par, "&", "&amp;");
// '"' is now &amp;quot; ==> '&quot;' is now &amp;quot; // '"' is now &amp;#34; ==> '&#34;' is now &amp;#34;
par = subst(par, "\"", "&quot;"); par = subst(par, "\"", "&#34;");
return par; return par;
} }
@ -1160,9 +1160,9 @@ void InsetListingsParams::fromEncodedString(string const & in)
{ {
// Decode string! Reversal of encodedString // Decode string! Reversal of encodedString
string par = in; string par = in;
// '&quot;' is now &amp;quot; ==> '"' is now &amp;quot; // '&#34;' is now &amp;#34; ==> '"' is now &amp;#34;
par = subst(par, "&quot;", "\""); par = subst(par, "&#34;", "\"");
// '"' is now &amp;quot; ==> '"' is now &quot; // '"' is now &amp;#34; ==> '"' is now &#34;
par = subst(par, "&amp;", "&"); par = subst(par, "&amp;", "&");
setParams(par); setParams(par);
} }

View File

@ -470,79 +470,6 @@ docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
} }
docstring InsetQuotesParams::getHTMLQuote(char_type c) const
{
string res;
switch (c){
case 0x201a: // ,
res = "&sbquo;";
break;
case 0x2019: // '
res = "&rsquo;";
break;
case 0x2018: // `
res = "&lsquo;";
break;
case 0x2039: // <
res = "&lsaquo;";
break;
case 0x203a: // >
res = "&rsaquo;";
break;
case 0x0027: // ' (plain)
res = "&#x27;";
break;
case 0x201e: // ,,
res = "&bdquo;";
break;
case 0x201d: // ''
res = "&rdquo;";
break;
case 0x201c: // ``
res = "&ldquo;";
break;
case 0x00ab: // <<
res = "&laquo;";
break;
case 0x00bb: // >>
res = "&raquo;";
break;
case 0x0022: // "
res = "&quot;";
break;
case 0x300c: // LEFT CORNER BRACKET
res = "&#x300c;";
break;
case 0x300d: // RIGHT CORNER BRACKET
res = "&#x300d;";
break;
case 0x300e: // LEFT WHITE CORNER BRACKET
res = "&#x300e;";
break;
case 0x300f: // RIGHT WHITE CORNER BRACKET
res = "&#x300f;";
break;
case 0x300a: // LEFT DOUBLE ANGLE BRACKET
res = "&#x300a;";
break;
case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
res = "&#x300b;";
break;
case 0x3008: // LEFT ANGLE BRACKET
res = "&#x3008;";
break;
case 0x3009: // RIGHT ANGLE BRACKET
res = "&#x3009;";
break;
default:
break;
}
return from_ascii(res);
}
docstring InsetQuotesParams::getXMLQuote(char_type c) const docstring InsetQuotesParams::getXMLQuote(char_type c) const
{ {
// Directly output the character Unicode form. // Directly output the character Unicode form.
@ -959,11 +886,10 @@ int InsetQuotes::plaintext(odocstringstream & os,
} }
docstring InsetQuotes::getQuoteEntity(bool isHTML) const { docstring InsetQuotes::getQuoteXMLEntity() const {
QuoteStyle style = QuoteStyle style =
(style_ == QuoteStyle::Dynamic) ? global_style_ : style_; (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) : docstring res = quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
// in French, thin spaces are added inside double guillemets // in French, thin spaces are added inside double guillemets
if (prefixIs(context_lang_, "fr") if (prefixIs(context_lang_, "fr")
@ -984,13 +910,13 @@ docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const
{ {
xs << XMLStream::ESCAPE_NONE << getQuoteEntity(false); xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity();
} }
docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true); xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity();
return docstring(); return docstring();
} }

View File

@ -87,8 +87,6 @@ public:
docstring getLaTeXQuote(char_type c, std::string const &, docstring getLaTeXQuote(char_type c, std::string const &,
bool const rtl = false) const; bool const rtl = false) const;
/// ///
docstring getHTMLQuote(char_type c) const;
///
docstring getXMLQuote(char_type c) const; docstring getXMLQuote(char_type c) const;
/// Returns a descriptive label of a style suitable for dialog and menu /// Returns a descriptive label of a style suitable for dialog and menu
docstring const getGuiLabel(QuoteStyle const & qs, docstring const getGuiLabel(QuoteStyle const & qs,
@ -188,7 +186,7 @@ private:
/// ///
docstring displayString() const; docstring displayString() const;
/// ///
docstring getQuoteEntity(bool isHTML) const; docstring getQuoteXMLEntity() const;
/// ///
QuoteStyle getStyle(std::string const &); QuoteStyle getStyle(std::string const &);

View File

@ -860,9 +860,9 @@ docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
case InsetSpaceParams::NEGTHIN: case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM: case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK: case InsetSpaceParams::NEGTHICK:
output ="&nbsp;"; output ="&#160;";
break; break;
// no XHTML entity, only unicode code for space character exists // no XML entity, only Unicode code for space character exists
case InsetSpaceParams::VISIBLE: case InsetSpaceParams::VISIBLE:
output ="&#x2423;"; output ="&#x2423;";
break; break;
@ -884,7 +884,7 @@ docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
case InsetSpaceParams::CUSTOM_PROTECTED: case InsetSpaceParams::CUSTOM_PROTECTED:
// FIXME XHTML // FIXME XHTML
// Probably we could do some sort of blank span? // Probably we could do some sort of blank span?
output ="&nbsp;"; output ="&#160;";
break; break;
} }
// don't escape the entities! // don't escape the entities!

View File

@ -530,96 +530,55 @@ int InsetSpecialChar::plaintext(odocstringstream & os,
} }
namespace {
string specialCharKindToXMLEntity(InsetSpecialChar::Kind kind) {
switch (kind) {
case InsetSpecialChar::Kind::HYPHENATION:
// Soft hyphen.
return "&#xAD;";
case InsetSpecialChar::Kind::ALLOWBREAK:
// Zero-width space
return "&#x200B;";
case InsetSpecialChar::Kind::LIGATURE_BREAK:
// Zero width non-joiner
return "&#x200C;";
case InsetSpecialChar::Kind::END_OF_SENTENCE:
return ".";
case InsetSpecialChar::Kind::LDOTS:
// &hellip;
return "&#x2026;";
case InsetSpecialChar::Kind::MENU_SEPARATOR:
// &rArr;, right arrow.
return "&#x21D2;";
case InsetSpecialChar::Kind::SLASH:
// &frasl;, fractional slash.
return "&#x2044;";
case InsetSpecialChar::Kind::NOBREAKDASH:
// Non-breaking hyphen.
return "&#x2011;";
case InsetSpecialChar::Kind::PHRASE_LYX:
return "LyX";
case InsetSpecialChar::Kind::PHRASE_TEX:
return "TeX";
case InsetSpecialChar::Kind::PHRASE_LATEX2E:
// Lower-case epsilon.
return "LaTeX2&#x03b5;";
case InsetSpecialChar::Kind::PHRASE_LATEX:
return "LaTeX";
}
}
}
void InsetSpecialChar::docbook(XMLStream & xs, OutputParams const &) const void InsetSpecialChar::docbook(XMLStream & xs, OutputParams const &) const
{ {
switch (kind_) { xs << XMLStream::ESCAPE_NONE << from_ascii(specialCharKindToXMLEntity(kind_));
case HYPHENATION:
// Soft hyphen.
xs << XMLStream::ESCAPE_NONE << "&#xAD;";
break;
case ALLOWBREAK:
// Zero-width space
xs << XMLStream::ESCAPE_NONE << "&#x200B;";
break;
case LIGATURE_BREAK:
// Zero width non-joiner
xs << XMLStream::ESCAPE_NONE << "&#x200C;";
break;
case END_OF_SENTENCE:
xs << '.';
break;
case LDOTS:
// &hellip;
xs << XMLStream::ESCAPE_NONE << "&#x2026;";
break;
case MENU_SEPARATOR:
// &rArr;, right arrow.
xs << XMLStream::ESCAPE_NONE << "&#x21D2;";
break;
case SLASH:
// &frasl;, fractional slash.
xs << XMLStream::ESCAPE_NONE << "&#x2044;";
break;
// Non-breaking hyphen.
case NOBREAKDASH:
xs << XMLStream::ESCAPE_NONE << "&#x2011;";
break;
case PHRASE_LYX:
xs << "LyX";
break;
case PHRASE_TEX:
xs << "TeX";
break;
case PHRASE_LATEX2E:
// Lower-case epsilon.
xs << "LaTeX2" << XMLStream::ESCAPE_NONE << "&#x03b5;";
break;
case PHRASE_LATEX:
xs << "LaTeX";
break;
}
} }
docstring InsetSpecialChar::xhtml(XMLStream & xs, OutputParams const &) const docstring InsetSpecialChar::xhtml(XMLStream & xs, OutputParams const &) const
{ {
switch (kind_) { xs << XMLStream::ESCAPE_NONE << from_ascii(specialCharKindToXMLEntity(kind_));
case HYPHENATION:
break;
case ALLOWBREAK:
xs << XMLStream::ESCAPE_NONE << "&#8203;";
break;
case LIGATURE_BREAK:
xs << XMLStream::ESCAPE_NONE << "&#8204;";
break;
case END_OF_SENTENCE:
xs << '.';
break;
case LDOTS:
xs << XMLStream::ESCAPE_NONE << "&hellip;";
break;
case MENU_SEPARATOR:
xs << XMLStream::ESCAPE_NONE << "&rArr;";
break;
case SLASH:
xs << XMLStream::ESCAPE_NONE << "&frasl;";
break;
case NOBREAKDASH:
xs << XMLStream::ESCAPE_NONE << "&#8209;";
break;
case PHRASE_LYX:
xs << "LyX";
break;
case PHRASE_TEX:
xs << "TeX";
break;
case PHRASE_LATEX2E:
xs << "LaTeX2" << XMLStream::ESCAPE_NONE << "&#x3b5;";
break;
case PHRASE_LATEX:
xs << "LaTeX";
break;
}
return docstring(); return docstring();
} }
@ -636,7 +595,7 @@ void InsetSpecialChar::toString(odocstream & os) const
break; break;
} }
odocstringstream ods; odocstringstream ods;
plaintext(ods, OutputParams(0)); plaintext(ods, OutputParams(nullptr));
os << ods.str(); os << ods.str();
} }
@ -645,7 +604,7 @@ void InsetSpecialChar::forOutliner(docstring & os, size_t const,
bool const) const bool const) const
{ {
odocstringstream ods; odocstringstream ods;
plaintext(ods, OutputParams(0)); plaintext(ods, OutputParams(nullptr));
os += ods.str(); os += ods.str();
} }

View File

@ -138,7 +138,7 @@ void InsetMathBig::normalize(NormalStream & os) const
void InsetMathBig::mathmlize(MathMLStream & ms) const void InsetMathBig::mathmlize(MathMLStream & ms) const
{ {
ms << MTagInline("mo", "fence='true' stretchy='true' symmetric='true'") ms << MTagInline("mo", "fence='true' stretchy='true' symmetric='true'")
<< convertDelimToXMLEscape(delim_, ms.xmlMode()) << convertDelimToXMLEscape(delim_)
<< ETagInline("mo"); << ETagInline("mo");
} }
@ -153,7 +153,7 @@ void InsetMathBig::htmlize(HtmlStream & os) const
default: name = "big"; break; default: name = "big"; break;
} }
os << MTag("span", "class='" + name + "symbol'") os << MTag("span", "class='" + name + "symbol'")
<< convertDelimToXMLEscape(delim_, false) << convertDelimToXMLEscape(delim_)
<< ETag("span"); << ETag("span");
} }

View File

@ -234,10 +234,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
case '>': entity = "&gt;"; break; case '>': entity = "&gt;"; break;
case '&': entity = "&amp;"; break; case '&': entity = "&amp;"; break;
case ' ': { case ' ': {
if (ms.xmlMode()) ms << from_ascii("&#0160;");
ms << from_ascii("&#0160;");
else
ms << from_ascii("&nbsp;");
return; return;
} }
default: break; default: break;
@ -278,7 +275,7 @@ void InsetMathChar::htmlize(HtmlStream & ms) const
case '<': entity = "&lt;"; break; case '<': entity = "&lt;"; break;
case '>': entity = "&gt;"; break; case '>': entity = "&gt;"; break;
case '&': entity = "&amp;"; break; case '&': entity = "&amp;"; break;
case ' ': entity = "&nbsp;"; break; case ' ': entity = "&#160;"; break;
default: break; default: break;
} }

View File

@ -188,10 +188,9 @@ void InsetMathDecoration::infoize(odocstream & os) const
namespace { namespace {
struct Attributes { struct Attributes {
Attributes() : over(false) {} Attributes() : over(false) {}
Attributes(bool o, string const & t, string const & entity) Attributes(bool o, string_view entity)
: over(o), tag(t), entity(entity) {} : over(o), entity(entity) {}
bool over; bool over;
string tag;
string entity; string entity;
}; };
@ -199,35 +198,35 @@ namespace {
void buildTranslationMap(TranslationMap & t) { void buildTranslationMap(TranslationMap & t) {
// the decorations we need to support are listed in lib/symbols // the decorations we need to support are listed in lib/symbols
t["acute"] = Attributes(true, "&acute;", "&#x00B4;"); t["acute"] = Attributes(true, "&#x00B4;");
t["bar"] = Attributes(true, "&OverBar;", "&#x00AF;"); t["bar"] = Attributes(true, "&#x00AF;");
t["breve"] = Attributes(true, "&breve;", "&#x02D8;"); t["breve"] = Attributes(true, "&#x02D8;");
t["check"] = Attributes(true, "&caron;", "&#x02C7;"); t["check"] = Attributes(true, "&#x02C7;");
t["ddddot"] = Attributes(true, "&DotDot;", "&#x20DC;"); t["ddddot"] = Attributes(true, "&#x20DC;");
t["dddot"] = Attributes(true, "&TripleDot;", "&#x20DB;"); t["dddot"] = Attributes(true, "&#x20DB;");
t["ddot"] = Attributes(true, "&Dot;", "&#x00A8;"); t["ddot"] = Attributes(true, "&#x00A8;");
t["dot"] = Attributes(true, "&dot;", "&#x02D9;"); t["dot"] = Attributes(true, "&#x02D9;");
t["grave"] = Attributes(true, "&grave;", "&#x0060;"); t["grave"] = Attributes(true, "&#x0060;");
t["hat"] = Attributes(true, "&circ;", "&#x02C6;"); t["hat"] = Attributes(true, "&#x02C6;");
t["mathring"] = Attributes(true, "&ring;", "&#x02DA;"); t["mathring"] = Attributes(true, "&#x02DA;");
t["overbrace"] = Attributes(true, "&OverBrace;", "&#x23DE;"); t["overbrace"] = Attributes(true, "&#x23DE;");
t["overleftarrow"] = Attributes(true, "&xlarr;", "&#x27F5;"); t["overleftarrow"] = Attributes(true, "&#x27F5;");
t["overleftrightarrow"] = Attributes(true, "&xharr;", "&#x27F7;"); t["overleftrightarrow"] = Attributes(true, "&#x27F7;");
t["overline"] = Attributes(true, "&macr;", "&#x00AF;"); t["overline"] = Attributes(true, "&#x00AF;");
t["overrightarrow"] = Attributes(true, "&xrarr;", "&#x27F6;"); t["overrightarrow"] = Attributes(true, "&#x27F6;");
t["tilde"] = Attributes(true, "&tilde;", "&#x02DC;"); t["tilde"] = Attributes(true, "&#x02DC;");
t["underbar"] = Attributes(false, "&UnderBar;", "&#x0332;"); t["underbar"] = Attributes(false, "&#x0332;");
t["underbrace"] = Attributes(false, "&UnderBrace;", "&#x23DF;"); t["underbrace"] = Attributes(false, "&#x23DF;");
t["underleftarrow"] = Attributes(false, "&xlarr;", "&#x27F5;"); t["underleftarrow"] = Attributes(false, "&#x27F5;");
t["underleftrightarrow"] = Attributes(false, "&xharr;", "&#x27F7;"); t["underleftrightarrow"] = Attributes(false, "&#x27F7;");
// this is the macron, again, but it works // this is the macron, again, but it works
t["underline"] = Attributes(false, "&macr;", "&#x00AF;"); t["underline"] = Attributes(false, "&#x00AF;");
t["underrightarrow"] = Attributes(false, "&xrarr;", "&#x27F6;"); t["underrightarrow"] = Attributes(false, "&#x27F6;");
t["undertilde"] = Attributes(false, "&Tilde;", "&#x223C;"); t["undertilde"] = Attributes(false, "&#x223C;");
t["utilde"] = Attributes(false, "&Tilde;", "&#x223C;"); t["utilde"] = Attributes(false, "&#x223C;");
t["vec"] = Attributes(true, "&rarr;", "&#x2192;"); t["vec"] = Attributes(true, "&#x2192;");
t["widehat"] = Attributes(true, "&Hat;", "&#x005E;"); t["widehat"] = Attributes(true, "&#x005E;");
t["widetilde"] = Attributes(true, "&Tilde;", "&#x223C;"); t["widetilde"] = Attributes(true, "&#x223C;");
} }
TranslationMap const & translationMap() { TranslationMap const & translationMap() {
@ -244,7 +243,7 @@ void InsetMathDecoration::mathmlize(MathMLStream & ms) const
TranslationMap::const_iterator cur = t.find(to_utf8(key_->name)); TranslationMap::const_iterator cur = t.find(to_utf8(key_->name));
LASSERT(cur != t.end(), return); LASSERT(cur != t.end(), return);
char const * const outag = cur->second.over ? "mover" : "munder"; char const * const outag = cur->second.over ? "mover" : "munder";
std::string decoration = ms.xmlMode() ? cur->second.entity : cur->second.tag; std::string decoration = cur->second.entity;
ms << MTag(outag) ms << MTag(outag)
<< cell(0) << cell(0)
<< "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">" << "<" << from_ascii(ms.namespacedTag("mo")) << " stretchy=\"true\">"
@ -277,14 +276,14 @@ void InsetMathDecoration::htmlize(HtmlStream & os) const
<< '\n'; << '\n';
if (symontop) if (symontop)
os << MTag("span", "class='symbol'") << from_ascii(cur->second.tag); os << MTag("span", "class='symbol'") << from_ascii(cur->second.entity);
else else
os << MTag("span", "class='base'") << cell(0); os << MTag("span", "class='base'") << cell(0);
os << ETag("span") << '\n'; os << ETag("span") << '\n';
if (symontop) if (symontop)
os << MTag("span", "class='base'") << cell(0); os << MTag("span", "class='base'") << cell(0);
else else
os << MTag("span", "class='symbol'") << from_ascii(cur->second.tag); os << MTag("span", "class='symbol'") << from_ascii(cur->second.entity);
os << ETag("span") << '\n' << ETag("span") << '\n'; os << ETag("span") << '\n' << ETag("span") << '\n';
} }

View File

@ -183,11 +183,11 @@ void InsetMathDelim::mathmlize(MathMLStream & ms) const
{ {
ms << MTag("mrow") ms << MTag("mrow")
<< MTagInline("mo", "form='prefix' fence='true' stretchy='true' symmetric='true'") << MTagInline("mo", "form='prefix' fence='true' stretchy='true' symmetric='true'")
<< convertDelimToXMLEscape(left_, ms.xmlMode()) << convertDelimToXMLEscape(left_)
<< ETagInline("mo") << ETagInline("mo")
<< cell(0) << cell(0)
<< MTagInline("mo", "form='postfix' fence='true' stretchy='true' symmetric='true'") << MTagInline("mo", "form='postfix' fence='true' stretchy='true' symmetric='true'")
<< convertDelimToXMLEscape(right_, ms.xmlMode()) << convertDelimToXMLEscape(right_)
<< ETagInline("mo") << ETagInline("mo")
<< ETag("mrow"); << ETag("mrow");
} }
@ -195,9 +195,9 @@ void InsetMathDelim::mathmlize(MathMLStream & ms) const
void InsetMathDelim::htmlize(HtmlStream & os) const void InsetMathDelim::htmlize(HtmlStream & os) const
{ {
os << convertDelimToXMLEscape(left_, false) os << convertDelimToXMLEscape(left_)
<< cell(0) << cell(0)
<< convertDelimToXMLEscape(right_, false); << convertDelimToXMLEscape(right_);
} }

View File

@ -74,60 +74,34 @@ void InsetMathDots::validate(LaTeXFeatures & features) const
} }
void InsetMathDots::mathmlize(MathMLStream & ms) const namespace {
{ std::string symbolToXMLEntity(docstring const & n) {
// which symbols we support is decided by what is listed in // which symbols we support is decided by what is listed in
// lib/symbols as generating a dots inset // lib/symbols as generating a dots inset
docstring const & n = key_->name; if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
std::string ent; return "&#x2026;";
if (ms.xmlMode()) { else if (n == "adots" || n == "iddots")
if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots") return "&#x22F0;";
ent = "&#x2026;"; else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
else if (n == "adots" || n == "iddots") return "&#x22EF;";
ent = "&#x22F0;"; else if (n == "ddots")
else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm") return "&#x22F1;";
ent = "&#x22EF;"; else if (n == "vdots")
else if (n == "ddots") return "&#x22EE;";
ent = "&#x22F1;"; else LASSERT(false, return "&#x2026;");
else if (n == "vdots") }
ent = "&#x22EE;"; }
else LASSERT(false, ent = "&#x2026;");
} else {
if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots") void InsetMathDots::mathmlize(MathMLStream & ms) const
ent = "&hellip;"; {
else if (n == "adots" || n == "iddots") ms << MTagInline("mi") << from_ascii(symbolToXMLEntity(key_->name)) << ETagInline("mi");
ent = "&utdot;";
else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
ent = "&ctdot;";
else if (n == "ddots")
ent = "&dtdot;";
else if (n == "vdots")
ent = "&vellip;";
else LASSERT(false, ent = "&hellip;");
}
ms << MTagInline("mi") << from_ascii(ent) << ETagInline("mi");
} }
void InsetMathDots::htmlize(HtmlStream & os) const void InsetMathDots::htmlize(HtmlStream & os) const
{ {
// which symbols we support is decided by what is listed in os << from_ascii(symbolToXMLEntity(key_->name));
// lib/symbols as generating a dots inset
docstring const & n = key_->name;
std::string ent;
if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
ent = "&#x02026;";
else if (n == "adots" || n == "iddots")
ent = "&#x022F0;";
else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
ent = "&#x022EF;";
else if (n == "ddots")
ent = "&#x022F1;";
else if (n == "vdots")
ent = "&#x022EE;";
else
LASSERT(false, ent = "#x02026;");
os << from_ascii(ent);
} }
} // namespace lyx } // namespace lyx

View File

@ -2419,7 +2419,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
} }
odocstringstream osmath; odocstringstream osmath;
MathMLStream ms(osmath, mathmlNamespacePrefix, true); MathMLStream ms(osmath, mathmlNamespacePrefix);
// Output the MathML subtree. // Output the MathML subtree.
// TeX transcription. Avoid MTag/ETag so that there are no extraneous spaces. // TeX transcription. Avoid MTag/ETag so that there are no extraneous spaces.
@ -2442,7 +2442,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
// First, generate the MathML expression. If there is an error in the generation, this block is not fully // First, generate the MathML expression. If there is an error in the generation, this block is not fully
// executed, and the formula is not output to the DocBook stream. // executed, and the formula is not output to the DocBook stream.
odocstringstream ostmp; odocstringstream ostmp;
MathMLStream mstmp(ostmp, ms.xmlns(), ms.xmlMode()); MathMLStream mstmp(ostmp, ms.xmlns());
mathmlize(mstmp); mathmlize(mstmp);
// Choose the display style for the formula, to be output as an attribute near the formula root. // Choose the display style for the formula, to be output as an attribute near the formula root.

View File

@ -1303,7 +1303,7 @@ void InsetMathMacro::mathmlize(MathMLStream & ms) const
// macro_ is 0 if this is an unknown macro // macro_ is 0 if this is an unknown macro
LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
if (d->macro_) { if (d->macro_) {
docstring const xmlname = (ms.xmlMode()) ? d->macro_->xmlname() : d->macro_->htmlname(); docstring const xmlname = d->macro_->xmlname();
if (!xmlname.empty()) { if (!xmlname.empty()) {
char const * type = d->macro_->MathMLtype(); char const * type = d->macro_->MathMLtype();
ms << "<" << from_ascii(ms.namespacedTag(type)) << ">" ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
@ -1325,7 +1325,7 @@ void InsetMathMacro::htmlize(HtmlStream & os) const
// macro_ is 0 if this is an unknown macro // macro_ is 0 if this is an unknown macro
LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
if (d->macro_) { if (d->macro_) {
docstring const xmlname = d->macro_->htmlname(); docstring const xmlname = d->macro_->xmlname();
if (!xmlname.empty()) { if (!xmlname.empty()) {
os << ' ' << xmlname << ' '; os << ' ' << xmlname << ' ';
return; return;

View File

@ -95,7 +95,7 @@ void InsetMathMatrix::mathematica(MathematicaStream & os) const
void InsetMathMatrix::mathmlize(MathMLStream & ms) const void InsetMathMatrix::mathmlize(MathMLStream & ms) const
{ {
ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>" ms << "<" << from_ascii(ms.namespacedTag("mo")) << " form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
<< convertDelimToXMLEscape(left_, ms.xmlMode()) << convertDelimToXMLEscape(left_)
<< "</" << from_ascii(ms.namespacedTag("mo")) << ">" << "</" << from_ascii(ms.namespacedTag("mo")) << ">"
<< MTag("mtable"); << MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) { for (row_type row = 0; row < nrows(); ++row) {
@ -114,7 +114,7 @@ void InsetMathMatrix::mathmlize(MathMLStream & ms) const
} }
ms << ETag("mtable") ms << ETag("mtable")
<< "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>" << "<" << from_ascii(ms.namespacedTag("mo")) << " form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
<< convertDelimToXMLEscape(right_, ms.xmlMode()) << convertDelimToXMLEscape(right_)
<< "</" << from_ascii(ms.namespacedTag("mo")) << ">"; << "</" << from_ascii(ms.namespacedTag("mo")) << ">";
} }

View File

@ -231,7 +231,7 @@ void InsetMathRoot::htmlize(HtmlStream & os) const
{ {
os << MTag("span", "class='root'") os << MTag("span", "class='root'")
<< MTag("sup") << cell(1) << ETag("sup") << MTag("sup") << cell(1) << ETag("sup")
<< from_ascii("&radic;") << from_ascii("&#8730;")
<< MTag("span", "class='rootof'") << cell(0) << ETag("span") << MTag("span", "class='rootof'") << cell(0) << ETag("span")
<< ETag("span"); << ETag("span");
} }

View File

@ -225,7 +225,7 @@ void InsetMathSpace::htmlize(HtmlStream & ms) const
ms << from_ascii("&thinsp;"); ms << from_ascii("&thinsp;");
break; break;
case InsetSpaceParams::MEDIUM: case InsetSpaceParams::MEDIUM:
ms << from_ascii("&nbsp;"); ms << from_ascii("&#160;");
break; break;
case InsetSpaceParams::THICK: case InsetSpaceParams::THICK:
ms << from_ascii("&emsp;"); ms << from_ascii("&emsp;");
@ -248,12 +248,12 @@ void InsetMathSpace::htmlize(HtmlStream & ms) const
case InsetSpaceParams::CUSTOM_PROTECTED: { case InsetSpaceParams::CUSTOM_PROTECTED: {
string l = length_.asHTMLString(); string l = length_.asHTMLString();
ms << MTag("span", "width='" + l + "'") ms << MTag("span", "width='" + l + "'")
<< from_ascii("&nbsp;") << ETag("span"); << from_ascii("&#160;") << ETag("span");
break; break;
} }
case InsetSpaceParams::NORMAL: case InsetSpaceParams::NORMAL:
case InsetSpaceParams::PROTECTED: case InsetSpaceParams::PROTECTED:
ms << from_ascii("&nbsp;"); ms << from_ascii("&#160;");
break; break;
default: default:
break; break;

View File

@ -107,7 +107,7 @@ void InsetMathSqrt::mathmlize(MathMLStream & ms) const
void InsetMathSqrt::htmlize(HtmlStream & os) const void InsetMathSqrt::htmlize(HtmlStream & os) const
{ {
os << MTag("span", "class='sqrt'") os << MTag("span", "class='sqrt'")
<< from_ascii("&radic;") << from_ascii("&#8730;")
<< MTag("span", "class='sqrtof'") << cell(0) << ETag("span") << MTag("span", "class='sqrtof'") << cell(0) << ETag("span")
<< ETag("span"); << ETag("span");
} }

View File

@ -162,13 +162,11 @@ void InsetMathSymbol::mathmlize(MathMLStream & ms) const
// with MathMLtype. // with MathMLtype.
docstring tag = from_ascii(ms.namespacedTag(sym_->MathMLtype())); docstring tag = from_ascii(ms.namespacedTag(sym_->MathMLtype()));
ms << '<' << tag << ">"; ms << '<' << tag << ">";
if ((ms.xmlMode() && sym_->xmlname == "x") || (!ms.xmlMode() && sym_->htmlname == "x")) if (sym_->xmlname == "x")
// unknown so far // unknown so far
ms << name(); ms << name();
else if (ms.xmlMode())
ms << sym_->xmlname;
else else
ms << sym_->htmlname; ms << sym_->xmlname;
ms << "</" << tag << '>'; ms << "</" << tag << '>';
} }
@ -180,13 +178,13 @@ void InsetMathSymbol::htmlize(HtmlStream & os, bool spacing) const
char const * type = sym_->MathMLtype(); char const * type = sym_->MathMLtype();
bool op = (std::string(type) == "mo"); bool op = (std::string(type) == "mo");
if (sym_->htmlname == "x") if (sym_->xmlname == "x")
// unknown so far // unknown so far
os << ' ' << name() << ' '; os << ' ' << name() << ' ';
else if (op && spacing) else if (op && spacing)
os << ' ' << sym_->htmlname << ' '; os << ' ' << sym_->xmlname << ' ';
else else
os << sym_->htmlname; os << sym_->xmlname;
} }

View File

@ -84,25 +84,6 @@ void InsetMathXArrow::normalize(NormalStream & os) const
} }
static std::map<string, string> latex_to_html_entities = {
{"xleftarrow", "&larr;"},
{"xrightarrow", "&rarr;"},
{"xhookleftarrow", "&larrhk;"},
{"xhookrightarrow", "&rarrhk;"},
{"xLeftarrow", "&lArr;"},
{"xRightarrow", "&rArr;"},
{"xleftrightarrow", "&leftrightarrow;"},
{"xLeftrightarrow", "&Leftrightarrow;"},
{"xleftharpoondown", "&leftharpoondown;"},
{"xleftharpoonup", "&leftharpoonup;"},
{"xleftrightharpoons", "&leftrightharpoons;"},
{"xrightharpoondown", "&rightharpoondown;"},
{"xrightharpoonup", "&rightharpoonup;"},
{"xrightleftharpoons", "&rightleftharpoons;"},
{"xmapsto", "&mapsto;"},
};
static std::map<string, string> latex_to_xml_entities = { static std::map<string, string> latex_to_xml_entities = {
{"xleftarrow", "&#x2190;"}, {"xleftarrow", "&#x2190;"},
{"xrightarrow", "&#x2192;"}, {"xrightarrow", "&#x2192;"},
@ -122,17 +103,14 @@ static std::map<string, string> latex_to_xml_entities = {
}; };
docstring map_latex_to(docstring latex, bool xml = false) docstring map_latex_to(docstring latex)
{ {
auto dict = (xml) ? latex_to_xml_entities : latex_to_html_entities; auto mapping = latex_to_xml_entities.find(to_ascii(latex));
if (mapping != latex_to_xml_entities.end()) {
auto mapping = dict.find(to_ascii(latex));
if (mapping != dict.end()) {
return from_ascii(mapping->second); return from_ascii(mapping->second);
} else { } else {
std::string format = (xml) ? "XML" : "HTML"; lyxerr << "mathmlize conversion for '" << latex << "' not implemented" << endl;
lyxerr << "mathmlize " << format << " conversion for '" << latex << "' not implemented" << endl; LASSERT(false, return from_ascii(latex_to_xml_entities["xrightarrow"]));
LASSERT(false, return from_ascii(dict["xrightarrow"]));
return docstring(); return docstring();
} }
} }
@ -140,7 +118,7 @@ docstring map_latex_to(docstring latex, bool xml = false)
void InsetMathXArrow::mathmlize(MathMLStream & ms) const void InsetMathXArrow::mathmlize(MathMLStream & ms) const
{ {
docstring arrow = map_latex_to(name_, ms.xmlMode()); docstring arrow = map_latex_to(name_);
ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>" ms << "<" << from_ascii(ms.namespacedTag("munderover")) << " accent='false' accentunder='false'>"
<< MTagInline("mo") << arrow << ETagInline("mo") << MTagInline("mo") << arrow << ETagInline("mo")
<< cell(1) << cell(0) << cell(1) << cell(0)

View File

@ -121,14 +121,6 @@ bool MacroData::hidden() const
} }
docstring const MacroData::htmlname() const
{
if (sym_)
return sym_->htmlname;
return docstring();
}
docstring const MacroData::xmlname() const docstring const MacroData::xmlname() const
{ {
if (sym_) if (sym_)

View File

@ -63,8 +63,6 @@ public:
/// ///
bool hidden() const; bool hidden() const;
/// ///
docstring const htmlname() const;
///
docstring const xmlname() const; docstring const xmlname() const;
/// ///
char const * MathMLtype() const; char const * MathMLtype() const;

View File

@ -188,11 +188,12 @@ void initSymbols()
// \def\macroname{definition} requires // \def\macroname{definition} requires
// or // or
// \def\macroname{definition} extra htmlname xmlname requires // \def\macroname{definition} extra htmlname xmlname requires
// TODO: remove htmlname
istringstream is(line); istringstream is(line);
string macro; string macro;
string required; string required;
string extra; string extra;
string htmlname; string htmlname; // Ignored. TODO: remove.
string xmlname; string xmlname;
bool hidden = false; bool hidden = false;
is >> setw(65536) >> macro >> required; is >> setw(65536) >> macro >> required;
@ -201,10 +202,10 @@ void initSymbols()
if (!(is >> required)) if (!(is >> required))
required = ""; required = "";
} else } else
htmlname = xmlname = ""; xmlname = "";
MacroTable::iterator it = MacroTable::globalMacros().insert( MacroTable::iterator it = MacroTable::globalMacros().insert(
nullptr, from_utf8(macro)); nullptr, from_utf8(macro));
if (!extra.empty() || !htmlname.empty() || !xmlname.empty() || !required.empty()) { if (!extra.empty() || !xmlname.empty() || !required.empty()) {
MathWordList::iterator wit = theMathWordList.find(it->first); MathWordList::iterator wit = theMathWordList.find(it->first);
if (wit != theMathWordList.end()) if (wit != theMathWordList.end())
LYXERR(Debug::MATHED, "readSymbols: inset " LYXERR(Debug::MATHED, "readSymbols: inset "
@ -214,7 +215,6 @@ void initSymbols()
tmp.inset = "macro"; tmp.inset = "macro";
tmp.name = it->first; tmp.name = it->first;
tmp.extra = from_utf8(extra); tmp.extra = from_utf8(extra);
tmp.htmlname = from_utf8(htmlname);
tmp.xmlname = from_utf8(xmlname); tmp.xmlname = from_utf8(xmlname);
if (required == "hiddensymbol") { if (required == "hiddensymbol") {
required = ""; required = "";
@ -232,7 +232,6 @@ void initSymbols()
<< " inset: macro" << " inset: macro"
<< " draw: 0" << " draw: 0"
<< " extra: " << extra << " extra: " << extra
<< " html: " << htmlname
<< " xml: " << xmlname << " xml: " << xmlname
<< " requires: " << required << " requires: " << required
<< " hidden: " << hidden << '\''); << " hidden: " << hidden << '\'');
@ -245,7 +244,7 @@ void initSymbols()
is >> tmp.name >> help; is >> tmp.name >> help;
tmp.inset = to_ascii(help); tmp.inset = to_ascii(help);
if (isFontName(tmp.inset)) { if (isFontName(tmp.inset)) {
is >> help >> fallbackid >> tmp.extra >> tmp.htmlname >> tmp.xmlname; is >> help >> fallbackid >> tmp.extra >> tmp.xmlname;
docstring cid, dsp_cid; docstring cid, dsp_cid;
idocstringstream is2(subst(help, '|', ' ')); idocstringstream is2(subst(help, '|', ' '));
is2 >> charid >> dsp_charid; is2 >> charid >> dsp_charid;
@ -338,7 +337,6 @@ void initSymbols()
<< " inset: " << tmp.inset << " inset: " << tmp.inset
<< " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0]) << " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0])
<< " extra: " << to_utf8(tmp.extra) << " extra: " << to_utf8(tmp.extra)
<< " html: " << to_utf8(tmp.htmlname)
<< " xml: " << to_utf8(tmp.xmlname) << " xml: " << to_utf8(tmp.xmlname)
<< " requires: " << tmp.required << " requires: " << tmp.required
<< " hidden: " << tmp.hidden << '\''); << " hidden: " << tmp.hidden << '\'');

View File

@ -57,8 +57,6 @@ public:
docstring dsp_draw; docstring dsp_draw;
/// operator/..., fontname e /// operator/..., fontname e
docstring extra; docstring extra;
/// how is this called as HTML entity in MathML?
docstring htmlname;
/// how is this called as XML entity in MathML? /// how is this called as XML entity in MathML?
docstring xmlname; docstring xmlname;
/// required LaTeXFeatures /// required LaTeXFeatures

View File

@ -288,8 +288,8 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int i)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns, bool xmlMode) MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns)
: os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns), xml_mode_(xmlMode) : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
{ {
if (in_text_) if (in_text_)
font_math_style_ = TEXT_STYLE; font_math_style_ = TEXT_STYLE;
@ -751,9 +751,8 @@ OctaveStream & operator<<(OctaveStream & os, string const & s)
} }
docstring convertDelimToXMLEscape(docstring const & name, bool xmlmode) docstring convertDelimToXMLEscape(docstring const & name)
{ {
// For the basic symbols, no difference between XML and HTML.
if (name.size() == 1) { if (name.size() == 1) {
char_type const c = name[0]; char_type const c = name[0];
if (c == '<') if (c == '<')
@ -772,8 +771,7 @@ docstring convertDelimToXMLEscape(docstring const & name, bool xmlmode)
MathWordList const & words = mathedWordList(); MathWordList const & words = mathedWordList();
MathWordList::const_iterator it = words.find(name); MathWordList::const_iterator it = words.find(name);
if (it != words.end()) { if (it != words.end()) {
// Only difference between XML and HTML, based on the contents read by MathFactory. docstring const escape = it->second.xmlname;
docstring const escape = xmlmode ? it->second.xmlname : it->second.htmlname;
return escape; return escape;
} }
LYXERR0("Unable to find `" << name <<"' in the mathWordList."); LYXERR0("Unable to find `" << name <<"' in the mathWordList.");

View File

@ -377,7 +377,7 @@ class MathExportException : public std::exception {};
class MathMLStream { class MathMLStream {
public: public:
/// Builds a stream proxy for os; the MathML namespace is given by xmlns (supposed to be already defined elsewhere in the document). /// Builds a stream proxy for os; the MathML namespace is given by xmlns (supposed to be already defined elsewhere in the document).
explicit MathMLStream(odocstream & os, std::string const & xmlns = "", bool xmlMode = false); explicit MathMLStream(odocstream & os, std::string const & xmlns = "");
/// ///
void cr(); void cr();
/// ///
@ -398,8 +398,6 @@ public:
bool inText() const { return in_text_; } bool inText() const { return in_text_; }
/// ///
std::string xmlns() const { return xmlns_; } std::string xmlns() const { return xmlns_; }
///
bool xmlMode() const { return xml_mode_; }
/// Returns the tag name prefixed by the name space if needed. /// Returns the tag name prefixed by the name space if needed.
std::string namespacedTag(std::string const & tag) const { std::string namespacedTag(std::string const & tag) const {
return (xmlns().empty() ? "" : xmlns() + ":") + tag; return (xmlns().empty() ? "" : xmlns() + ":") + tag;
@ -423,8 +421,6 @@ private:
odocstringstream deferred_; odocstringstream deferred_;
/// ///
std::string xmlns_; std::string xmlns_;
///
bool xml_mode_;
/// The only important part of a FontInfo object. /// The only important part of a FontInfo object.
MathStyle font_math_style_; MathStyle font_math_style_;
/// ///
@ -699,7 +695,7 @@ OctaveStream & operator<<(OctaveStream &, char);
OctaveStream & operator<<(OctaveStream &, int); OctaveStream & operator<<(OctaveStream &, int);
docstring convertDelimToXMLEscape(docstring const & name, bool xmlmode); docstring convertDelimToXMLEscape(docstring const & name);
} // namespace lyx } // namespace lyx