- escape_map.push_back(pair<string, string>("{*}", "*"));
- escape_map.push_back(pair<string, string>("{[}", "["));
- escape_map.push_back(pair<string, string>("\\$", "$"));
- escape_map.push_back(pair<string, string>("\\backslash{}", "\\"));
- escape_map.push_back(pair<string, string>("\\backslash", "\\"));
- escape_map.push_back(pair<string, string>("\\sim ", "~"));
- escape_map.push_back(pair<string, string>("\\^", "^"));
+ escape_map.push_back(P("\\%", "%"));
+ escape_map.push_back(P("\\mathcircumflex ", "^"));
+ escape_map.push_back(P("\\mathcircumflex", "^"));
+ escape_map.push_back(P("\\backslash ", "\\"));
+ escape_map.push_back(P("\\backslash", "\\"));
+ escape_map.push_back(P("\\\\{", "_x_<"));
+ escape_map.push_back(P("\\\\}", "_x_>"));
+ escape_map.push_back(P("\\sim ", "~"));
+ escape_map.push_back(P("\\sim", "~"));
+ }
+ return escape_map;
+}
+
+/// A map of escapes turning a regexp matching text to one matching latex.
+Escapes const & get_regexp_latex_escapes()
+{
+ typedef std::pair<std::string, std::string> P;
+
+ static Escapes escape_map;
+ if (escape_map.empty()) {
+ escape_map.push_back(P("\\\\", "(?:\\\\\\\\|\\\\backslash|\\\\textbackslash\\{\\})"));
+ escape_map.push_back(P("(<?!\\\\\\\\textbackslash)\\{", "\\\\\\{"));
+ escape_map.push_back(P("(<?!\\\\\\\\textbackslash\\\\\\{)\\}", "\\\\\\}"));
+ escape_map.push_back(P("\\[", "\\{\\[\\}"));
+ escape_map.push_back(P("\\]", "\\{\\]\\}"));
+ escape_map.push_back(P("\\^", "(?:\\^|\\\\textasciicircum\\{\\}|\\\\mathcircumflex)"));
+ escape_map.push_back(P("%", "\\\\\\%"));