summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-url.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
commit57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch)
tree1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/lang-url.lua
parent6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff)
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 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.lua136
1 files changed, 68 insertions, 68 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-url.lua b/Master/texmf-dist/tex/context/base/lang-url.lua
index 3d93a046a21..b0a71ec679e 100644
--- a/Master/texmf-dist/tex/context/base/lang-url.lua
+++ b/Master/texmf-dist/tex/context/base/lang-url.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['lang-url'] = {
version = 1.001,
- comment = "companion to lang-url.tex",
+ comment = "companion to lang-url.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
@@ -11,7 +11,7 @@ local utf = unicode.utf8
local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues
local utfbyte, utfgsub = utf.byte, utf.gsub
-local ctxcatcodes = tex.ctxcatcodes
+local ctxcatcodes, texsprint = tex.ctxcatcodes, tex.sprint
commands = commands or { }
@@ -22,80 +22,80 @@ parsing, but the following solution suits as well. After all, we're mostly
dealing with <l n='ascii'/> characters.</p>
]]--
-do
-
- commands.hyphenatedurl = commands.hyphenatedurl or { }
-
- commands.hyphenatedurl.characters = {
- ["!"] = 1,
- ["\""] = 1,
- ["#"] = 1,
- ["$"] = 1,
- ["%"] = 1,
- ["&"] = 1,
- ["("] = 1,
- ["*"] = 1,
- ["+"] = 1,
- [","] = 1,
- ["-"] = 1,
- ["."] = 1,
- ["/"] = 1,
- [":"] = 1,
- [";"] = 1,
- ["<"] = 1,
- ["="] = 1,
- [">"] = 1,
- ["?"] = 1,
- ["@"] = 1,
- ["["] = 1,
- ["\\"] = 1,
- ["^"] = 1,
- ["_"] = 1,
- ["`"] = 1,
- ["{"] = 1,
- ["|"] = 1,
- ["~"] = 1,
-
- ["'"] = 2,
- [")"] = 2,
- ["]"] = 2,
- ["}"] = 2
- }
-
- commands.hyphenatedurl.lefthyphenmin = 2
- commands.hyphenatedurl.righthyphenmin = 3
-
- local chars = commands.hyphenatedurl.characters
+commands.hyphenatedurl = commands.hyphenatedurl or { }
+
+local hyphenatedurl = commands.hyphenatedurl
+
+hyphenatedurl.characters = {
+ ["!"] = 1,
+ ["\""] = 1,
+ ["#"] = 1,
+ ["$"] = 1,
+ ["%"] = 1,
+ ["&"] = 1,
+ ["("] = 1,
+ ["*"] = 1,
+ ["+"] = 1,
+ [","] = 1,
+ ["-"] = 1,
+ ["."] = 1,
+ ["/"] = 1,
+ [":"] = 1,
+ [";"] = 1,
+ ["<"] = 1,
+ ["="] = 1,
+ [">"] = 1,
+ ["?"] = 1,
+ ["@"] = 1,
+ ["["] = 1,
+ ["\\"] = 1,
+ ["^"] = 1,
+ ["_"] = 1,
+ ["`"] = 1,
+ ["{"] = 1,
+ ["|"] = 1,
+ ["~"] = 1,
+
+ ["'"] = 2,
+ [")"] = 2,
+ ["]"] = 2,
+ ["}"] = 2
+}
- 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)
- str = utfgsub(str,"(.)",function(s)
- n = n + 1
+hyphenatedurl.lefthyphenmin = 2
+hyphenatedurl.righthyphenmin = 3
+hyphenatedurl.discretionary = nil
+
+local chars = hyphenatedurl.characters
+
+function hyphenatedurl.action(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)
+ local d = disc or hyphenatedurl.discretionary
+ for s in utfcharacters(str) do
+ n = n + 1
+ if s == d then
+ texsprint(ctxcatcodes,"\\d{",utfbyte(s),"}")
+ else
local c = chars[s]
if not c or n<=b or n>=e then
- return "\\n{" .. utfbyte(s) .. "}"
+ texsprint(ctxcatcodes,"\\n{",utfbyte(s),"}")
elseif c == 1 then
- return "\\b{" .. utfbyte(s) .. "}"
+ texsprint(ctxcatcodes,"\\b{",utfbyte(s),"}")
elseif c == 2 then
- return "\\a{" .. utfbyte(s) .. "}"
+ texsprint(ctxcatcodes,"\\a{",utfbyte(s),"}")
end
- end )
- 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 s in utfcharacters(str) do
- chars[s] = value or 1
end
end
+end
- -- commands.hyphenatedurl.setcharacters("')]}",2)
+-- todo, no interface in mkiv yet
+function hyphenatedurl.setcharacters(str,value) -- 1, 2 == before, after
+ for s in utfcharacters(str) do
+ chars[s] = value or 1
+ end
end
+
+-- .hyphenatedurl.setcharacters("')]}",2)