From 91a40ccaffce74728d109c726985f67773b0617e Mon Sep 17 00:00:00 2001
From: Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de>
Date: Thu, 13 Jan 2011 12:23:36 +0100
Subject: =?UTF-8?q?adapted=20ConTeXt=20escaping=20--=20waiting=20for=20?=
 =?UTF-8?q?=E2=80=98=5F=E2=80=99=20to=20generally=20get=20letter=20catcode?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 mod/tex/context/third/rst/rst_context.lua | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'mod/tex/context/third')

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)
-- 
cgit v1.2.3