X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FEncoding.cpp;h=a4c706bd3b409b30a68e46ef4b3ca3f96fe2630e;hb=39c0b322f7b140ca9a9c1544adf05f296a5ea28f;hp=4e47daef8b0dc6d5967ece778a3d7c31423d8a90;hpb=0dc7f34e00e06e8b378236e32f86023313067b7c;p=features.git diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 4e47daef8b..a4c706bd3b 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -381,6 +381,32 @@ docstring Encodings::fromLaTeXCommand(docstring const & cmd, int cmdtype, rem = empty_docstring(); bool const mathmode = cmdtype & MATH_CMD; bool const textmode = cmdtype & TEXT_CMD; + + // Easy case: the command is a complete entry of unicodesymbols. + for (const auto & unicodeSymbol : unicodesymbols) { + if (mathmode) { + for (const auto & command : unicodeSymbol.second.mathCommands()) { + if (command == cmd) { + docstring value; + value += unicodeSymbol.first; + needsTermination = !unicodeSymbol.second.mathNoTermination(); + return value; + } + } + } + if (textmode) { + for (const auto & command : unicodeSymbol.second.textCommands()) { + if (command == cmd) { + docstring value; + value += unicodeSymbol.first; + needsTermination = !unicodeSymbol.second.textNoTermination(); + return value; + } + } + } + } + + // Otherwise, try to map as many commands as possible, matching prefixes of the command. docstring symbols; size_t const cmdend = cmd.size(); size_t prefix = 0; @@ -727,7 +753,7 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) symbol = tmp; // Special case: more than one entry for one character (to add other LaTeX commands). - if (unicodesymbols.contains(symbol)) { + if (unicodesymbols.find(symbol) != unicodesymbols.end()) { if (!symbolsLex.next(true)) break; docstring textCommand = symbolsLex.getDocString();