diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/core-env.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/core-mis.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/l-table.lua | 30 | ||||
-rw-r--r-- | tex/context/base/lxml-ini.lua | 340 | ||||
-rw-r--r-- | tex/context/base/lxml-ini.mkiv | 59 | ||||
-rw-r--r-- | tex/context/base/lxml-pth.lua | 3 | ||||
-rw-r--r-- | tex/context/base/lxml-tab.lua | 17 | ||||
-rw-r--r-- | tex/context/base/math-vfu.lua | 8 | ||||
-rw-r--r-- | tex/context/base/mult-def.lua | 8 | ||||
-rw-r--r-- | tex/context/base/mult-mes.lua | 8 | ||||
-rw-r--r-- | tex/context/base/mult-sys.tex | 1 | ||||
-rw-r--r-- | tex/context/base/spac-ver.lua | 11 | ||||
-rw-r--r-- | tex/context/base/spac-ver.mkiv | 29 | ||||
-rw-r--r-- | tex/context/base/x-set-11.mkiv | 90 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 32 |
17 files changed, 401 insertions, 243 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 02117c4b8..d4a1ca548 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.09.25 09:42} +\newcontextversion{2009.09.25 23:52} %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 3bba2b9d0..369ba7cf1 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.09.25 09:42} +\edef\contextversion{2009.09.25 23:52} %D For those who want to use this: diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index 72f7278d8..941914272 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -193,7 +193,7 @@ \fi \endcsname\empty} % takes one argument -\def\setupwithargument#1% the grid option will be extended to other main modes +\def\setupwithargument#1% {\csname\??su:\ifcsname\??su:#1\endcsname#1\else\letterpercent\fi\endcsname} \let\directsetup\dosetups diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 65cf273c6..f742dab47 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -819,7 +819,7 @@ \def\doinitializetextlevel#1% {\ifcsname\??ci:#1:\c!level\endcsname - \newcount\csname\??ci:#1:\c!level\endcsname\zerocount + \csname\??ci:#1:\c!level\endcsname\zerocount \else \expandafter\newcount\csname\??ci:#1:\c!level\endcsname \fi} diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua index 02bc47bf8..e14514291 100644 --- a/tex/context/base/l-table.lua +++ b/tex/context/base/l-table.lua @@ -813,3 +813,33 @@ end --~ end --~ return concat(k,"") --~ end + +function table.insert_before_value(t,value,extra) + for i=1,#t do + if t[i] == extra then + remove(t,i) + end + end + for i=1,#t do + if t[i] == value then + insert(t,i,extra) + return + end + end + insert(t,1,extra) +end + +function table.insert_after_value(t,value,extra) + for i=1,#t do + if t[i] == extra then + remove(t,i) + end + end + for i=1,#t do + if t[i] == value then + insert(t,i+1,extra) + return + end + end + insert(t,#t+1,extra) +end diff --git a/tex/context/base/lxml-ini.lua b/tex/context/base/lxml-ini.lua index d837dfd6d..4c6bae967 100644 --- a/tex/context/base/lxml-ini.lua +++ b/tex/context/base/lxml-ini.lua @@ -22,38 +22,6 @@ local trace_setups = false trackers.register("lxml.setups", function(v) trace local trace_loading = false trackers.register("lxml.loading", function(v) trace_loading = v end) local trace_access = false trackers.register("lxml.access", function(v) trace_access = v end) --- for the moment here - -function table.insert_before_value(t,value,extra) - for i=1,#t do - if t[i] == extra then - remove(t,i) - end - end - for i=1,#t do - if t[i] == value then - insert(t,i,extra) - return - end - end - insert(t,1,extra) -end - -function table.insert_after_value(t,value,extra) - for i=1,#t do - if t[i] == extra then - remove(t,i) - end - end - for i=1,#t do - if t[i] == value then - insert(t,i+1,extra) - return - end - end - insert(t,#t+1,extra) -end - -- todo: speed up: remember last index/match combination local traverse, lpath = xml.traverse, xml.lpath @@ -61,8 +29,7 @@ local traverse, lpath = xml.traverse, xml.lpath local xmlfilter, xmlfirst, xmllast, xmlall, xmlcount = xml.filter, xml.first, xml.last, xml.all, xml.count local xmlcollect, xmlcontent, xmlcollect_texts, xmlcollect_tags, xmlcollect_elements = xml.collect, xml.content, xml.collect_texts, xml.collect_tags, xml.collect_elements local xmlattribute, xmlindex, xmlchainattribute = xml.filters.attribute, xml.filters.index, xml.filters.chainattribute - -local xmlelements = xml.elements +local xmlelements, xmlsetproperty = xml.elements, xml.setproperty document = document or { } document.xml = document.xml or { } @@ -71,54 +38,52 @@ document.xml = document.xml or { } lxml = lxml or { } lxml.loaded = { } -lxml.paths = { } -lxml.myself = { } lxml.noffiles = 0 lxml.nofconverted = 0 lxml.nofindices = 0 local loaded = lxml.loaded -local paths = lxml.paths -local myself = lxml.myself -local stack = lxml.stack - ---~ lxml.self = myself -- be backward compatible for a while - ---~ local function get_id(id) ---~ return (type(id) == "table" and id) or loaded[id] or myself[tonumber(id)] -- no need for tonumber if we pass without "" ---~ end -- experiment -local currentdocuments, currentloaded, currentdocument, defaultdocument = { }, { }, "", "" - -function lxml.pushdocument(name) -- catches double names - if #currentdocuments == 0 then - defaultdocument = name - end - currentdocument = name - insert(currentdocuments,currentdocument) - insert(currentloaded,loaded[currentdocument]) - if trace_access then - logs.report("lxml","pushed: %s",currentdocument) +function lxml.store(id,root,filename) + loaded[id] = root + xmlsetproperty(root,"name",id) + if filename then + xmlsetproperty(root,"filename",filename) end end -function lxml.popdocument() - currentdocument = remove(currentdocuments) - if not currentdocument or currentdocument == "" then - currentdocument = defaultdocument - end - loaded[currentdocument] = remove(currentloaded) - if trace_access then - logs.report("lxml","popped: %s",currentdocument) - end -end +--~ local currentdocuments, currentloaded, currentdocument, defaultdocument = { }, { }, "", "" + +--~ function lxml.pushdocument(name) -- catches double names +--~ if #currentdocuments == 0 then +--~ defaultdocument = name +--~ end +--~ currentdocument = name +--~ insert(currentdocuments,currentdocument) +--~ insert(currentloaded,loaded[currentdocument]) +--~ if trace_access then +--~ logs.report("lxml","pushed: %s",currentdocument) +--~ end +--~ end + +--~ function lxml.popdocument() +--~ currentdocument = remove(currentdocuments) +--~ if not currentdocument or currentdocument == "" then +--~ currentdocument = defaultdocument +--~ end +--~ loaded[currentdocument] = remove(currentloaded) +--~ if trace_access then +--~ logs.report("lxml","popped: %s",currentdocument) +--~ end +--~ end + +--~ local splitter = ((lpeg.R("09")^1/tonumber) + lpeg.Cc(false)) * lpeg.P("@")^0 * (lpeg.C(lpeg.P(1)^1) + lpeg.Cc(false)) ---~ local splitter = lpeg.splitat("::") local splitter = lpeg.C((1-lpeg.P(":"))^1) * lpeg.P("::") * lpeg.C(lpeg.P(1)^1) -local function get_id(id) +local function get_id(id, qualified) if type(id) == "table" then return id else @@ -134,7 +99,11 @@ local function get_id(id) if ldi then local root = ldi[tonumber(i)] if root then - return root + if qualified then -- we need this else two args that confuse others + return root, d + else + return root + end elseif trace_access then logs.report("lxml","'%s' has no index entry '%s'",d,i) end @@ -145,22 +114,26 @@ local function get_id(id) logs.report("lxml","'%s' is not loaded",d) end else - local ld = loaded[currentdocument] - if ld then - local ldi = ld.index - if ldi then - local root = ldi[tonumber(id)] - if root then - return root - elseif trace_access then - logs.report("lxml","current document '%s' has no index entry '%s'",currentdocument,id) - end - elseif trace_access then - logs.report("lxml","current document '%s' has no index",currentdocument) - end - elseif trace_access then - logs.report("lxml","current document '%s' not loaded",currentdocument) - end +--~ local ld = loaded[currentdocument] +--~ if ld then +--~ local ldi = ld.index +--~ if ldi then +--~ local root = ldi[tonumber(id)] +--~ if root then +--~ if qualified then -- we need this else two args that confuse others +--~ return root, currentdocument +--~ else +--~ return root +--~ end +--~ elseif trace_access then +--~ logs.report("lxml","current document '%s' has no index entry '%s'",currentdocument,id) +--~ end +--~ elseif trace_access then +--~ logs.report("lxml","current document '%s' has no index",currentdocument) +--~ end +--~ elseif trace_access then +--~ logs.report("lxml","current document '%s' not loaded",currentdocument) +--~ end end end end @@ -422,22 +395,14 @@ xml.originalload = xml.originalload or xml.load local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming ---~ function xml.load(filename) ---~ lxml.noffiles = lxml.noffiles + 1 ---~ starttiming(xml) ---~ local xmldata = xml.convert((filename and resolvers.loadtexfile(filename)) or "") ---~ stoptiming(xml) ---~ return xmldata ---~ end - function xml.load(filename) lxml.noffiles = lxml.noffiles + 1 lxml.nofconverted = lxml.nofconverted + 1 starttiming(xml) local ok, data = resolvers.loadbinfile(filename) - local xmldata = xml.convert((ok and data) or "") + local xmltable = xml.convert((ok and data) or "") stoptiming(xml) - return xmldata + return xmltable end function lxml.load(id,filename) @@ -445,23 +410,24 @@ function lxml.load(id,filename) if trace_loading then commands.writestatus("lxml","loading file '%s' as '%s'",filename,id) end - local root = xml.load(filename) - loaded[id], paths[id]= root, filename - return root, filename + local xmltable = xml.load(filename) + lxml.store(id,xmltable,filename) + return xmltable, filename end -function lxml.register(id,xmltable) - loaded[id] = xmltable +function lxml.register(id,xmltable,filename) + lxml.store(id,xmltable,filename) return xmltable end function lxml.include(id,pattern,attribute,recurse) starttiming(xml) - xml.include(get_id(id),pattern,attribute,recurse,function(filename) + local root = get_id(id) + xml.include(root,pattern,attribute,recurse,function(filename) if filename then filename = commands.preparedfile(filename) - if file.dirname(filename) == "" then - filename = file.join(file.dirname(paths[currentdocument]),filename) + if file.dirname(filename) == "" and root.filename then + filename = file.join(file.dirname(root.filename),filename) end if trace_loading then commands.writestatus("lxml","including file: %s",filename) @@ -692,16 +658,17 @@ function lxml.serialize(root, command) local tc = type(command) if tc == "string" then -- setup ---~ local n = #myself + 1 ---~ myself[n] = root ---~ texsprint(ctxcatcodes,format("\\xmlsetup{%i}{%s}",n,command)) local ix = root.ix ---~ if not ix then ---~ lxml.addindex(root) ---~ ix = root.ix ---~ end ---~ texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",ix,command)) - texsprint(ctxcatcodes,format("\\xmls{%s}{%s}",ix,command)) + local rootname = root.name + if rootname then + if not ix then + lxml.addindex(rootname,false,true) + ix = root.ix + end + texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",rootname,ix,command)) + else + texsprint(ctxcatcodes,format("\\xmls{%s}{%s}",ix,command)) + end elseif tc == "function" then -- function command(root) @@ -733,17 +700,21 @@ function lxml.setsetup(id,pattern,setup) if setup == "-" then dtdk.command = false if trace then - logs.report("lxml","lpath matched -> %s -> skipped", command) + logs.report("lxml","lpath matched -> %s -> skipped", setup) end elseif setup == "+" then dtdk.command = true if trace_setups then - logs.report("lxml","lpath matched -> %s -> text", command) + logs.report("lxml","lpath matched -> %s -> text", setup) end else - dtdk.command = command + dtdk.command = tg -- command -- setup if trace_setups then - logs.report("lxml","lpath matched -> %s -> %s", command, command) + if ns == "" then + logs.report("lxml","lpath matched -> %s -> %s", tg, tg) + else + logs.report("lxml","lpath matched -> %s:%s -> %s", ns, tg, tg) + end end end end @@ -832,30 +803,95 @@ function lxml.info(id) texsprint(tg) end +-- can be simplified ... we can use the outer name +--~ local function command(root,pattern,cmd) -- met zonder '' +--~ if find(cmd,"^[\'\"]") then +--~ cmd = sub(cmd,2,-2) +--~ end +--~ local rootname = root.name +--~ traverse(root, lpath(pattern), function(r,d,k) +--~ -- this can become pretty large +--~ local m = (d and d[k]) or r -- brrr this r, maybe away +--~ local ix = m.ix +--~ if not ix then +--~ lxml.addindex(rootname,false,true) +--~ ix = m.ix +--~ end +--~ texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",rootname,ix,cmd)) +--~ end) +--~ end +--~ local function qualifiedcommand(parent,root,pattern,cmd) -- met zonder '' +--~ if find(cmd,"^[\'\"]") then +--~ cmd = sub(cmd,2,-2) +--~ end +--~ traverse(root, lpath(pattern), function(r,d,k) +--~ local m = (d and d[k]) or r +--~ local ix = m.ix +--~ if not ix then +--~ lxml.addindex(parent,false,true) +--~ ix = m.ix +--~ end +--~ texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",parent,ix,cmd)) +--~ end) +--~ end + +local rootname, thecmd +local function ndoit(r,d,k) + local m = (d and d[k]) or r -- brrr this r, maybe away + local ix = m.ix + if not ix then + lxml.addindex(rootname,false,true) + ix = m.ix + end + texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",rootname,ix,thecmd)) +end +local function qdoit(r,d,k) + local m = (d and d[k]) or r + local ix = m.ix + if not ix then + lxml.addindex(parent,false,true) + ix = m.ix + end + texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",rootname,ix,thecmd)) +end local function command(root,pattern,cmd) -- met zonder '' ---~ cmd = gsub(cmd,"^([\'\"])(.-)%1$", "%2") if find(cmd,"^[\'\"]") then - cmd = sub(cmd,2,-2) - end - traverse(root, lpath(pattern), function(r,d,k) - -- this can become pretty large - local m = (d and d[k]) or r -- brrr this r, maybe away - if type(m) == "table" then -- probably a bug ---~ local n = #myself + 1 ---~ myself[n] = m ---~ texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",n,cmd)) - texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",tostring(m.ix),cmd)) - end - end) + thecmd = sub(cmd,2,-2) + else + thecmd = cmd + end + rootname = root.name + traverse(root, lpath(pattern), ndoit) +end +local function qualifiedcommand(parent,root,pattern,cmd) -- met zonder '' + if find(cmd,"^[\'\"]") then + thecmd = sub(cmd,2,-2) + else + thecmd = cmd + end + rootname = parent + traverse(root, lpath(pattern), qdoit) end - -xml.filters.command = command function lxml.command(id,pattern,cmd) - command(get_id(id),pattern,cmd) + if find(cmd,"^[\'\"]") then + thecmd = sub(cmd,2,-2) + else + thecmd = cmd + end + local i, p = get_id(id,true) + if p then + rootname = p + traverse(i, lpath(pattern), qdoit) + else + rootname = i.name + traverse(i, lpath(pattern), ndoit) + end end +xml.filters.command = command + local function dofunction(root,pattern,fnc) traverse(root, lpath(pattern), xml.functions[fnc]) -- r, d, t end @@ -964,17 +1000,19 @@ function lxml.loadbuffer(id,name) end starttiming(xml) lxml.nofconverted = lxml.nofconverted + 1 - loaded[id] = xml.convert(buffers.collect(name or id,"\n")) + local xmltable = xml.convert(buffers.collect(name or id,"\n")) + lxml.store(id,xmltable) stoptiming(xml) - return loaded[id], name or id + return xmltable, name or id end function lxml.loaddata(id,str) starttiming(xml) lxml.nofconverted = lxml.nofconverted + 1 - loaded[id] = xml.convert(str or "") + local xmltable = xml.convert(str or "") + lxml.store(id,xmltable) stoptiming(xml) - return loaded[id], id + return xmltable, id end function lxml.loadregistered(id) @@ -1211,8 +1249,7 @@ end function lxml.addindex(name,check_sum,force) local root = get_id(name) if root and (not root.index or force) then -- weird, only called once - local index, maxindex, check = root.index or { }, root.maxindex or 0, root.check or { } - local n = 0 + local n, index, maxindex, check = 0, root.index or { }, root.maxindex or 0, root.check or { } local function nest(root) local dt = root.dt if not root.ix then @@ -1265,18 +1302,11 @@ function lxml.addindex(name,check_sum,force) root.maxindex = maxindex --~ end if trace_access then - commands.writestatus("lxml",format("%s loaded, %s index entries",tostring(name),maxindex)) + logs.report("lxml","%s indexed, %s nodes",tostring(name),maxindex) end end end -local include= lxml.include - -function lxml.include(id,...) - include(id,...) - lxml.addindex(currentdocument,false,true) -end - -- we can share the index function lxml.checkindex(name) @@ -1284,12 +1314,22 @@ function lxml.checkindex(name) return (root and root.index) or 0 end -function lxml.withindex(name,n,command) - texsprint(ctxcatcodes,format("\\xmlsetup{%s::%s}{%s}",name,n,command)) +function lxml.withindex(name,n,command) -- will change as name is always there now + local i, p = splitter:match(n) + if p then + texsprint(ctxcatcodes,format("\\xmls{%s}{%s}",n,command)) + else + texsprint(ctxcatcodes,format("\\xmls{%s::%s}{%s}",name,n,command)) + end end -function lxml.getindex(name,n) - texsprint(ctxcatcodes,format("%s::%s",name,n)) +function lxml.getindex(name,n) -- will change as name is always there now + local i, p = splitter:match(n) + if p then + texsprint(ctxcatcodes,n) + else + texsprint(ctxcatcodes,format("%s::%s",name,n)) + end end -- diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 02703d2da..05f89652c 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D Todo: push/pop for nested usage ... think this over +%D Todo: auto apply setups (manage at lua end) \writestatus{loading}{ConTeXt XML Support / Initialization} @@ -42,8 +42,8 @@ \def\xmlfilter #1#2{\ctxlua{lxml.filter("#1",\!!bs#2\!!es)}} \def\xmlfirst #1#2{\ctxlua{lxml.first("#1","#2")}} \def\xmlflush #1{\ctxlua{lxml.flush("#1")}} -% \def\xmlcontent #1{\ctxlua{lxml.content("#1")}} -% \def\xmlflushstripped #1{\ctxlua{lxml.strip("#1",true)}} +%def\xmlcontent #1{\ctxlua{lxml.content("#1")}} +%def\xmlflushstripped #1{\ctxlua{lxml.strip("#1",true)}} \def\xmldirect #1{\ctxlua{lxml.direct("#1")}} % in loops, not dt but root \def\xmlidx #1#2#3{\ctxlua{lxml.idx("#1","#2",\number#3)}} \def\xmlinclude #1#2#3{\ctxlua{lxml.include("#1","#2","#3",true)}} @@ -109,10 +109,11 @@ % % \xmlprependsetup{xml:include} -\let\xmlgrab\xmlsetsetup +\let\xmlgrab\xmlsetsetup % obsolete +\let\xmlself\s!unknown % obsolete -\def\xmlsetup#1#2% % we pass the reference so that we have access to the frozen number - {\def\xmlself{#1}% % by using #1 inside a setup; maybe self becomes obsolete +\def\xmlsetup#1#2% + {%\def\xmlself{#1}% \setupwithargument{#2}{#1}} \let\xmls\xmlsetup @@ -153,7 +154,6 @@ % todo: test for duplicates ! \xmlflushdocumentsetups{#1}% \xmldefaulttotext{#1}% after include -\xmladdindex{#1}% check for dups \xmlstoptiming} \def\xmlstarttiming{\ctxlua{statistics.starttiming(lxml)}} @@ -162,18 +162,17 @@ \def\doxmlprocess#1#2#3#4#5% {\begingroup \edef\xmldocument{#3}% #2 can be \xmldocument and set as such - \xmlpushdocument{#3}% + %xmlpushdocument{#3}% #2{#3}{#4}% - \ctxlua{lxml.addindex("\xmldocument",\ifnum#1=\plusone true\else false\fi)}% todo: only checksum for file \ifcase\xmlprocessingmode \enableXML \else \setcatcodetable\notcatcodes \fi \doifelsenothing{#5} - {\directsetup{xml:process}} - {\directsetup{#5}}% - \xmlpopdocument + {\xmlsetup{#3}{xml:process}} + {\xmlsetup{#3}{#5}}% + %xmlpopdocument \endgroup} \def\xmlprocessfile {\doxmlprocess\plusone \xmlload} @@ -182,15 +181,23 @@ \def\xmlprocessregistered{\doxmlprocess\zerocount\xmlloadregistered} \let\xmlprocess \xmlprocessfile +\startxmlsetups xml:flush + \xmlflush{#1} +\stopxmlsetups + +\startxmlsetups xml:process + \xmlregistereddocumentsetups{#1} + \xmlmain{#1} +\stopxmlsetups + +\def\xmlloadonly#1#2#3% + {\xmlload{#1}{#2}% + \xmlregistereddocumentsetups{#3}} + % beware: \xmlmain takes the real root, so also processing % instructions preceding the root element; well, in some % sense that is the root -\startsetups xml:process - \xmlregistereddocumentsetups\xmldocument - \xmlmain\xmldocument -\stopsetups - \long\def\xmlloop#1#2#3% {\def\xmli##1##2{\xmlidx{#1}{#2/##1}{##2}}% \dorecurse{\xmlcount{#1}{#2}}{#3}} @@ -415,23 +422,13 @@ %D Experimental: -\def\xmlpushdocument#1{\ctxlua{lxml.pushdocument("#1")}} -\def\xmlpopdocument {\ctxlua{lxml.popdocument()}} -\def\xmladdindex #1{\ctxlua{lxml.addindex("#1")}} +%def\xmlpushdocument#1{\ctxlua{lxml.pushdocument("#1")}} +%def\xmlpopdocument {\ctxlua{lxml.popdocument()}} +%def\xmladdindex #1{\ctxlua{lxml.addindex("#1")}} + \def\xmlgetindex #1{\ctxlua{lxml.getindex("\xmldocument","#1")}} \def\xmlrawindex #1{\ctxlua{lxml.rawindex("#1")}} \def\xmlwithindex #1#2{\ctxlua{lxml.withindex("\xmldocument","#1","#2")}} \def\xmlreference #1#2{\string\xmlwithindex{#1}{#2}} -\startxmlsetups xml:flush - \xmlflush{#1} -\stopxmlsetups - -%D Under construction (see x-set-11) - -\def\xmlloadonly#1#2#3% - {\xmlload{#1}{#2}% - \xmlregistereddocumentsetups{#3}% - \xmladdindex{#1}} - \protect \endinput diff --git a/tex/context/base/lxml-pth.lua b/tex/context/base/lxml-pth.lua index e0520edbd..8f7015de9 100644 --- a/tex/context/base/lxml-pth.lua +++ b/tex/context/base/lxml-pth.lua @@ -1334,7 +1334,8 @@ function xml.include(xmldata,pattern,attribute,recursive,loaddata) elseif ek.at["parse"] == "text" then -- for the moment hard coded d[k] = xml.escaped(data) else - local xi = xml.convert(data) + -- data, no_root, strip_cm_and_dt, given_entities, parent_root (todo: entities) + local xi = xml.convert(data,nil,nil,xmldata.entities,xmldata) if not xi then xml.empty(d,k) else diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 52e04befd..b49bf0ecb 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -39,7 +39,7 @@ xml = xml or { } --~ local xml = xml local concat, remove, insert = table.concat, table.remove, table.insert -local type, next, setmetatable = type, next, setmetatable +local type, next, setmetatable, getmetatable = type, next, setmetatable, getmetatable local format, lower, find = string.format, string.lower, string.find --[[ldx-- @@ -175,6 +175,14 @@ local stack, top, dt, at, xmlns, errorstr, entities = {}, {}, {}, {}, {}, nil, { local mt = { __tostring = xml.text } +function initialize_mt(root) + mt = { __tostring = xml.text, __index = root } +end + +function xml.setproperty(root,k,v) + getmetatable(root).__index[k] = v +end + function xml.check_error(top,toclose) return "" end @@ -366,9 +374,14 @@ local grammar = P { "preamble", -- todo: xml.new + properties like entities and strip and such (store in root) -function xml.convert(data, no_root, strip_cm_and_dt, given_entities) -- maybe use table met k/v (given_entities may disapear) +function xml.convert(data, no_root, strip_cm_and_dt, given_entities, parent_root) -- maybe use table met k/v (given_entities may disapear) strip = strip_cm_and_dt or xml.strip_cm_and_dt stack, top, at, xmlns, errorstr, result, entities = {}, {}, {}, {}, nil, nil, given_entities or {} + if parent_root then + mt = getmetatable(parent_root) + else + initialize_mt(top) + end stack[#stack+1] = top top.dt = { } dt = top.dt diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index 3db60c4ee..42b7ef05d 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -288,6 +288,7 @@ function fonts.vf.math.define(specification,set) main.name, main.fonts, main.virtualized, main.math_parameters = name, lst, true, { } local characters, descriptions = main.characters, main.descriptions main.parameters.x_height = main.parameters.x_height or 0 + local already_reported = false for s=1,n do local ss, fs = okset[s], fnt[s] if not fs then @@ -343,7 +344,12 @@ function fonts.vf.math.define(specification,set) if not rv then rv = { } rf[vectorname] = rv end local ru = rv[unicode] if not ru then - logs.report("math virtual", "unicode point U+%05X has no index %04X in vector %s for font %s",unicode,index,vectorname,fontname) + if trace_virtual then + logs.report("math virtual", "unicode point U+%05X has no index %04X in vector %s for font %s",unicode,index,vectorname,fontname) + elseif not already_reported then + logs.report("math virtual", "the mapping is incomplete for '%s' at %s",name,size) + already_reported = true + end rv[unicode] = true end else diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index 3c6227943..cd80c23c9 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -1,3 +1,11 @@ +if not modules then modules = { } end modules ['mult-def'] = { + version = 1.001, + comment = "companion to mult-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + return { ["commands"]={ ["CAPPED"]={ diff --git a/tex/context/base/mult-mes.lua b/tex/context/base/mult-mes.lua index a1a410b21..5c8129711 100644 --- a/tex/context/base/mult-mes.lua +++ b/tex/context/base/mult-mes.lua @@ -1,3 +1,11 @@ +if not modules then modules = { } end modules ['mult-mes'] = { + version = 1.001, + comment = "companion to mult-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + return { ["publications"]={ ["files"]={ "bibl-tra.mkiv" }, diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex index 0fc975816..c16ebee18 100644 --- a/tex/context/base/mult-sys.tex +++ b/tex/context/base/mult-sys.tex @@ -607,6 +607,7 @@ \definesystemvariable {up} % Utility Program \definesystemvariable {ve} % VErsie \definesystemvariable {vn} % VoetNoten +\definesystemvariable {vs} % VSpacing \definesystemvariable {vt} % VerTical \definesystemvariable {wr} % WitRuimte \definesystemvariable {wl} % WordList diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index a5daa96f1..4374eb4d4 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -297,7 +297,7 @@ do -- todo: interface.variables -- This will change: just node.write and we can store the values in skips which -- then obeys grouping - local function analyse(str,oldcategory,texsprint) + local function analyse(str,oldcategory,texsprint) -- we could use shorter names for s in gmatch(str,"([^ ,]+)") do local amount, keyword, detail = splitter:match(s) if not keyword then @@ -332,10 +332,15 @@ do -- todo: interface.variables else amount = tonumber(amount) or 1 local sk = skip[keyword] +--~ if sk then +--~ texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,sk[1],sk[2] or sk[1])) +--~ else -- no check +--~ texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,keyword,keyword)) +--~ end if sk then - texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,sk[1],sk[2] or sk[1])) + texsprint(ctxcatcodes,format("\\addpredefinedblankskip{%s}{%s}",amount,keyword)) else -- no check - texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,keyword,keyword)) + texsprint(ctxcatcodes,format("\\addaskedblankskip{%s}{%s}",amount,keyword)) end end end diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 15e37d61a..ae0fbf003 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -418,8 +418,10 @@ {\par \ifvmode \bgroup + \whitespace % not combined \blank[\v!disable] \setupwhitespace[\v!none] + \let\startpacked\nestedstartpacked \fi} \def\stoppacked @@ -428,6 +430,15 @@ \egroup \fi} +\def\nestedstartpacked + {\par + \bgroup + \let\stoppacked\nestedstoppacked} + +\def\nestedstoppacked + {\par + \egroup} + \def\startunpacked {\blank \bgroup} @@ -1521,13 +1532,25 @@ \setfalse\someblankdone \the\everybeforeblankhandling} -% % % % +% % % % we can move much to lua once we can expand there % % % % \def\definevspacingamount {\dotripleempty\dodefinevspacingamount} -\def\dodefinevspacingamount[#1][#2][#3]% - {\ctxlua{vspacing.setskip("#1",\!!bs\detokenize{#2}\!!es,\!!bs\detokenize{#3}\!!es)}} +% \def\dodefinevspacingamount[#1][#2][#3]% +% {\ctxlua{vspacing.setskip("#1",\!!bs\detokenize{#2}\!!es,\!!bs\detokenize{#3}\!!es)}} + +\def\dodefinevspacingamount[#1][#2][#3]% can be combined + {\setvalue{\??vs:#1}{\ifgridsnapping#3\else#2\fi}% + \ctxlua{vspacing.setskip("#1")}} + +\def\addpredefinedblankskip#1#2% + {\settrue\someblankdone + \advance\blankskip#1\dimexpr\csname\??vs:#2\endcsname\relax} + +\def\addaskedblankskip#1#2% + {\settrue\someblankdone + \advance\blankskip#1\dimexpr#2\relax} \def\definevspacing {\dodoubleempty\dodefinevspacing} diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index 087aeb459..02d75fc4c 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -141,9 +141,7 @@ {\doifsomething{#1} {\doonlyonce{setups:#1} {\xmlloadonly{setups}{#1}{setups}% - \xmlpushdocument{setups}% should be automatic - \xmlcommand{setups}{/interface/command}{xml:setups:register}}% qualified path saves > 50% runtime - \xmlpopdocument}} + \xmlcommand{setups}{/interface/command}{xml:setups:register}}}} % qualified path saves > 50% runtime \newif\ifshortsetup @@ -193,56 +191,54 @@ \def\currentSETUPwidth{0pt} \startxmlsetups xml:setups:typeset - \xmlpushdocument{setups} - \getvalue{\e!start setuptext} - \tttf - \nohyphens - \veryraggedright - \doglobal\newcounter\currentSETUPargument - \xdef\maximumSETUPargument{\xmlcount{#1}{/arguments/*}} + \getvalue{\e!start setuptext} + \tttf + \nohyphens + \veryraggedright + \doglobal\newcounter\currentSETUPargument + \xdef\maximumSETUPargument{\xmlcount{#1}{/arguments/*}} + \bgroup + \doif {\xmlatt{#1}{generated}} {yes} { + \ttsl + } + \doifelse {\xmlatt{#1}{type}} {environment} { + \tex{\e!start} + } { + \tex{} + } + \xmlfirst{#1}{/sequence} + \ignorespaces + \egroup + \xmldoif{#1}{/arguments} { + \bgroup + \enablemode[setups-pass-one] + \doglobal\newcounter\currentSETUPargument + \ignorespaces + \xmltext{#1}{/arguments} + \egroup + } + \doif {\xmlatt{#1}{type}} {environment} { \bgroup + \hskip.5em\unknown\hskip.5em \doif {\xmlatt{#1}{generated}} {yes} { \ttsl } - \doifelse {\xmlatt{#1}{type}} {environment} { - \tex{\e!start} - } { - \tex{} - } - \xmlfirst{#1}{/sequence} + \tex{\e!stop} + \xmlfirst{#1}{/sequence/variable} \ignorespaces \egroup - \xmldoif{#1}{/arguments} { - \bgroup - \enablemode[setups-pass-one] - \doglobal\newcounter\currentSETUPargument - \ignorespaces - \xmltext{#1}{/arguments} - \egroup - } - \doif {\xmlatt{#1}{type}} {environment} { - \bgroup - \hskip.5em\unknown\hskip.5em - \doif {\xmlatt{#1}{generated}} {yes} { - \ttsl - } - \tex{\e!stop} - \xmlfirst{#1}{/sequence/variable} - \ignorespaces - \egroup - } - \endgraf - \xmldoif{#1}{/arguments} { - \bgroup - \enablemode[setups-pass-two] - \doglobal\newcounter\currentSETUPargument - \blank[\v!line] - \switchtobodyfont[small] - \ignorespaces\xmltext{#1}{/arguments}\endgraf - \egroup - } - \getvalue{\e!stop setuptext} - \xmlpopdocument + } + \endgraf + \xmldoif{#1}{/arguments} { + \bgroup + \enablemode[setups-pass-two] + \doglobal\newcounter\currentSETUPargument + \blank[\v!line] + \switchtobodyfont[small] + \ignorespaces\xmltext{#1}{/arguments}\endgraf + \egroup + } + \getvalue{\e!stop setuptext} \stopxmlsetups \setupsetup diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index e107372e9..8d7f7b58b 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 : 09/25/09 09:47:31 +-- merge date : 09/25/09 23:59:10 do -- begin closure to overcome local limits and interference @@ -1295,6 +1295,36 @@ end --~ return concat(k,"") --~ end +function table.insert_before_value(t,value,extra) + for i=1,#t do + if t[i] == extra then + remove(t,i) + end + end + for i=1,#t do + if t[i] == value then + insert(t,i,extra) + return + end + end + insert(t,1,extra) +end + +function table.insert_after_value(t,value,extra) + for i=1,#t do + if t[i] == extra then + remove(t,i) + end + end + for i=1,#t do + if t[i] == value then + insert(t,i+1,extra) + return + end + end + insert(t,#t+1,extra) +end + end -- closure do -- begin closure to overcome local limits and interference |