From 36be5943fa71b0543ccea4a771c4cea9361cfcc2 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 11 Dec 2014 13:15:03 +0100 Subject: 2014-12-11 12:04:00 --- scripts/context/lua/mtxrun.lua | 76 +++++++++++++-- scripts/context/stubs/mswin/mtxrun.lua | 76 +++++++++++++-- scripts/context/stubs/unix/mtxrun | 76 +++++++++++++-- scripts/context/stubs/win64/mtxrun.lua | 76 +++++++++++++-- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4382 -> 4387 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/l-string.lua | 2 +- tex/context/base/lxml-aux.lua | 92 +++++++++++++++++- tex/context/base/meta-imp-txt.mkiv | 7 +- tex/context/base/publ-fnd.lua | 3 +- tex/context/base/status-files.pdf | Bin 24649 -> 24632 bytes tex/context/base/status-lua.pdf | Bin 344691 -> 344758 bytes tex/context/base/strc-lst.lua | 13 ++- tex/context/base/strc-ref.lua | 104 ++++++++++++++++++++- tex/context/base/strc-ref.mkvi | 28 ++++++ tex/context/base/util-str.lua | 4 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 5 +- 18 files changed, 523 insertions(+), 43 deletions(-) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index d123ddd9e..88004c0e3 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1180,7 +1180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 5671, stripped down to: 2827 +-- original size: 5694, stripped down to: 2827 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -5125,7 +5125,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 34327, stripped down to: 18775 +-- original size: 34388, stripped down to: 18833 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -5257,9 +5257,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) @@ -11604,7 +11605,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true --- original size: 26119, stripped down to: 18895 +-- original size: 28227, stripped down to: 20128 if not modules then modules={} end modules ['lxml-aux']={ version=1.001, @@ -11621,10 +11622,12 @@ local xmlconvert,xmlcopy,xmlname=xml.convert,xml.copy,xml.name 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) end @@ -12373,6 +12376,65 @@ function helpers.recursetext(collected,action,recursive) end end end +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 + 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 end -- of closure @@ -17657,8 +17719,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 729563 --- stripped bytes : 259777 +-- original bytes : 731755 +-- stripped bytes : 260678 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index d123ddd9e..88004c0e3 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -1180,7 +1180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 5671, stripped down to: 2827 +-- original size: 5694, stripped down to: 2827 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -5125,7 +5125,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 34327, stripped down to: 18775 +-- original size: 34388, stripped down to: 18833 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -5257,9 +5257,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) @@ -11604,7 +11605,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true --- original size: 26119, stripped down to: 18895 +-- original size: 28227, stripped down to: 20128 if not modules then modules={} end modules ['lxml-aux']={ version=1.001, @@ -11621,10 +11622,12 @@ local xmlconvert,xmlcopy,xmlname=xml.convert,xml.copy,xml.name 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) end @@ -12373,6 +12376,65 @@ function helpers.recursetext(collected,action,recursive) end end end +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 + 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 end -- of closure @@ -17657,8 +17719,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 729563 --- stripped bytes : 259777 +-- original bytes : 731755 +-- stripped bytes : 260678 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index d123ddd9e..88004c0e3 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1180,7 +1180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 5671, stripped down to: 2827 +-- original size: 5694, stripped down to: 2827 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -5125,7 +5125,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 34327, stripped down to: 18775 +-- original size: 34388, stripped down to: 18833 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -5257,9 +5257,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) @@ -11604,7 +11605,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true --- original size: 26119, stripped down to: 18895 +-- original size: 28227, stripped down to: 20128 if not modules then modules={} end modules ['lxml-aux']={ version=1.001, @@ -11621,10 +11622,12 @@ local xmlconvert,xmlcopy,xmlname=xml.convert,xml.copy,xml.name 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) end @@ -12373,6 +12376,65 @@ function helpers.recursetext(collected,action,recursive) end end end +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 + 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 end -- of closure @@ -17657,8 +17719,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 729563 --- stripped bytes : 259777 +-- original bytes : 731755 +-- stripped bytes : 260678 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index d123ddd9e..88004c0e3 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -1180,7 +1180,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 5671, stripped down to: 2827 +-- original size: 5694, stripped down to: 2827 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -5125,7 +5125,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-str"] = package.loaded["util-str"] or true --- original size: 34327, stripped down to: 18775 +-- original size: 34388, stripped down to: 18833 if not modules then modules={} end modules ['util-str']={ version=1.001, @@ -5257,9 +5257,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) @@ -11604,7 +11605,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true --- original size: 26119, stripped down to: 18895 +-- original size: 28227, stripped down to: 20128 if not modules then modules={} end modules ['lxml-aux']={ version=1.001, @@ -11621,10 +11622,12 @@ local xmlconvert,xmlcopy,xmlname=xml.convert,xml.copy,xml.name 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) end @@ -12373,6 +12376,65 @@ function helpers.recursetext(collected,action,recursive) end end end +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 + 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 end -- of closure @@ -17657,8 +17719,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 729563 --- stripped bytes : 259777 +-- original bytes : 731755 +-- stripped bytes : 260678 -- end library merge 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 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf 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 = [[ +-- +-- +-- +-- +-- +-- c > d +-- +-- +-- ]] +-- +-- 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 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 23ff2dbab..7612df67e 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf 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) -- cgit v1.2.3