diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-09-28 11:20:59 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-09-28 11:20:59 +0200 |
commit | 164a98ac4e58ae88de0a83d1eb60583827f4fbab (patch) | |
tree | a9bb80667dcf2dacc511b7c0dd0439e3ece7c274 /tex/context/base/mkiv/lang-rep.lua | |
parent | e5c13c74b45e08527dda1d1be1788cccd96b6dac (diff) | |
download | context-164a98ac4e58ae88de0a83d1eb60583827f4fbab.tar.gz |
2017-09-28 10:13:00
Diffstat (limited to 'tex/context/base/mkiv/lang-rep.lua')
-rw-r--r-- | tex/context/base/mkiv/lang-rep.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/lang-rep.lua b/tex/context/base/mkiv/lang-rep.lua index f7eeefdba..a09574ef4 100644 --- a/tex/context/base/mkiv/lang-rep.lua +++ b/tex/context/base/mkiv/lang-rep.lua @@ -16,6 +16,7 @@ if not modules then modules = { } end modules ['lang-rep'] = { -- is somewhat unique. local type, tonumber = type, tonumber +local gmatch, gsub = string.gmatch, string.gsub local utfbyte, utfsplit = utf.byte, utf.split local P, C, U, Cc, Ct, Cs, lpegmatch = lpeg.P, lpeg.C, lpeg.patterns.utf8character, lpeg.Cc, lpeg.Ct, lpeg.Cs, lpeg.match local find = string.find @@ -140,6 +141,26 @@ function replacements.add(category,word,replacement) end end +-- local strip = lpeg.stripper("{}") + +function languages.replacements.addlist(category,list) + local root = lists[category].list + if type(list) == "string" then + for new in gmatch(list,"%S+") do + local old = gsub(new,"[{}]","") + -- local old = lpegmatch(strip,new) + add(root,old,new) + end + else + for i=1,#list do + local new = list[i] + local old = gsub(new,"[{}]","") + -- local old = lpegmatch(strip,new) + add(root,old,new) + end + end +end + local function hit(a,head) local tree = trees[a] if tree then @@ -336,3 +357,9 @@ implement { actions = replacements.add, arguments = { "string", "string", "string" } } + +implement { + name = "addreplacementslist", + actions = replacements.addlist, + arguments = { "string", "string" } +} |