summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-12-11 13:15:03 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-12-11 13:15:03 +0100
commit36be5943fa71b0543ccea4a771c4cea9361cfcc2 (patch)
tree22547577c3d08e85dac07d6ed35d8e1f398b4418 /tex
parent561708843a2c7fd2d69186fe22fdec99908a64d9 (diff)
downloadcontext-36be5943fa71b0543ccea4a771c4cea9361cfcc2.tar.gz
2014-12-11 12:04:00
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4382 -> 4387 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/l-string.lua2
-rw-r--r--tex/context/base/lxml-aux.lua92
-rw-r--r--tex/context/base/meta-imp-txt.mkiv7
-rw-r--r--tex/context/base/publ-fnd.lua3
-rw-r--r--tex/context/base/status-files.pdfbin24649 -> 24632 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin344691 -> 344758 bytes
-rw-r--r--tex/context/base/strc-lst.lua13
-rw-r--r--tex/context/base/strc-ref.lua104
-rw-r--r--tex/context/base/strc-ref.mkvi28
-rw-r--r--tex/context/base/util-str.lua4
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua5
14 files changed, 247 insertions, 15 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 6cfda56fe..303fef490 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2014.12.10 22:40}
+\newcontextversion{2014.12.11 12:02}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index ff58c610c..750551066 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 45a1ee1ba..8b075404f 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2014.12.10 22:40}
+\edef\contextversion{2014.12.11 12:02}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/l-string.lua b/tex/context/base/l-string.lua
index 3b1a0003f..70c66f661 100644
--- a/tex/context/base/l-string.lua
+++ b/tex/context/base/l-string.lua
@@ -94,7 +94,7 @@ end
-- return not find(str,"%S")
-- end
-local pattern = P(" ")^0 * P(-1)
+local pattern = P(" ")^0 * P(-1) -- maybe also newlines
-- patterns.onlyspaces = pattern
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index 2b35c909c..19c5968b7 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -21,10 +21,12 @@ local xmlinheritedconvert = xml.inheritedconvert
local xmlapplylpath = xml.applylpath
local xmlfilter = xml.filter
-local type, setmetatable, getmetatable = type, setmetatable, getmetatable
+local type, next, setmetatable, getmetatable = type, next, setmetatable, getmetatable
local insert, remove, fastcopy, concat = table.insert, table.remove, table.fastcopy, table.concat
local gmatch, gsub, format, find, strip = string.gmatch, string.gsub, string.format, string.find, string.strip
local utfbyte = utf.byte
+local lpegmatch = lpeg.match
+local striplinepatterns = utilities.strings.striplinepatterns
local function report(what,pattern,c,e)
report_xml("%s element %a, root %a, position %a, index %a, pattern %a",what,xmlname(e),xmlname(e.__p__),c,e.ni,pattern)
@@ -891,3 +893,91 @@ function helpers.recursetext(collected,action,recursive)
end
end
end
+
+-- on request ... undocumented ...
+--
+-- _tag : element name
+-- _type : node type (_element can be an option)
+-- _namespace : only if given
+--
+-- [1..n] : text or table
+-- key : value or attribite 'key'
+--
+-- local str = [[
+-- <?xml version="1.0" ?>
+-- <a one="1">
+-- <!-- rubish -->
+-- <b two="1"/>
+-- <b two="2">
+-- c &gt; d
+-- </b>
+-- </a>
+-- ]]
+--
+-- inspect(xml.totable(xml.convert(str)))
+-- inspect(xml.totable(xml.convert(str),true))
+-- inspect(xml.totable(xml.convert(str),true,true))
+
+local specials = {
+ ["@rt@"] = "root",
+ ["@pi@"] = "instruction",
+ ["@cm@"] = "comment",
+ ["@dt@"] = "declaration",
+ ["@cd@"] = "cdata",
+}
+
+local function convert(x,strip,flat)
+ local ns = x.ns
+ local tg = x.tg
+ local at = x.at
+ local dt = x.dt
+ local node = flat and {
+ [0] = (not x.special and (ns ~= "" and ns .. ":" .. tg or tg)) or nil,
+ } or {
+ _namespace = ns ~= "" and ns or nil,
+ _tag = not x.special and tg or nil,
+ _type = specials[tg] or "_element",
+ }
+ if at then
+ for k, v in next, at do
+ node[k] = v
+ end
+ end
+ local n = 0
+ for i=1,#dt do
+ local di = dt[i]
+ if type(di) == "table" then
+ if flat and di.special then
+ -- ignore
+ else
+ di = convert(di,strip,flat)
+ if di then
+ n = n + 1
+ node[n] = di
+ end
+ end
+ elseif strip then
+ di = lpegmatch(strip,di)
+ if di ~= "" then
+ n = n + 1
+ node[n] = di
+ end
+ else
+ n = n + 1
+ node[n] = di
+ end
+ end
+ if next(node) then
+ return node
+ end
+end
+
+function xml.totable(x,strip,flat)
+ if type(x) == "table" then
+ if strip then
+ strip = striplinepatterns[strip]
+ end
+ return convert(x,strip,flat)
+ end
+end
+
diff --git a/tex/context/base/meta-imp-txt.mkiv b/tex/context/base/meta-imp-txt.mkiv
index bcfc5513f..9687f6cd4 100644
--- a/tex/context/base/meta-imp-txt.mkiv
+++ b/tex/context/base/meta-imp-txt.mkiv
@@ -152,7 +152,7 @@
%%%%%%% rotfont nog definieren
-\doifundefined{RotFont}{\definefont[RotFont][RegularBold]}
+\doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]}
\unexpanded\def\processfollowingtoken#1% strut toegevoegd
{\appendtoks#1\to\MPtoks
@@ -174,9 +174,7 @@
{\vbox\bgroup
\forgetall
\dontcomplain
- \startMPenvironment
- \doifundefined{RotFont}{\definefont[RotFont][RegularBold]}%
- \stopMPenvironment
+ \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]}%
\MPtoks\emptytoks
\resetMPdrawing
\startMPdrawing
@@ -225,6 +223,7 @@
withpen pencircle scaled .50pt withcolor green ;
fi ;
endfor ;
+% fill boundingbox currentpicture ;
\stopMPdrawing
\MPdrawingdonetrue
\getMPdrawing
diff --git a/tex/context/base/publ-fnd.lua b/tex/context/base/publ-fnd.lua
index 5308302cb..780ce039e 100644
--- a/tex/context/base/publ-fnd.lua
+++ b/tex/context/base/publ-fnd.lua
@@ -19,7 +19,6 @@ local publications = publications
local tonumber, next, type = tonumber, next, type
local find = string.find
-local lower = characters.lower
local P, R, C, Cs, Cp, Cc, Carg = lpeg.P, lpeg.R, lpeg.C, lpeg.Cs, lpeg.Cp, lpeg.Cc, lpeg.Carg
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
local concat = table.concat
@@ -111,7 +110,7 @@ local pattern = Cs(Cc("(") * (P("match")/"" * space^0 * p_match)^1 * Cc(")"))
function publications.anywhere(entry,str) -- helpers
for k, v in next, entry do
- if find(lower(v),str) then
+ if find(lowercase(v),str) then
return true
end
end
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index be673253e..2444449e2 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 23ff2dbab..7612df67e 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index c7fbf51b7..f3fd9867d 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -45,6 +45,8 @@ local collected = allocate()
local tobesaved = allocate()
local cached = allocate()
local pushed = allocate()
+local kinds = allocate()
+local names = allocate()
lists.collected = collected
lists.tobesaved = tobesaved
@@ -54,6 +56,8 @@ lists.enhancers = lists.enhancers or { }
lists.ordered = allocate(lists.ordered or { }) -- to be checked
lists.cached = cached
lists.pushed = pushed
+lists.kinds = kinds
+lists.names = names
local sectionblocks = allocate()
lists.sectionblocks = sectionblocks
@@ -129,7 +133,8 @@ local function initializer()
end
end
-- access by order in list
- local kind, name = m.kind, m.name
+ local kind = m.kind
+ local name = m.name
if kind and name then
local ok = ordered[kind]
if ok then
@@ -142,6 +147,12 @@ local function initializer()
else
ordered[kind] = { [name] = { c } }
end
+ kinds[kind] = true
+ names[name] = true
+ elseif kind then
+ kinds[kind] = true
+ elseif name then
+ names[name] = true
end
end
if r then
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index fb1c98c32..633fc112a 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -85,6 +85,7 @@ references.defined = references.defined or allocate()
local defined = references.defined
local derived = allocate()
local specials = allocate()
+local functions = allocate()
local runners = allocate()
local internals = allocate()
local filters = allocate()
@@ -100,6 +101,7 @@ local usedviews = allocate()
references.derived = derived
references.specials = specials
+references.functions = functions
references.runners = runners
references.internals = internals
references.filters = filters
@@ -1668,7 +1670,11 @@ local function identify(prefix,reference)
set.n = nofidentified
for i=1,#set do
local var = set[i]
- if var.special then
+ local spe = var.special
+ local fnc = functions[spe]
+ if fnc then
+ var = fnc(var) or { error = "invalid special function" }
+ elseif spe then
var = identify_special(set,var,i)
elseif var.outer then
var = identify_outer(set,var,i)
@@ -2382,6 +2388,102 @@ function specials.section(var,actions)
end
end
+-- experimental:
+
+local p_splitter = lpeg.splitat(":")
+local p_lower = lpeg.patterns.utf8lower
+
+-- We can cache lowercased titles which saves a lot of time, but then
+-- we can better have a global cache with weak keys.
+
+-- local lowercache = table.setmetatableindex(function(t,k)
+-- local v = lpegmatch(p_lower,k)
+-- t[k] = v
+-- return v
+-- end)
+
+local lowercache = false
+
+local function locate(list,askedkind,askedname,pattern)
+ local kinds = lists.kinds
+ local names = lists.names
+ if askedkind and not kinds[askedkind] then
+ return false
+ end
+ if askedname and not names[askedname] then
+ return false
+ end
+ for i=1,#list do
+ local entry = list[i]
+ local metadata = entry.metadata
+ if metadata then
+ local found = false
+ if askedname then
+ local name = metadata.name
+ if name then
+ found = name == askedname
+ end
+ elseif askedkind then
+ local kind = metadata.kind
+ if kind then
+ found = kind == askedkind
+ end
+ end
+ if found then
+ local titledata = entry.titledata
+ if titledata then
+ local title = titledata.title
+ if title then
+ if lowercache then
+ found = lpegmatch(pattern,lowercache[title])
+ else
+ found = lpegmatch(pattern,lpegmatch(p_lower,title))
+ end
+ if found then
+ return {
+ inner = pattern,
+ kind = "inner",
+ reference = pattern,
+ i = entry,
+ p = "",
+ r = entry.references.realpage,
+ }
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+function functions.match(var,actions)
+ if not var.outer then
+ local operation = var.operation
+ if operation and operation ~= "" then
+ local operation = lpegmatch(p_lower,operation)
+ local list = lists.collected
+ local names = false
+ local kinds = false
+ local where, what = lpegmatch(p_splitter,operation)
+ if where and what then
+ local pattern = lpeg.finder(what)
+ return
+ locate(list,false,where,pattern)
+ or locate(list,where,false,pattern)
+ or { error = "no match" }
+ else
+ local pattern = lpeg.finder(operation)
+ -- todo: don't look at section and float in last pass
+ return
+ locate(list,"section",false,pattern)
+ or locate(list,"float",false,pattern)
+ or locate(list,false,false,pattern)
+ or { error = "no match" }
+ end
+ end
+ end
+end
+
-- needs a better split ^^^
-- done differently now:
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index 65634b2e6..d2f36eb74 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -2103,6 +2103,34 @@
%D \stopinteractionmenu
%D \stoptyping
+%D Relatively new:
+%D
+%D \starttyping
+%D \chapter{The never ending story}
+%D
+%D \section{An ending story}
+%D
+%D \in{chapter}[match(complex bibliographies)]
+%D \in{chapter}[match(never ending)]
+%D \in{chapter}[match(ending)]
+%D \in{chapter}[match(chapter:never ending)]
+%D \in{chapter}[match(chapter:ending)]
+%D \in{section}[match(section:ending)]
+%D \in{figure}[match(float:mess)]
+%D \in{figure}[match(figure:mess)]
+%D \in{figure (not found)}[match(section:mess)]
+%D \in{figure (not found)}[match(section:xxxx)]
+%D \in{figure}[match(mess)]
+%D
+%D \placefigure{What a mess}{}
+%D
+%D \chapter{About complex bibliographies}
+%D
+%D \in{chapter}[match(complex bibliographies)]
+%D \in{chapter}[match(never ending)]
+%D \in{figure}[match(mess)]
+%D \stoptyping
+
%D Tracing:
\unexpanded\def\strc_references_tracer#1#2% \csleft csright
diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua
index 8529c3ad0..a040b0113 100644
--- a/tex/context/base/util-str.lua
+++ b/tex/context/base/util-str.lua
@@ -219,10 +219,12 @@ local striplinepatterns = {
["collapse"] = patterns.collapser, -- how about: stripper fullstripper
}
+setmetatable(striplinepatterns,{ __index = function(t,k) return p_prune_collapse end })
+
strings.striplinepatterns = striplinepatterns
function strings.striplines(str,how)
- return str and lpegmatch(how and striplinepatterns[how] or p_prune_collapse,str) or str
+ return str and lpegmatch(striplinepatterns[how],str) or str
end
-- also see: string.collapsespaces
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 6d0e5218f..f11a74ca5 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/10/14 22:40:17
+-- merge date : 12/11/14 12:02:53
do -- begin closure to overcome local limits and interference
@@ -2831,9 +2831,10 @@ local striplinepatterns={
["retain and no empty"]=p_retain_noempty,
["collapse"]=patterns.collapser,
}
+setmetatable(striplinepatterns,{ __index=function(t,k) return p_prune_collapse end })
strings.striplinepatterns=striplinepatterns
function strings.striplines(str,how)
- return str and lpegmatch(how and striplinepatterns[how] or p_prune_collapse,str) or str
+ return str and lpegmatch(striplinepatterns[how],str) or str
end
strings.striplong=strings.striplines
function strings.nice(str)