summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-url.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
committerTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
commitd7ccb42582f85acf30568913610ccf4d602023fb (patch)
tree7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/lang-url.lua
parent2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff)
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-url.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lang-url.lua24
1 files changed, 14 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-url.lua b/Master/texmf-dist/tex/context/base/lang-url.lua
index b0a71ec679e..e401e41484d 100644
--- a/Master/texmf-dist/tex/context/base/lang-url.lua
+++ b/Master/texmf-dist/tex/context/base/lang-url.lua
@@ -11,9 +11,10 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utfgsub = utf.byte, utf.gsub
-local ctxcatcodes, texsprint = tex.ctxcatcodes, tex.sprint
+context = context
-commands = commands or { }
+commands = commands or { }
+local commands = commands
--[[
<p>Hyphenating <l n='url'/>'s is somewhat tricky and a matter of taste. I did
@@ -23,10 +24,9 @@ dealing with <l n='ascii'/> characters.</p>
]]--
commands.hyphenatedurl = commands.hyphenatedurl or { }
+local hyphenatedurl = commands.hyphenatedurl
-local hyphenatedurl = commands.hyphenatedurl
-
-hyphenatedurl.characters = {
+hyphenatedurl.characters = utilities.storage.allocate {
["!"] = 1,
["\""] = 1,
["#"] = 1,
@@ -68,7 +68,7 @@ hyphenatedurl.discretionary = nil
local chars = hyphenatedurl.characters
-function hyphenatedurl.action(str, left, right, disc)
+local function action(hyphenatedurl, str, left, right, disc)
local n = 0
local b = math.max( left or hyphenatedurl.lefthyphenmin, 2)
local e = math.min(#str-(right or hyphenatedurl.righthyphenmin)+2,#str)
@@ -76,20 +76,24 @@ function hyphenatedurl.action(str, left, right, disc)
for s in utfcharacters(str) do
n = n + 1
if s == d then
- texsprint(ctxcatcodes,"\\d{",utfbyte(s),"}")
+ context.d(utfbyte(s))
else
local c = chars[s]
if not c or n<=b or n>=e then
- texsprint(ctxcatcodes,"\\n{",utfbyte(s),"}")
+ context.n(utfbyte(s))
elseif c == 1 then
- texsprint(ctxcatcodes,"\\b{",utfbyte(s),"}")
+ context.b(utfbyte(s))
elseif c == 2 then
- texsprint(ctxcatcodes,"\\a{",utfbyte(s),"}")
+ context.a(utfbyte(s))
end
end
end
end
+-- hyphenatedurl.action = function(_,...) action(...) end -- sort of obsolete
+
+table.setmetatablecall(hyphenatedurl,action)
+
-- todo, no interface in mkiv yet
function hyphenatedurl.setcharacters(str,value) -- 1, 2 == before, after