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/enco-ini.mkiv2
-rw-r--r--tex/context/base/grph-inc.lua18
-rw-r--r--tex/context/base/grph-inc.mkiv4
-rw-r--r--tex/context/base/grph-trf.mkiv13
-rw-r--r--tex/context/base/lxml-aux.lua74
-rw-r--r--tex/context/base/lxml-ini.mkiv3
-rw-r--r--tex/context/base/lxml-lpt.lua68
-rw-r--r--tex/context/base/lxml-tex.lua4
-rw-r--r--tex/context/base/mult-ini.lua4
-rw-r--r--tex/context/base/page-lay.mkiv2
-rw-r--r--tex/context/base/strc-bkm.lua18
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
14 files changed, 166 insertions, 50 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 79fe0c555..dd1051d0a 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{2010.04.23 18:34}
+\newcontextversion{2010.04.25 15:55}
%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 188ff748e..8d8c45910 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{2010.04.23 18:34}
+\edef\contextversion{2010.04.25 15:55}
%D For those who want to use this:
diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv
index 495767389..42730ed26 100644
--- a/tex/context/base/enco-ini.mkiv
+++ b/tex/context/base/enco-ini.mkiv
@@ -335,6 +335,8 @@
\fallbackcontrolspace
\fi}
+\let\textvisiblespace\normalcontrolspace
+
\unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped)
{\dofastcontrolspace}
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 507235545..d6a4b1bd6 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -671,23 +671,29 @@ end
function figures.done(data)
figures.n = figures.n + 1
data = data or figures.current()
+--~ print(table.serialize(figures.current()))
local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber
- local box = tex.box[nr]
+ local box = texbox[nr]
ds.width = box.width
ds.height = box.height
ds.xscale = ds.width /(du.width or 1)
ds.yscale = ds.height/(du.height or 1)
+--~ print(table.serialize(figures.current()))
return data
end
function figures.dummy(data)
data = data or figures.current()
local dr, du, ds, nr = data.request, data.used, data.status, figures.boxnumber
- local box = node.new("hlist")
- box.width = du.width or figures.defaultwidth
- box.height = du.height or figures.defaultheight
- box.depth = du.depth or figures.defaultdepth
- texbox[nr] = box
+ local box = node.hpack(node.new("hlist")) -- we need to set the dir (luatex 0.60 buglet)
+ du.width = du.width or figures.defaultwidth
+ du.height = du.height or figures.defaultheight
+ du.depth = du.depth or figures.defaultdepth
+ -- box.dir = "TLT"
+ box.width = du.width
+ box.height = du.height
+ box.depth = du.depth
+ texbox[nr] = box -- hm, should be global (to be checked for consistency)
end
-- -- -- generic -- -- --
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index 1fc9656a9..079015a47 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -103,7 +103,7 @@
\let\figurescaleyscale \figureyscale
\appendtoks
- \ctxlua {
+ \ctxlua { % figures.defaultwidth .. why not dimen
figures.setpaths("\@@exlocation","\@@exdirectory") ;
figures.defaultwidth = \number\dimexpr\defaultfigurewidth \relax ;
figures.defaultheight = \number\dimexpr\defaultfigureheight\relax ;
@@ -286,7 +286,7 @@
\global\setsystemmode \v!figure % todo, also: \v!resource
\fi}
-\def\startfoundexternalfigure#1#2%
+\def\startfoundexternalfigure#1#2% ht wd
{\global\setbox\foundexternalfigure\vbox to #2\bgroup\vss\hbox to #1\bgroup}
\def\stopfoundexternalfigure
diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv
index 191dc254a..2066f7b2f 100644
--- a/tex/context/base/grph-trf.mkiv
+++ b/tex/context/base/grph-trf.mkiv
@@ -115,6 +115,7 @@
\global\let\finalscaleboxxfactor\!!hundred
\global\let\finalscaleboxyfactor\!!hundred
\ifdim\nextboxht>\zeropoint \ifdim\nextboxwd>\zeropoint
+ % hm, still useful? better in lua anyway
\edef\scaleboxstampa % slow way [can be combined]
{\scaleparameter\c!scale \scaleparameter\c!xscale \scaleparameter\c!yscale
\scaleparameter\c!factor\scaleparameter\c!wfactor\scaleparameter\c!hfactor
@@ -128,10 +129,10 @@
\ifx\scaleboxstampb\scaleboxstampc
% no scaling, but still check; new, gone again
% wrong: scaled proportionally as side effect
-% \doifsomething{\scaleparameter\c!maxwidth }{\letvalue{\currentscaletag\c!factor}\v!fit}%
-% \doifsomething{\scaleparameter\c!maxheight}{\letvalue{\currentscaletag\c!factor}\v!fit}%
- \insidefloattrue % trick
- \dodoscaleboxcalculations
+% \doifsomething{\scaleparameter\c!maxwidth }{\letvalue{\currentscaletag\c!factor}\v!fit}%
+% \doifsomething{\scaleparameter\c!maxheight}{\letvalue{\currentscaletag\c!factor}\v!fit}%
+ \insidefloattrue % trick
+ \dodoscaleboxcalculations
\else
\dosetscalboxsxsy
\nodoscaleboxcalculations
@@ -202,7 +203,6 @@
\xdef\finalscaleboxxscale {\withoutpt\the\dimexpr\scax\points/\plushundred\relax}%
\xdef\finalscaleboxyscale {\withoutpt\the\dimexpr\scay\points/\plushundred\relax}}
-
\setvalue{\??xy:\c!grid:\v!yes }{\getnoflines \fighei\setevalue{\currentscaletag\c!height}{\the\noflines\lineheight}}
\setvalue{\??xy:\c!grid:\v!height }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight+\strutdepth\relax}}
\setvalue{\??xy:\c!grid:\v!depth }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight-\strutdepth\relax}}
@@ -374,8 +374,7 @@
\else % hm, there should be an option to force this
\ifdim\pagegoal<\maxdimen
\ifdim\pagetotal<\pagegoal
- \scratchdimen\pagegoal
- \advance\scratchdimen -\pagetotal
+ \scratchdimen\dimexpr\pagegoal-\pagetotal\relax
\else
\scratchdimen\scaleboxoutervsize % \textheight
\fi
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index 6b92143e7..00f791909 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -382,7 +382,7 @@ function xml.strip_whitespace(root, pattern, nolines) -- strips all leading and
end
end
else
---~ str.ni = i
+ --~ str.ni = i
t[#t+1] = str
end
end
@@ -392,6 +392,78 @@ function xml.strip_whitespace(root, pattern, nolines) -- strips all leading and
end
end
+function xml.strip_whitespace(root, pattern, nolines, anywhere) -- strips all leading and trailing spacing
+ local collected = xmlparseapply({ root },pattern) -- beware, indices no longer are valid now
+ if collected then
+ for i=1,#collected do
+ local e = collected[i]
+ local edt = e.dt
+ if edt then
+ if anywhere then
+ local t = { }
+ for e=1,#edt do
+ local str = edt[e]
+ if type(str) ~= "string" then
+ t[#t+1] = str
+ elseif str ~= "" then
+ -- todo: lpeg for each case
+ if nolines then
+ str = gsub(str,"%s+"," ")
+ end
+ str = gsub(str,"^%s*(.-)%s*$","%1")
+ if str ~= "" then
+ t[#t+1] = str
+ end
+ end
+ end
+ e.dt = t
+ else
+ -- we can assume a regular sparse xml table with no successive strings
+ -- otherwise we should use a while loop
+ if #edt > 0 then
+ -- strip front
+ local str = edt[1]
+ if type(str) ~= "string" then
+ -- nothing
+ elseif str == "" then
+ remove(edt,1)
+ else
+ if nolines then
+ str = gsub(str,"%s+"," ")
+ end
+ str = gsub(str,"^%s+","")
+ if str == "" then
+ remove(edt,1)
+ else
+ edt[1] = str
+ end
+ end
+ end
+ if #edt > 1 then
+ -- strip end
+ local str = edt[#edt]
+ if type(str) ~= "string" then
+ -- nothing
+ elseif str == "" then
+ remove(edt)
+ else
+ if nolines then
+ str = gsub(str,"%s+"," ")
+ end
+ str = gsub(str,"%s+$","")
+ if str == "" then
+ remove(edt)
+ else
+ edt[#edt] = str
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
local function rename_space(root, oldspace, newspace) -- fast variant
local ndt = #root.dt
for i=1,ndt or 0 do
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index d2520d974..b0fc39680 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -74,8 +74,9 @@
\def\xmlsetfunction #1#2#3{\ctxlua{lxml.setaction("#1","#2",#3)}}
\def\xmlsetsetup #1#2#3{\ctxlua{lxml.setsetup("#1","#2","#3")}}
\def\xmlstrip #1#2{\ctxlua{lxml.strip("#1","#2")}}
-\def\xmlstripped #1#2{\ctxlua{lxml.stripped("#1","#2")}}
\def\xmlstripnolines #1#2{\ctxlua{lxml.strip("#1","#2",true)}}
+\def\xmlstripanywhere #1#2{\ctxlua{lxml.strip("#1","#2",true,true)}}
+\def\xmlstripped #1#2{\ctxlua{lxml.stripped("#1","#2")}}
\def\xmlstrippednolines #1#2{\ctxlua{lxml.stripped("#1","#2",true)}}
\def\xmltag #1{\ctxlua{lxml.tag("#1")}}
\def\xmltext #1#2{\ctxlua{lxml.text("#1","#2")}}
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index 883b174db..bddbe4868 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -143,17 +143,17 @@ apply_axis['child'] = function(list)
for l=1,#list do
local ll = list[l]
local dt = ll.dt
-local en = 0
+ local en = 0
for k=1,#dt do
local dk = dt[k]
if dk.tg then
collected[#collected+1] = dk
dk.ni = k -- refresh
-en = en + 1
-dk.ei = en
+ en = en + 1
+ dk.ei = en
end
end
-ll.en = en
+ ll.en = en
end
return collected
end
@@ -161,18 +161,18 @@ end
local function collect(list,collected)
local dt = list.dt
if dt then
-local en = 0
+ local en = 0
for k=1,#dt do
local dk = dt[k]
if dk.tg then
collected[#collected+1] = dk
dk.ni = k -- refresh
-en = en + 1
-dk.ei = en
+ en = en + 1
+ dk.ei = en
collect(dk,collected)
end
end
-list.en = en
+ list.en = en
end
end
apply_axis['descendant'] = function(list)
@@ -186,18 +186,18 @@ end
local function collect(list,collected)
local dt = list.dt
if dt then
-local en = 0
+ local en = 0
for k=1,#dt do
local dk = dt[k]
if dk.tg then
collected[#collected+1] = dk
dk.ni = k -- refresh
-en = en + 1
-dk.ei = en
+ en = en + 1
+ dk.ei = en
collect(dk,collected)
end
end
-list.en = en
+ list.en = en
end
end
apply_axis['descendant-or-self'] = function(list)
@@ -834,17 +834,17 @@ parse_pattern = function (pattern) -- the gain of caching is rather minimal
add_comment(parsed, "initial-child removed") -- we could also make it a auto-self
remove(parsed,1)
end
-local np = #parsed -- can have changed
-if np > 1 then
- local pnp = parsed[np]
- if pnp.kind == "nodes" and pnp.nodetest == true then
- local nodes = pnp.nodes
- if nodes[1] == true and nodes[2] == false and nodes[3] == false then
- add_comment(parsed, "redundant final wildcard filter removed")
- remove(parsed,np)
- end
- end
-end
+ local np = #parsed -- can have changed
+ if np > 1 then
+ local pnp = parsed[np]
+ if pnp.kind == "nodes" and pnp.nodetest == true then
+ local nodes = pnp.nodes
+ if nodes[1] == true and nodes[2] == false and nodes[3] == false then
+ add_comment(parsed, "redundant final wildcard filter removed")
+ remove(parsed,np)
+ end
+ end
+ end
end
else
parsed = { pattern = pattern }
@@ -870,6 +870,10 @@ end
-- caching found lookups saves not that much (max .1 sec on a 8 sec run)
-- and it also messes up finalizers
+-- watch out: when there is a finalizer, it's always called as there
+-- can be cases that a finalizer returns (or does) something in case
+-- there is no match; an example of this is count()
+
local profiled = { } xml.profiled = profiled
local function profiled_apply(list,parsed,nofparsed,order)
@@ -897,6 +901,12 @@ local function profiled_apply(list,parsed,nofparsed,order)
return collected
end
if not collected or #collected == 0 then
+ local pn = i < nofparsed and parsed[nofparsed]
+ if pn and pn.kind == "finalizer" then
+ collected = pn.finalizer(collected)
+ p.finalized = p.finalized + 1
+ return collected
+ end
return nil
end
end
@@ -928,10 +938,16 @@ local function traced_apply(list,parsed,nofparsed,order)
logs.report("lpath", "% 10i : ex : %s -> %s",(collected and #collected) or 0,pi.expression,pi.converted)
elseif kind == "finalizer" then
collected = pi.finalizer(collected)
- logs.report("lpath", "% 10i : fi : %s : %s(%s)",(collected and #collected) or 0,parsed.protocol or xml.defaultprotocol,pi.name,pi.arguments or "")
+ logs.report("lpath", "% 10i : fi : %s : %s(%s)",(type(collected) == "table" and #collected) or 0,parsed.protocol or xml.defaultprotocol,pi.name,pi.arguments or "")
return collected
end
if not collected or #collected == 0 then
+ local pn = i < nofparsed and parsed[nofparsed]
+ if pn and pn.kind == "finalizer" then
+ collected = pn.finalizer(collected)
+ logs.report("lpath", "% 10i : fi : %s : %s(%s)",(type(collected) == "table" and #collected) or 0,parsed.protocol or xml.defaultprotocol,pn.name,pn.arguments or "")
+ return collected
+ end
return nil
end
end
@@ -956,6 +972,10 @@ local function normal_apply(list,parsed,nofparsed,order)
return pi.finalizer(collected)
end
if not collected or #collected == 0 then
+ local pf = i < nofparsed and parsed[nofparsed].finalizer
+ if pf then
+ return pf(collected) -- can be anything
+ end
return nil
end
end
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index a41502e1b..fb41b1c28 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -1371,8 +1371,8 @@ function lxml.nonspace(id,pattern) -- slow, todo loop
xmltprint(xmlcollect(get_id(id),pattern,true))
end
-function lxml.strip(id,pattern,nolines)
- xml.strip(get_id(id),pattern,nolines)
+function lxml.strip(id,pattern,nolines,anywhere)
+ xml.strip(get_id(id),pattern,nolines,anywhere)
end
function lxml.stripped(id,pattern,nolines)
diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua
index d876e98b5..92a7bc629 100644
--- a/tex/context/base/mult-ini.lua
+++ b/tex/context/base/mult-ini.lua
@@ -99,3 +99,7 @@ function interfaces.cachesetup(t)
return t
end
end
+
+function interfaces.is_command(str)
+ return (str and str ~= "" and token.csname_name(token.create(str)) ~= "") or false
+end
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 4953f2063..dd118b5dc 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -715,7 +715,7 @@
\fi}
\def\adaptpagedimensionsindeed
- {\rawdoifinsetelse\realfolio\adaptedpages
+ {\rawdoifinset\realfolio\adaptedpages
{\removefromcommalist\realfolio\adaptedpages
\getvalue{\??za\realfolio}%
\letbeundefined{\??za\realfolio}}}
diff --git a/tex/context/base/strc-bkm.lua b/tex/context/base/strc-bkm.lua
index 286169153..e25f55fa8 100644
--- a/tex/context/base/strc-bkm.lua
+++ b/tex/context/base/strc-bkm.lua
@@ -59,21 +59,33 @@ local function stripped(str) -- kind of generic
return str
end
+-- todo: collect specs and collect later i.e. multiple places
+
function bookmarks.place()
if names ~= "" then
local list = lists.filter(names,"all",nil,lists.collected)
+ local lastlevel = 1
if #list > 0 then
local opened, levels = aux.settings_to_set(opened), { }
for i=1,#list do
local li = list[i]
local metadata = li.metadata
local name = metadata.name
- if not metadata.nolist and levelmap[name] then
+ if not metadata.nolist then -- and levelmap[name] then
local titledata = li.titledata
if titledata then
+ local structural = levelmap[name]
+ lastlevel = structural or lastlevel
+ local title = titledata.bookmark
+ if (not title or title == "") and not structural then
+ -- placeholder, todo: bookmarklabel
+ title = name .. ": " .. (titledata.title or "?")
+ else
+ title = titledata.title or "?"
+ end
levels[#levels+1] = {
- levelmap[name],
- stripped(titledata.bookmark or titledata.title or "?"),
+ lastlevel,
+ stripped(title),
li.references, -- has internal and realpage
allopen or opened[name]
}
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index c1f4fc457..3fecdb88c 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 04/23/10 18:34:16
+-- merge date : 04/25/10 15:55:41
do -- begin closure to overcome local limits and interference