summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/core-con.lua104
-rw-r--r--tex/context/base/data-res.lua48
-rw-r--r--tex/context/base/data-tmp.lua2
-rw-r--r--tex/context/base/lxml-lpt.lua114
-rw-r--r--tex/context/base/page-ini.mkiv6
-rw-r--r--tex/context/base/strc-not.mkiv1
-rw-r--r--tex/context/base/strc-pag.mkiv9
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
10 files changed, 243 insertions, 47 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index d9f7d7281..93055b27a 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2009.12.22 13:15}
+\newcontextversion{2009.12.23 22:15}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index a5dd4eec6..962e1ef86 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2009.12.22 13:15}
+\edef\contextversion{2009.12.23 22:15}
%D For those who want to use this:
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index b8ca17387..cca386ee4 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -309,7 +309,7 @@ function converters.abjadnodotnumerals(n) return texsprint(converters.toabjad(n,
local vector = {
normal = {
- [0] = "○",
+ [0] = "〇",
[1] = "一",
[2] = "二",
[3] = "三",
@@ -343,7 +343,7 @@ local vector = {
[100000000] = "亿",
},
all = {
- [0] = "○",
+ [0] = "〇",
[1] = "一",
[2] = "二",
[3] = "三",
@@ -363,7 +363,63 @@ local vector = {
}
}
+--~ function tochinese(n,name) -- normal, caps, all
+--~ local result = { }
+--~ local vector = vector[name] or vector.normal
+--~ while true do
+--~ if n == 0 then
+--~ break
+--~ elseif n >= 100000000 then
+--~ local m = floor(n/100000000)
+--~ if m > 1 then result[#result+1] = tochinese(m) end
+--~ result[#result+1] = vector[100000000]
+--~ n = n % 100000000
+--~ elseif n >= 10000000 then
+--~ result[#result+1] = tochinese(floor(n/10000))
+--~ result[#result+1] = vector[10000]
+--~ n = n % 10000
+--~ elseif n >= 1000000 then
+--~ result[#result+1] = tochinese(floor(n/10000))
+--~ result[#result+1] = vector[10000]
+--~ n = n % 10000
+--~ elseif n >= 100000 then
+--~ result[#result+1] = tochinese(floor(n/10000))
+--~ result[#result+1] = vector[10000]
+--~ n = n % 10000
+--~ elseif n >= 10000 then
+--~ local m = floor(n/10000)
+--~ if m > 1 then result[#result+1] = vector[m] end
+--~ result[#result+1] = vector[10000]
+--~ n = n % 10000
+--~ elseif n >= 1000 then
+--~ local m = floor(n/1000)
+--~ if m > 1 then result[#result+1] = vector[m] end
+--~ result[#result+1] = vector[1000]
+--~ n = n % 1000
+--~ elseif n >= 100 then
+--~ local m = floor(n/100)
+--~ if m > 1 then result[#result+1] = vector[m] end
+--~ result[#result+1] = vector[100]
+--~ n = n % 100
+--~ elseif n >= 10 then
+--~ local m = floor(n/10)
+--~ if vector[m*10] then
+--~ result[#result+1] = vector[m*10]
+--~ else
+--~ result[#result+1] = vector[m]
+--~ result[#result+1] = vector[10]
+--~ end
+--~ n = n % 10
+--~ else
+--~ result[#result+1] = vector[n]
+--~ break
+--~ end
+--~ end
+--~ return concat(result)
+--~ end
+
function tochinese(n,name) -- normal, caps, all
+ -- improved version by Li Yanrui
local result = { }
local vector = vector[name] or vector.normal
while true do
@@ -371,39 +427,56 @@ function tochinese(n,name) -- normal, caps, all
break
elseif n >= 100000000 then
local m = floor(n/100000000)
- if m > 1 then result[#result+1] = tochinese(m) end
+ result[#result+1] = tochinese(m,name)
result[#result+1] = vector[100000000]
+ local z = n - m * 100000000
+ if z > 0 and z < 10000000 then result[#result+1] = vector[0] end
n = n % 100000000
elseif n >= 10000000 then
- result[#result+1] = tochinese(floor(n/10000))
+ local m = floor(n/10000)
+ result[#result+1] = tochinese(m,name)
result[#result+1] = vector[10000]
+ local z = n - m * 10000
+ if z > 0 and z < 1000 then result[#result+1] = vector[0] end
n = n % 10000
elseif n >= 1000000 then
- result[#result+1] = tochinese(floor(n/10000))
+ local m = floor(n/10000)
+ result[#result+1] = tochinese(m,name)
result[#result+1] = vector[10000]
+ local z = n - m * 10000
+ if z > 0 and z < 1000 then result[#result+1] = vector[0] end
n = n % 10000
elseif n >= 100000 then
- result[#result+1] = tochinese(floor(n/10000))
+ local m = floor(n/10000)
+ result[#result+1] = tochinese(m,name)
result[#result+1] = vector[10000]
+ local z = n - m * 10000
+ if z > 0 and z < 1000 then result[#result+1] = vector[0] end
n = n % 10000
- elseif n >= 10000 then
+ elseif n >= 10000 then
local m = floor(n/10000)
- if m > 1 then result[#result+1] = vector[m] end
+ result[#result+1] = vector[m]
result[#result+1] = vector[10000]
+ local z = n - m * 10000
+ if z > 0 and z < 1000 then result[#result+1] = vector[0] end
n = n % 10000
- elseif n >= 1000 then
+ elseif n >= 1000 then
local m = floor(n/1000)
- if m > 1 then result[#result+1] = vector[m] end
+ result[#result+1] = vector[m]
result[#result+1] = vector[1000]
+ local z = n - m * 1000
+ if z > 0 and z < 100 then result[#result+1] = vector[0] end
n = n % 1000
- elseif n >= 100 then
+ elseif n >= 100 then
local m = floor(n/100)
- if m > 1 then result[#result+1] = vector[m] end
+ result[#result+1] = vector[m]
result[#result+1] = vector[100]
+ local z = n - m * 100
+ if z > 0 and z < 10 then result[#result+1] = vector[0] end
n = n % 100
- elseif n >= 10 then
+ elseif n >= 10 then
local m = floor(n/10)
- if vector[m*10] then
+ if m > 1 and vector[m*10] then
result[#result+1] = vector[m*10]
else
result[#result+1] = vector[m]
@@ -415,6 +488,9 @@ function tochinese(n,name) -- normal, caps, all
break
end
end
+ if (result[1] == vector[1] and result[2] == vector[10]) then
+ result[1] = ""
+ end
return concat(result)
end
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index c7f360141..0299478ba 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -1418,7 +1418,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","using blobpath '%s'",fname)
+ logs.report("fileio","checking name '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -1434,7 +1434,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
+ logs.report("fileio","deep checking '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -1468,7 +1468,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
+ logs.report("fileio","no match in '%s' (%s)",blobpath,bname)
end
end
end
@@ -1682,7 +1682,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
else
-- list search
local filelist = collect_files(wantedfiles)
- local doscan, recurse
+ local dirlist = { }
+ if filelist then
+ for i=1,#filelist do
+ dirlist[i] = file.dirname(filelist[i][2]) .. "/"
+ end
+ end
+ local doscan
if trace_detail then
logs.report("fileio","checking filename '%s'",filename)
end
@@ -1690,28 +1696,42 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
for k=1,#pathlist do
local path = pathlist[k]
if find(path,"^!!") then doscan = false else doscan = true end
- if find(path,"//$") then recurse = true else recurse = false end
local pathname = gsub(path,"^!+", '')
done = false
-- using file list
- if filelist and not (done and not instance.allresults) and recurse then
- -- compare list entries with permitted pattern
+ if filelist then
+ -- compare list entries with permitted pattern -- /xx /xx//
+ if not find(pathname,"/$") then
+ pathname = pathname .. "/"
+ end
pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences
- pathname = gsub(pathname,"/+$", '/.*') -- later usage of pathname
+ pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname
pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless
- local expr = "^" .. pathname
+ local expr = "^" .. pathname .. "$"
+ if trace_detail then
+ logs.report("fileio","using pattern %s for path %s",expr,path)
+ end
for k=1,#filelist do
local fl = filelist[k]
local f = fl[2]
- if find(f,expr) then
- if trace_detail then
- logs.report("fileio","file '%s' found in hash",f)
- end
+ local d = dirlist[k]
+ if find(d,expr) then
--- todo, test for readable
result[#result+1] = fl[3]
resolvers.register_in_trees(f) -- for tracing used files
done = true
- if not instance.allresults then break end
+ if instance.allresults then
+ if trace_detail then
+ logs.report("fileio","match in hash for file '%s' on path '%s', continue scanning",f,d)
+ end
+ else
+ if trace_detail then
+ logs.report("fileio","match in hash for file '%s' on path '%s', quit scanning",f,d)
+ end
+ break
+ end
+ elseif trace_detail then
+ logs.report("fileio","no match in hash for file '%s' on path '%s'",f,d)
end
end
end
diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua
index ba338b5a4..88e5d1e3b 100644
--- a/tex/context/base/data-tmp.lua
+++ b/tex/context/base/data-tmp.lua
@@ -24,7 +24,7 @@ luatools with a recache feature.</p>
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
+local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end) -- not used yet
caches = caches or { }
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index 406d00c05..936288d34 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -12,6 +12,9 @@ local concat, remove, insert = table.concat, table.remove, table.insert
local type, next, tonumber, tostring, setmetatable, loadstring = type, next, tonumber, tostring, setmetatable, loadstring
local format, upper, lower, gmatch, gsub, find, rep = string.format, string.upper, string.lower, string.gmatch, string.gsub, string.find, string.rep
+-- beware, this is not xpath ... e.g. position is different (currently) and
+-- we have reverse-sibling as reversed preceding sibling
+
--[[ldx--
<p>This module can be used stand alone but also inside <l n='mkiv'/> in
which case it hooks into the tracker code. Therefore we provide a few
@@ -239,24 +242,92 @@ apply_axis['attribute'] = function(list)
return { }
end
-apply_axis['following'] = function(list)
+apply_axis['namespace'] = function(list)
return { }
end
-apply_axis['following-sibling'] = function(list)
+apply_axis['following'] = function(list) -- incomplete
+--~ local collected = { }
+--~ for l=1,#list do
+--~ local ll = list[l]
+--~ local p = ll.__p__
+--~ local d = p.dt
+--~ for i=ll.ni+1,#d do
+--~ local di = d[i]
+--~ if type(di) == "table" then
+--~ collected[#collected+1] = di
+--~ break
+--~ end
+--~ end
+--~ end
+--~ return collected
return { }
end
-apply_axis['namespace'] = function(list)
+apply_axis['preceding'] = function(list) -- incomplete
+--~ local collected = { }
+--~ for l=1,#list do
+--~ local ll = list[l]
+--~ local p = ll.__p__
+--~ local d = p.dt
+--~ for i=ll.ni-1,1,-1 do
+--~ local di = d[i]
+--~ if type(di) == "table" then
+--~ collected[#collected+1] = di
+--~ break
+--~ end
+--~ end
+--~ end
+--~ return collected
return { }
end
-apply_axis['preceding'] = function(list)
- return { }
+apply_axis['following-sibling'] = function(list)
+ local collected = { }
+ for l=1,#list do
+ local ll = list[l]
+ local p = ll.__p__
+ local d = p.dt
+ for i=ll.ni+1,#d do
+ local di = d[i]
+ if type(di) == "table" then
+ collected[#collected+1] = di
+ end
+ end
+ end
+ return collected
end
apply_axis['preceding-sibling'] = function(list)
- return { }
+ local collected = { }
+ for l=1,#list do
+ local ll = list[l]
+ local p = ll.__p__
+ local d = p.dt
+ for i=1,ll.ni-1 do
+ local di = d[i]
+ if type(di) == "table" then
+ collected[#collected+1] = di
+ end
+ end
+ end
+ return collected
+end
+
+apply_axis['reverse-sibling'] = function(list) -- reverse preceding
+ local collected = { }
+ for l=1,#list do
+ local ll = list[l]
+ local p = ll.__p__
+ local d = p.dt
+ for i=ll.ni-1,1,-1 do
+ local di = d[i]
+ if type(di) == "table" then
+ collected[#collected+1] = di
+ end
+ end
+ end
+ return collected
end
apply_axis['auto-descendant-or-self'] = apply_axis['descendant-or-self']
@@ -362,13 +433,19 @@ local function apply_nodes(list,directive,nodes)
end
end
+local quit_expression = false
+
local function apply_expression(list,expression,order)
local collected = { }
+ quit_expression = false
for l=1,#list do
local ll = list[l]
if expression(list,ll,l,order) then -- nasty, alleen valid als n=1
collected[#collected+1] = ll
end
+ if quit_expression then
+ break
+ end
end
return collected
end
@@ -392,7 +469,8 @@ local lp_builtin = P (
P("index") / "(ll.ni or 1)" +
P("match") / "(ll.mi or 1)" +
P("text") / "(ll.dt[1] or '')" +
- P("name") / "(ll.ns~='' and ll.ns..':'..ll.tg)" +
+--~ P("name") / "(ll.ns~='' and ll.ns..':'..ll.tg)" +
+ P("name") / "((ll.ns~='' and ll.ns..':'..ll.tg) or ll.tg)" +
P("tag") / "ll.tg" +
P("ns") / "ll.ns"
) * ((spaces * P("(") * spaces * P(")"))/"")
@@ -422,6 +500,7 @@ local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent}
local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"}
local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')")
+local lp_number = S("+-") * R("09")^1
local lp_string = Cc("'") * R("az","AZ","--","__")^1 * Cc("'")
local lp_content = (P("'") * (1-P("'"))^0 * P("'") + P('"') * (1-P('"'))^0 * P('"'))
@@ -430,6 +509,7 @@ local cleaner
local lp_special = (C(P("name")+P("text")+P("tag")+P("count")+P("child"))) * value / function(t,s)
if expressions[t] then
s = s and s ~= "" and cleaner:match(s)
+--~ print("!!!",t,s)
if s and s ~= "" then
return "expr." .. t .. "(ll," .. s ..")"
else
@@ -459,9 +539,11 @@ local converter = Cs (
cleaner = Cs ( (
--~ lp_fastpos +
lp_reserved +
+ lp_number +
lp_string +
1 )^1 )
+
--~ expr
local template_e = [[
@@ -544,6 +626,7 @@ local register_following = { kind = "axis", axis = "following"
local register_following_sibling = { kind = "axis", axis = "following-sibling" } -- , apply = apply_axis["following-sibling"] }
local register_preceding = { kind = "axis", axis = "preceding" } -- , apply = apply_axis["preceding"] }
local register_preceding_sibling = { kind = "axis", axis = "preceding-sibling" } -- , apply = apply_axis["preceding-sibling"] }
+local register_reverse_sibling = { kind = "axis", axis = "reverse-sibling" } -- , apply = apply_axis["reverse-sibling"] }
local register_auto_descendant_or_self = { kind = "axis", axis = "auto-descendant-or-self" } -- , apply = apply_axis["auto-descendant-or-self"] }
local register_auto_descendant = { kind = "axis", axis = "auto-descendant" } -- , apply = apply_axis["auto-descendant"] }
@@ -570,8 +653,8 @@ local parser = Ct { "patterns", -- can be made a bit faster by moving pattern ou
step = ((V("shortcuts") + P("/") + V("axis")) * spaces * V("nodes")^0 + V("error")) * spaces * V("expressions")^0 * spaces * V("finalizer")^0,
axis = V("descendant") + V("child") + V("parent") + V("self") + V("root") + V("ancestor") +
- V("descendant_or_self") + V("following") + V("following_sibling") +
- V("preceding") + V("preceding_sibling") + V("ancestor_or_self") +
+ V("descendant_or_self") + V("following_sibling") + V("following") +
+ V("reverse_sibling") + V("preceding_sibling") + V("preceding") + V("ancestor_or_self") +
#(1-P(-1)) * Cc(register_auto_child),
initial = (P("/") * spaces * Cc(register_initial_child))^-1,
@@ -605,6 +688,7 @@ local parser = Ct { "patterns", -- can be made a bit faster by moving pattern ou
following_sibling = P('following-sibling::') * Cc(register_following_sibling ),
preceding = P('preceding::') * Cc(register_preceding ),
preceding_sibling = P('preceding-sibling::') * Cc(register_preceding_sibling ),
+ reverse_sibling = P('reverse-sibling::') * Cc(register_reverse_sibling ),
nodes = (V("nodefunction") * spaces * P("(") * V("nodeset") * P(")") + V("nodetest") * V("nodeset")) / register_nodes,
@@ -869,6 +953,18 @@ expressions.undefined = function(s)
return s == nil
end
+expressions.quit = function(s)
+ if s or s == nil then
+ quit_expression = true
+ end
+ return true
+end
+
+expressions.print = function(...)
+ print(...)
+ return true
+end
+
expressions.contains = find
expressions.find = find
expressions.upper = upper
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 476acfd1e..fae7611ac 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -523,7 +523,6 @@
{\forgetall
\beforefinaloutput
\the\everybeforeshipout
- \setpagecounters
\message{[-\the\realpageno]}%
\setbox\scratchbox\hbox{\dopagebody#1#2}%
\deadcycles\zerocount
@@ -551,6 +550,7 @@
\fi#1#2%
\resetselectiepagina
\incrementpagenumber
+ \incrementsubpagenumber
\checkpagedimensions
\ifnum\outputpenalty>\superpenalty \else
\dosupereject
@@ -883,9 +883,9 @@
{%\getallmarks % now in following token register
\the\everybeforepagebody
\starttextproperties
- \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak)
+% \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak)
\dontshowboxes % dan hier blokkeren en verderop resetten
-% \shipoutfacingpage
+% \shipoutfacingpage
\checkmargeblokken
\the\beforeeverypage
\normalexpanded{\global\beforepage\emptytoks\the\beforepage}% \scratchtoks\beforepage\global\beforepage\emptytoks\the\scratchtoks % was \flushtoks\beforepage
diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv
index 4c3fd2f22..09cf523ec 100644
--- a/tex/context/base/strc-not.mkiv
+++ b/tex/context/base/strc-not.mkiv
@@ -641,6 +641,7 @@
\edef\currentnote{#1}%
\edef\currentdescriptionnumberentry{#2}%
% \let\currentenumerationfullnumber\currentnoteenumerationfullnumber
+ \dontcomplain % should be done in startstoreddescription instead
\dostartstoreddescription\begstrut\currentnotedescriptiontext\endstrut\dostopstoreddescription}
\def\dostartstoreddescription
diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv
index 4bcee80ea..c7cc701af 100644
--- a/tex/context/base/strc-pag.mkiv
+++ b/tex/context/base/strc-pag.mkiv
@@ -256,10 +256,13 @@
\def\setnextrealpageno{\global\realpageno\incrementedstructurecounter[\s!realpage]\relax}
\def\setnextsubpageno {\global\subpageno \incrementedstructurecounter[\s!subpage ]\relax}
-% Page numbers:
+% Page numbers: (can move to lua)
-\def\dodecrementpagenumber{\global\userpageno\decrementedstructurecounter[\s!userpage]\relax}
-\def\doincrementpagenumber{\global\userpageno\incrementedstructurecounter[\s!userpage]\relax}
+\def\dodecrementpagenumber {\global\userpageno\decrementedstructurecounter[\s!userpage]\relax}
+\def\doincrementpagenumber {\global\userpageno\incrementedstructurecounter[\s!userpage]\relax}
+
+\def\decrementsubpagenumber{\global\subpageno \decrementedstructurecounter[\s!subpage ]\relax}
+\def\incrementsubpagenumber{\global\subpageno \incrementedstructurecounter[\s!subpage ]\relax}
\def\dosynchronizepagenumber{\global\let\@@pnstate\v!start}
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 52c46884c..652bc7473 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 12/22/09 13:19:25
+-- merge date : 12/23/09 22:18:55
do -- begin closure to overcome local limits and interference