summaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/tex/context/third/rst/rst_context.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/mod/tex/context/third/rst/rst_context.lua b/mod/tex/context/third/rst/rst_context.lua
index a18086b..5ed7812 100644
--- a/mod/tex/context/third/rst/rst_context.lua
+++ b/mod/tex/context/third/rst/rst_context.lua
@@ -331,10 +331,17 @@ function rst_context.substitution_reference (str, underscores)
return sub .. [[{\\RSTsubstitution]] .. str:gsub("%s", "") .. "}"
end
+-- see catc-sym.tex
+local escape_me = {
+ ["&"] = [[\letterampersand ]],
+ ["#"] = [[\letterhash ]],
+ ["^"] = [[\letterhat ]],
+ ["_"] = [[\letterunderscore ]],
+}
+
function rst_context.escape (str)
- str = str:gsub("\\(.)", "%1")
- str = str:gsub("&", "\\letterampersand")
- return str
+ str = str:gsub("\\(.)", "%1") -- literalize escaped sequences
+ return str:gsub("[&#^_]", escape_me) -- escape chars with special meaning
end
function rst_context.joinindented (tab)