]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathParser.cpp
Fix bug 5393
[lyx.git] / src / mathed / MathParser.cpp
index 56fdf23c81db936e223f1483e967ddcd9b8ebe40..7494a2906cb261ecacb9b5da01326c0603a4ed21 100644 (file)
@@ -100,11 +100,16 @@ bool stared(docstring const & s)
 }
 
 
-docstring escapeSpecialChars(docstring const & str)
+docstring escapeSpecialChars(docstring const & str, bool textmode)
 {
+       docstring const backslash = textmode ? from_ascii("\\textbackslash ")
+                                            : from_ascii("\\backslash ");
+       docstring const caret = textmode ? from_ascii("\\textasciicircum ")
+                                        : from_ascii("\\mathcircumflex ");
+
        return subst(subst(subst(subst(subst(subst(subst(subst(subst(str,
-                       from_ascii("\\"), from_ascii("\\backslash ")),
-                       from_ascii("^"), from_ascii("\\mathcircumflex ")),
+                       from_ascii("\\"), backslash),
+                       from_ascii("^"), caret),
                        from_ascii("_"), from_ascii("\\_")),
                        from_ascii("$"), from_ascii("\\$")),
                        from_ascii("#"), from_ascii("\\#")),
@@ -540,8 +545,9 @@ void Parser::tokenize(istream & is)
 
 void Parser::tokenize(docstring const & buffer)
 {
-       idocstringstream is(mode_ & Parse::VERBATIM ?
-               escapeSpecialChars(buffer) : buffer, ios::in | ios::binary);
+       idocstringstream is(mode_ & Parse::VERBATIM
+                       ? escapeSpecialChars(buffer, mode_ & Parse::TEXTMODE)
+                       : buffer, ios::in | ios::binary);
 
        char_type c;
        while (is.get(c)) {