summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/lang-url.lmt259
-rw-r--r--tex/context/base/mkxl/lang-url.mkxl2
-rw-r--r--tex/context/base/mkxl/lpdf-xmp.lmt4
-rw-r--r--tex/context/base/mkxl/mlib-pps.lmt2
-rw-r--r--tex/context/base/mkxl/mlib-svg.lmt2
-rw-r--r--tex/context/base/mkxl/spac-ali.mkxl44
-rw-r--r--tex/context/base/mkxl/syst-aux.mkxl25
9 files changed, 321 insertions, 21 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index b29dfe679..b300fcf1b 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2021.10.21 19:53}
+\newcontextversion{2021.10.24 21:42}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index d49b81f2b..41d4e1ca3 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2021.10.21 19:53}
+\immutable\edef\contextversion{2021.10.24 21:42}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/lang-url.lmt b/tex/context/base/mkxl/lang-url.lmt
new file mode 100644
index 000000000..b918464d0
--- /dev/null
+++ b/tex/context/base/mkxl/lang-url.lmt
@@ -0,0 +1,259 @@
+if not modules then modules = { } end modules ['lang-url'] = {
+ version = 1.001,
+ 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"
+}
+
+local next = next
+local utfcharacters, utfbyte, utfchar = utf.characters, utf.byte, utf.char
+local min, max = math.min, math.max
+local setmetatableindex = table.setmetatableindex
+
+local context = context
+local ctx_pushcatcodes = context.pushcatcodes
+local ctx_popcatcodes = context.popcatcodes
+
+local implement = interfaces.implement
+local variables = interfaces.variables
+
+local v_before = variables.before
+local v_after = variables.after
+
+local is_letter = characters.is_letter
+
+--[[
+<p>Hyphenating <l n='url'/>'s is somewhat tricky and a matter of taste. I did
+consider using a dedicated hyphenation pattern or dealing with it by node
+parsing, but the following solution suits as well. After all, we're mostly
+dealing with <l n='ascii'/> characters.</p>
+]]--
+
+local urls = { }
+languages.urls = urls
+
+local characters = utilities.storage.allocate {
+ ["!"] = "before",
+ ['"'] = "before",
+ ["#"] = "before",
+ ["$"] = "before",
+ ["%"] = "before",
+ ["&"] = "before",
+ ["("] = "before",
+ ["*"] = "before",
+ ["+"] = "before",
+ [","] = "before",
+ ["-"] = "before",
+ ["."] = "before",
+ ["/"] = "before",
+ [":"] = "before",
+ [";"] = "before",
+ ["<"] = "before",
+ ["="] = "before",
+ [">"] = "before",
+ ["?"] = "before",
+ ["@"] = "before",
+ ["["] = "before",
+ ["\\"] = "before",
+ ["^"] = "before",
+ ["_"] = "before",
+ ["`"] = "before",
+ ["{"] = "before",
+ ["|"] = "before",
+ ["~"] = "before",
+
+ ["'"] = "after",
+ [")"] = "after",
+ ["]"] = "after",
+ ["}"] = "after",
+}
+
+local mapping = utilities.storage.allocate {
+ -- [utfchar(0xA0)] = "~", -- nbsp (catch)
+}
+
+urls.characters = characters
+urls.mapping = mapping
+urls.lefthyphenmin = 2
+urls.righthyphenmin = 3
+urls.discretionary = nil
+urls.packslashes = false
+
+directives.register("hyphenators.urls.packslashes",function(v) urls.packslashes = v end)
+
+local trace = false trackers.register("hyphenators.urls",function(v) trace = v end)
+local report = logs.reporter("hyphenators","urls")
+
+-- local ctx_a = context.a
+-- local ctx_b = context.b
+-- local ctx_d = context.d
+-- local ctx_c = context.c
+-- local ctx_l = context.l
+-- local ctx_C = context.C
+-- local ctx_L = context.L
+
+-- local function action(hyphenatedurl,str,left,right,disc)
+-- --
+-- left = max( left or urls.lefthyphenmin, 2)
+-- right = min(#str-(right or urls.righthyphenmin)+2,#str)
+-- disc = disc or urls.discretionary
+-- --
+-- local word = nil
+-- local prev = nil
+-- local pack = urls.packslashes
+-- local length = 0
+-- --
+-- for char in utfcharacters(str) do
+-- length = length + 1
+-- char = mapping[char] or char
+-- local b = utfbyte(char)
+-- if prev == char and prev == "/" then
+-- ctx_c(b)
+-- elseif char == disc then
+-- ctx_d()
+-- else
+-- if prev == "/" then
+-- ctx_d()
+-- end
+-- local how = characters[char]
+-- if how == v_before then
+-- word = false
+-- ctx_b(b)
+-- elseif how == v_after then
+-- word = false
+-- ctx_a(b)
+-- else
+-- local letter = is_letter[char]
+-- if length <= left or length >= right then
+-- if word and letter then
+-- ctx_L(b)
+-- else
+-- ctx_C(b)
+-- end
+-- elseif word and letter then
+-- ctx_l(b)
+-- else
+-- ctx_c(b)
+-- end
+-- word = letter
+-- end
+-- end
+-- if pack then
+-- prev = char
+-- else
+-- prev = nil
+-- end
+-- end
+-- end
+
+local function action(hyphenatedurl,str,left,right,disc)
+ --
+ left = max( left or urls.lefthyphenmin, 2)
+ right = min(#str-(right or urls.righthyphenmin)+2,#str)
+ disc = disc or urls.discretionary
+ --
+ local word = nil
+ local pack = urls.packslashes
+ local length = 0
+ local list = utf.split(str)
+ local size = #list
+ local prev = nil
+
+ for i=1,size do
+ local what = nil
+ local dodi = false
+ local char = list[i]
+ length = length + 1
+ char = mapping[char] or char
+ if char == disc then
+ dodi = true
+ elseif pack and char == "/" and (list[i+1] == "/" or prev == "/") then
+ what = "c"
+ else
+ local how = characters[char]
+ if how == v_before then
+ what = "b"
+ elseif how == v_after then
+ word = false
+ what = "a"
+ else
+ local letter = is_letter[char]
+ if length <= left or length >= right then
+ if word and letter then
+ what = "L"
+ else
+ what = "C"
+ end
+ elseif word and letter then
+ what = "l"
+ else
+ what = "c"
+ end
+ word = letter
+ end
+ end
+ if dodi then
+ list[i] = "\\lang_url_d "
+ else
+ list[i] = "\\lang_url_" .. what .. "{" .. utfbyte(char) .. "}"
+ end
+ prev = char
+ end
+ if trace then
+ report("old : %s",str)
+ report("new : %t",list)
+ end
+ ctx_pushcatcodes("prtcatcodes")
+ context("%t",list)
+ ctx_popcatcodes()
+end
+
+-- urls.action = function(_,...) action(...) end -- sort of obsolete
+
+table.setmetatablecall(hyphenatedurl,action) -- watch out: a caller
+
+-- todo, no interface in mkiv yet
+
+local registerfunction = context.functions.register
+local unregisterfunction = context.functions.unregister
+local savelua = token.savelua
+
+local function restorevalues(savedchars,restore)
+ for k, v in next, savedchars do
+ characters[k] = v
+ end
+ unregisterfunction(restore)
+end
+
+function urls.setcharacters(str,value) -- 1, 2 == before, after
+ local savedchars = { }
+ local newvalue = value or v_before
+ for s in utfcharacters(str) do
+ local oldvalue = characters[s]
+ if oldvalue ~= newvalue then
+ savedchars[s] = oldvalue
+ characters[s] = newvalue
+ end
+ end
+ if next(savedchars) then
+ local restore = nil
+ restore = registerfunction(function() restorevalues(savedchars,restore) end)
+ savelua(restore)
+ end
+end
+
+-- .urls.setcharacters("')]}",2)
+
+implement {
+ name = "sethyphenatedurlcharacters",
+ actions = urls.setcharacters,
+ arguments = "2 strings",
+}
+
+implement {
+ name = "hyphenatedurl",
+ scope = "private",
+ actions = function(...) action(hyphenatedurl,...) end,
+ arguments = { "string", "integer", "integer", "string" }
+}
diff --git a/tex/context/base/mkxl/lang-url.mkxl b/tex/context/base/mkxl/lang-url.mkxl
index 04a55fcf9..6e38c95a1 100644
--- a/tex/context/base/mkxl/lang-url.mkxl
+++ b/tex/context/base/mkxl/lang-url.mkxl
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\registerctxluafile{lang-url}{}
+\registerctxluafile{lang-url}{autosuffix}
\unprotect
diff --git a/tex/context/base/mkxl/lpdf-xmp.lmt b/tex/context/base/mkxl/lpdf-xmp.lmt
index ce5d69a48..c4f475914 100644
--- a/tex/context/base/mkxl/lpdf-xmp.lmt
+++ b/tex/context/base/mkxl/lpdf-xmp.lmt
@@ -151,7 +151,7 @@ local function pdfsetmetadate(n,both)
if n then
n = converters.totime(n)
if n then
- creationdate = osdate("%Y-%m-%dT%X",ostime(n)) .. ostimezone(true)
+ creationdate = osdate("%Y-%m-%dT%H:%M:%S",ostime(n)) .. ostimezone()
if both then
modificationdate = creationdate
end
@@ -190,7 +190,7 @@ local function setdates(v)
end
end
if toboolean(v) then
- creationdate = osdate("%Y-%m-%dT%X") .. ostimezone(true)
+ creationdate = osdate("%Y-%m-%dT%H:%M:%S") .. ostimezone()
modificationdate = creationdate
else
creationdate = false
diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt
index bad738bc1..5d91f0799 100644
--- a/tex/context/base/mkxl/mlib-pps.lmt
+++ b/tex/context/base/mkxl/mlib-pps.lmt
@@ -392,7 +392,7 @@ function models.rgb(cr)
elseif metapost.reducetogray then
if n == 1 then
local s = cr[1]
- checked_color_pair(f_gray,s,s)
+ return checked_color_pair(f_gray,s,s)
elseif n == 3 then
local r = cr[1]
local g = cr[2]
diff --git a/tex/context/base/mkxl/mlib-svg.lmt b/tex/context/base/mkxl/mlib-svg.lmt
index 9dcd6984b..5279bea71 100644
--- a/tex/context/base/mkxl/mlib-svg.lmt
+++ b/tex/context/base/mkxl/mlib-svg.lmt
@@ -636,7 +636,7 @@ local colorcomponents, withcolor, thecolor, usedcolors do
tonumber(t[2]) or 0,
tonumber(t[3]) or 0,
tonumber(t[4]) or 0,
- tonumber(t[4]) or false
+ tonumber(t[5]) or false
elseif what == "cmyk" then
return
what,
diff --git a/tex/context/base/mkxl/spac-ali.mkxl b/tex/context/base/mkxl/spac-ali.mkxl
index d6043b4da..e196b0c03 100644
--- a/tex/context/base/mkxl/spac-ali.mkxl
+++ b/tex/context/base/mkxl/spac-ali.mkxl
@@ -1081,6 +1081,28 @@
{\normalexpanded{\spac_word_right_indeed{#1}{\hpack{\thebox\nextbox}}}}
\hbox}
+% \protected\def\spac_word_right_indeed#1#2%
+% {\registerparwrapper
+% {\v!word:\v!right}
+% {\begingroup
+% \frozen\parfillskip \zeropoint
+% \frozen\finalhyphendemerits\zerocount
+% \endgroup}
+% {\doifelseparwrapper{\v!word:\v!right}%
+% {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}%
+% \strut \removeunwantedspaces
+% \hfill
+% \allowbreak % changed back from \hskip\zeropoint
+% \quad}%
+% {\allowbreak % changed back from \hskip\zeropoint
+% \break}%
+% \unregisterparwrapper{\v!word:\v!right}%
+% \strut
+% \hfill
+% \nobreak
+% #2%
+% \allowbreak}}
+
\protected\def\spac_word_right_indeed#1#2%
{\registerparwrapper
{\v!word:\v!right}
@@ -1088,20 +1110,14 @@
\frozen\parfillskip \zeropoint
\frozen\finalhyphendemerits\zerocount
\endgroup}
- {\doifelseparwrapper{\v!word:\v!right}%
- {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}%
- \strut \removeunwantedspaces
- \hfill
- \allowbreak % changed back from \hskip\zeropoint
- \quad}%
- {\allowbreak % changed back from \hskip\zeropoint
- \break}%
- \unregisterparwrapper{\v!word:\v!right}%
- \strut
- \hfill
- \nobreak
- #2%
- \allowbreak}}
+ {\doifelseparwrapper{\v!word:\v!right}{\unregisterparwrapper{\v!word:\v!right}}\donothing
+ \removeunwantedspaces
+ \doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}%
+ \hfilll
+ \discretionary{\strut}{\strut}{\strut}% \allowbreak % changed back from \hskip\zeropoint
+ \hfilll
+ \quad % decent spacing
+ #2}}
% \dorecurse{5}{something} \wordright{--someone} \endgraf
% \dorecurse{6}{something} \wordright{--someone} \endgraf
diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl
index c9bed105f..278926582 100644
--- a/tex/context/base/mkxl/syst-aux.mkxl
+++ b/tex/context/base/mkxl/syst-aux.mkxl
@@ -3219,6 +3219,31 @@
#2\expandafter\doexpandedrecurse\expandafter{\the\numexpr#1-\plusone\relax}{#2}%
\fi}
+%D The next one might replace the above and provides the current step in \type {#1}
+%D like \type {\dorecurse} do, but it comes with a tiny performance hit.
+
+\installsystemnamespace{expandedrecurse}
+
+\mutable\let\m_expanded_recursed\gobbleoneargument
+
+\permanent\def\doexpandedrecursed#1#2% this might replace: \doexpandedrecurse
+ {\beginlocalcontrol
+ \localpushmacro\m_expanded_recursed
+ \def\m_expanded_recursed##1{#2}%
+ \endlocalcontrol
+ \syst_do_expanded_recursed{1}{#1}{#2}% no \plusone !
+ \beginlocalcontrol
+ \localpopmacro\m_expanded_recursed
+ \endlocalcontrol}
+
+\def\syst_do_expanded_recursed#1#2#3%
+ {\ifnum#1>#2\norelax
+ \expandafter\gobblethreearguments
+ \else
+ \m_expanded_recursed{#1}\doubleexpandafter\syst_do_expanded_recursed
+ \fi
+ {\the\numexpr#1+\plusone\relax}{#2}{#3}}
+
%D As we can see here, the simple command \type{\dorecurse} is a special case of the
%D more general:
%D