val.insert(2, from_ascii("{"));
}
docstring rem;
- docstring const cnvtd = Encodings::fromLaTeXCommand(val, rem);
+ docstring const cnvtd = Encodings::fromLaTeXCommand(val, rem,
+ Encodings::TEXT_CMD);
if (!cnvtd.empty()) {
// it did, so we'll take that bit and proceed with what's left
ret += cnvtd;
}
-docstring Encodings::fromLaTeXCommand(docstring const & cmd, docstring & rem)
+docstring Encodings::fromLaTeXCommand(docstring const & cmd, docstring & rem,
+ int cmdtype)
{
+ bool const mathmode = cmdtype & MATH_CMD;
+ bool const textmode = cmdtype & TEXT_CMD;
docstring symbols;
size_t i = 0;
size_t const cmdend = cmd.size();
size_t unicmd_size = 0;
char_type c = 0;
for (; it != uniend; ++it) {
- docstring const math = it->second.mathcommand;
- docstring const text = it->second.textcommand;
+ docstring const math = mathmode ? it->second.mathcommand
+ : docstring();
+ docstring const text = textmode ? it->second.textcommand
+ : docstring();
size_t cur_size = max(math.size(), text.size());
// The current math or text unicode command cannot
// match, or we already matched a longer one
* point and set \p combining to true if it is a combining symbol
*/
static char_type fromLaTeXCommand(docstring const & cmd, bool & combining);
+ ///
+ enum LatexCmd {
+ ///
+ MATH_CMD = 1,
+ ///
+ TEXT_CMD = 2
+ };
/**
* Convert the LaTeX commands in \p cmd and \return a docstring
* of corresponding unicode points. The conversion stops at the
* first command which could not be converted, and the remaining
- * unconverted commands are returned in \p rem
+ * unconverted commands are returned in \p rem.
+ * The \p cmdtype parameter can be used to limit recognized
+ * commands to math or text mode commands only.
*/
- static docstring fromLaTeXCommand(docstring const & cmd, docstring & rem);
+ static docstring fromLaTeXCommand(docstring const & cmd,
+ docstring & rem, int cmdtype = MATH_CMD | TEXT_CMD);
/**
* Add the preamble snippet needed for the output of \p c to
* \p features.