summaryrefslogtreecommitdiff
path: root/tex/context/base/l-string.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/l-string.lua')
-rw-r--r--tex/context/base/l-string.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/tex/context/base/l-string.lua b/tex/context/base/l-string.lua
index b0344c002..b8059c0c9 100644
--- a/tex/context/base/l-string.lua
+++ b/tex/context/base/l-string.lua
@@ -332,3 +332,28 @@ function string:split_settings() -- no {} handling, see l-aux for lpeg variant
return nil
end
end
+
+local patterns_escapes = {
+ ["-"] = "%-",
+ ["."] = "%.",
+ ["+"] = "%+",
+ ["*"] = "%*",
+ ["%"] = "%%",
+ ["("] = "%)",
+ [")"] = "%)",
+ ["["] = "%[",
+ ["]"] = "%]",
+}
+
+
+function string:pattesc()
+ return (self:gsub(".",patterns_escapes))
+end
+
+function string:tohash()
+ local t = { }
+ for s in self:gmatch("([^, ]+)") do -- lpeg
+ t[s] = true
+ end
+ return t
+end