#include "Encoding.h"
-#include "Lexer.h"
-
#include "support/debug.h"
#include "support/docstring.h"
#include "support/gettext.h"
+#include "support/Lexer.h"
#include "support/lstrings.h"
#include "support/mutex.h"
#include "support/textutils.h"
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();
+ if (req && unicodeSymbol.second.mathFeature()
+ && !unicodeSymbol.second.mathPreamble().empty())
+ req->insert(unicodeSymbol.second.mathPreamble());
+ return value;
+ }
+ }
+ }
+ if (textmode) {
+ for (const auto & command : unicodeSymbol.second.textCommands()) {
+ if (command == cmd) {
+ docstring value;
+ value += unicodeSymbol.first;
+ needsTermination = !unicodeSymbol.second.textNoTermination();
+ if (req && unicodeSymbol.second.textFeature()
+ && !unicodeSymbol.second.textPreamble().empty())
+ req->insert(unicodeSymbol.second.textPreamble());
+ 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;
// the prefix of some command in the unicodesymbols file
docstring subcmd = cmd.substr(i, j - i + 1);
- CharInfoMap::const_iterator it = unicodesymbols.begin();
// First part of subcmd which might be a combining character
docstring combcmd = (m == j) ? docstring() : cmd.substr(i, m - i + 1);
// The combining character of combcmd if it exists
- CharInfoMap::const_iterator combining = uniend;
size_t unicmd_size = 0;
char_type c = 0;
+ CharInfoMap::const_iterator it = unicodesymbols.begin();
+ CharInfoMap::const_iterator combining = uniend;
for (; it != uniend; ++it) {
if (it->second.deprecated())
continue;
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();