summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-url.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-url.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lang-url.lua27
1 files changed, 18 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-url.lua b/Master/texmf-dist/tex/context/base/lang-url.lua
index d0214af7706..3d93a046a21 100644
--- a/Master/texmf-dist/tex/context/base/lang-url.lua
+++ b/Master/texmf-dist/tex/context/base/lang-url.lua
@@ -6,6 +6,13 @@ if not modules then modules = { } end modules ['lang-url'] = {
license = "see context related readme files"
}
+local utf = unicode.utf8
+
+local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
+local utfbyte, utfgsub = utf.byte, utf.gsub
+
+local ctxcatcodes = tex.ctxcatcodes
+
commands = commands or { }
--[[
@@ -60,30 +67,32 @@ do
local chars = commands.hyphenatedurl.characters
- function commands.hyphenatedurl.action(str, left, right)
+ function commands.hyphenatedurl.convert(str, left, right)
local n = 0
local b = math.max(left or commands.hyphenatedurl.lefthyphenmin,2)
local e = math.min(#str-(right or commands.hyphenatedurl.righthyphenmin)+2,#str)
- local u = utf.byte
- str = utf.gsub(str,"(.)",function(s)
+ str = utfgsub(str,"(.)",function(s)
n = n + 1
local c = chars[s]
if not c or n<=b or n>=e then
- return "\\n{" .. u(s) .. "}"
+ return "\\n{" .. utfbyte(s) .. "}"
elseif c == 1 then
- return "\\b{" .. u(s) .. "}"
+ return "\\b{" .. utfbyte(s) .. "}"
elseif c == 2 then
- return "\\a{" .. u(s) .. "}"
+ return "\\a{" .. utfbyte(s) .. "}"
end
end )
- tex.sprint(tex.ctxcatcodes,str)
+ return str
+ end
+ function commands.hyphenatedurl.action(str, left, right)
+ tex.sprint(ctxcatcodes,commands.hyphenatedurl.convert(str, left, right))
end
-- todo, no interface in mkiv yet
function commands.hyphenatedurl.setcharacters(str,value) -- 1, 2 == before, after
- for ch in utf.gmatch(".") do
- chars[ch] = value or 1
+ for s in utfcharacters(str) do
+ chars[s] = value or 1
end
end