diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/core-uti.lua | 2 | ||||
-rw-r--r-- | tex/context/base/lxml-ini.mkiv | 15 | ||||
-rw-r--r-- | tex/context/base/lxml-tex.lua | 16 | ||||
-rw-r--r-- | tex/context/base/page-lin.mkiv | 67 | ||||
-rw-r--r-- | tex/context/base/strc-itm.mkiv | 34 | ||||
-rw-r--r-- | tex/context/base/strc-num.mkiv | 4 | ||||
-rw-r--r-- | tex/context/base/strc-pag.lua | 4 | ||||
-rw-r--r-- | tex/context/base/supp-ran.lua | 13 | ||||
-rw-r--r-- | tex/context/base/x-set-11.mkiv | 42 |
9 files changed, 122 insertions, 75 deletions
diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index e98012dab..f381f2bb6 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -70,7 +70,7 @@ local function initializer() if not r then r = math.random() end - math.randomseed(r) + math.setrandomseedi(r) jobvariables.tobesaved.randomseed = r for cs, value in next, jobvariables.collected do tex.sprint(format("\\xdef\\%s{%s}",cs,value)) diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index bb1f4ca44..f1af79797 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -45,6 +45,7 @@ \def\xmldirectivesbefore #1{\ctxlua{lxml.directives.before("#1")}} \def\xmldirectivesafter #1{\ctxlua{lxml.directives.after("#1")}} \def\xmlfilter #1#2{\ctxlua{lxml.filter("#1",\!!bs#2\!!es)}} +\def\xmlfilterlist #1#2{\ctxlua{lxml.filterlist("#1",\!!bs#2\!!es)}} \def\xmlfunction #1#2{\ctxlua{lxml["function"]("#1",\!!bs#2\!!es)}} \def\xmlfirst #1#2{\ctxlua{lxml.first("#1","#2")}} \def\xmlflush #1{\ctxlua{lxml.flush("#1")}} @@ -122,7 +123,7 @@ \newtoks \registeredxmlsetups -% todo: 1:xml:whatever alwas before 3:xml:something +% todo: 1:xml:whatever always before 3:xml:something \def\xmlprependsetup #1{\ctxlua{lxml.installsetup(1,"*","#1")}} \def\xmlappendsetup #1{\ctxlua{lxml.installsetup(2,"*","#1")}} @@ -137,7 +138,7 @@ \def\xmlremovesetup #1{\ctxlua{lxml.removesetup("*","#1")}} \def\xmlremovedocumentsetup #1#2{\ctxlua{lxml.removesetup("#1","#2")}} -\def\xmlflushdocumentsetups #1{\ctxlua{lxml.flushsetups("*","#1")}} +\def\xmlflushdocumentsetups #1#2{\ctxlua{lxml.flushsetups("#1","*","#2")}} % #1 == id where to apply * and #2 \def\xmlresetdocumentsetups #1{\ctxlua{lxml.resetsetups("#1")}} \let\xmlregistersetup \xmlappendsetup @@ -151,17 +152,17 @@ \xmldefaulttotext\xmldocument % after include \xmlstoptiming} -\def\xmlregistereddocumentsetups#1% +\def\xmlregistereddocumentsetups#1#2% id setups {\xmlstarttiming % todo: test for duplicates ! - \xmlflushdocumentsetups{#1}% + \xmlflushdocumentsetups{#1}{#2}% \xmldefaulttotext{#1}% after include \xmlstoptiming} \def\xmlstarttiming{\ctxlua{statistics.starttiming(lxml)}} \def\xmlstoptiming {\ctxlua{statistics.stoptiming (lxml)}} -\def\doxmlprocess#1#2#3#4#5% +\def\doxmlprocess#1#2#3#4#5% flag \loader id name what initializersetup {\begingroup \edef\xmldocument{#3}% #2 can be \xmldocument and set as such %xmlpushdocument{#3}% @@ -184,13 +185,13 @@ \stopxmlsetups \startxmlsetups xml:process - \xmlregistereddocumentsetups{#1} + \xmlregistereddocumentsetups{#1}{#1} \xmlmain{#1} \stopxmlsetups \def\xmlloadonly#1#2#3% {\xmlload{#1}{#2}% - \xmlregistereddocumentsetups{#3}} + \xmlregistereddocumentsetups{#1}{#3}} % beware: \xmlmain takes the real root, so also processing % instructions preceding the root element; well, in some diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index fe4a5f3e2..56bb0ab15 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -10,7 +10,7 @@ local utf = unicode.utf8 local utfchar = utf.char local concat, insert, remove, gsub, find = table.concat, table.insert, table.remove -local format, sub, gsub, find = string.format, string.sub, string.gsub, string.find +local format, sub, gsub, find, gmatch = string.format, string.sub, string.gsub, string.find, string.gmatch local type, next, tonumber, tostring = type, next, tonumber, tostring if not tex and not tex.sprint then @@ -173,7 +173,8 @@ function lxml.store(id,root,filename) end end -local splitter = lpeg.C((1-lpeg.P(":"))^1) * lpeg.P("::") * lpeg.C(lpeg.P(1)^1) +--~ local splitter = lpeg.C((1-lpeg.P(":"))^1) * lpeg.P("::") * lpeg.C(lpeg.P(1)^1) +local splitter = lpeg.splitat("::") lxml.idsplitter = splitter @@ -282,6 +283,12 @@ end lxml.filter = lxmlparseapply +function lxml.filterlist(list,pattern) + for s in gmatch(list,"[^, ]+") do -- we could cache a table + lxmlparseapply(s,pattern) + end +end + lxml["function"] = function(id,name) local f = xml.functions[name] return f and f(get_id(id)) @@ -689,7 +696,7 @@ function lxml.installsetup(what,document,setup,where) end end -function lxml.flushsetups(...) +function lxml.flushsetups(id,...) local done = { } for _, document in ipairs({...}) do local sd = setups[document] @@ -700,7 +707,8 @@ function lxml.flushsetups(...) if trace_loading then commands.writestatus("lxml","applying setup %02i = %s to %s",k,v,document) end - texsprint(ctxcatcodes,"\\directsetup{",v,"}") +--~ texsprint(ctxcatcodes,"\\directsetup{",v,"}") + texsprint(ctxcatcodes,"\\xmlsetup{",id,"}{",v,"}") done[v] = true end end diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv index c2dbfb774..4b2731a7e 100644 --- a/tex/context/base/page-lin.mkiv +++ b/tex/context/base/page-lin.mkiv @@ -34,22 +34,23 @@ \newconditional\tracelinenumbering -\def\mkaddtextlinenumbers#1#2#3% box col max - {\bgroup - \def\skipnumber{\hbox{}}% - \ifcase#3\relax - \let\makenumber\mkskiplinenumber - \or - \let\makenumber\mkleftlinenumber - \else\ifcase#2\relax - \let\makenumber\mkskiplinenumber - \or - \let\makenumber\mkleftlinenumber - \else - \let\makenumber\mkrightlinenumber - \fi\fi - \mkprocesstextlinenumbers{#1}% - \egroup} +% \def\mkaddtextlinenumbers#1#2#3% box col max +% {\bgroup +% \fullrestoreglobalbodyfont +% \def\skipnumber{\hbox{}}% +% \ifcase#3\relax +% \let\makenumber\mkskiplinenumber +% \or +% \let\makenumber\mkleftlinenumber +% \else\ifcase#2\relax +% \let\makenumber\mkskiplinenumber +% \or +% \let\makenumber\mkleftlinenumber +% \else +% \let\makenumber\mkrightlinenumber +% \fi\fi +% \mkprocesstextlinenumbers{#1}% +% \egroup} \def\mkprocesstextlinenumbers#1% {\setbox\linenumberscratchbox\vbox{\forgetall\offinterlineskip\ctxlua{nodes.lines.boxed.stage_one(\number#1)}}% @@ -57,9 +58,9 @@ % id nr shift width leftskip -\def\mkskiplinenumber #1#2#3#4#5{} -\def\mkleftlinenumber #1#2#3#4#5{\hbox{\llap{#2\quad\hskip#3\scaledpoint}}} -\def\mkrightlinenumber#1#2#3#4#5{\hbox{\rlap{\hskip#4\scaledpoint\hskip#3\scaledpoint\quad#2}}} +% \def\mkskiplinenumber #1#2#3#4#5{} +% \def\mkleftlinenumber #1#2#3#4#5{\hbox{\llap{#2\quad\hskip#3\scaledpoint}}} +% \def\mkrightlinenumber#1#2#3#4#5{\hbox{\rlap{\hskip#4\scaledpoint\hskip#3\scaledpoint\quad#2}}} \def\makenumber#1#2{\hbox{\llap{#1\quad\hskip#2\scaledpoint}}\endgraf}% @@ -267,15 +268,30 @@ \def\mkaddtextlinenumbers#1#2#3% box col max {\bgroup + \chardef\linenumberlocation \executeifdefined{\??rn:l:\linenumberparameter\c!location}\plusone % left + \chardef\linenumberalignment\executeifdefined{\??rn:a:\linenumberparameter\c!align }\plusfive % auto + \fullrestoreglobalbodyfont \def\skipnumber{\hbox{}}% \ifcase#3\relax \let\makenumber\mkskiplinenumber \or - \let\makenumber\mkleftlinenumber + % one column + \ifcase\linenumberlocation + % hm + \or + \let\makenumber\mkleftlinenumber + \or + \let\makenumber\mkrightlinenumber + \or % inner + \let\makenumber\mkdoinnerlinenumber + \or % outer + \let\makenumber\mkdoouterlinenumber + \or % text + \fi \else\ifcase#2\relax \let\makenumber\mkskiplinenumber \or - \let\makenumber\mkdoleftlinenumber + \let\makenumber\mkleftlinenumber \ifcase\linenumberlocation\or \chardef\linenumberlocation\plusone \or @@ -288,7 +304,7 @@ \chardef\linenumberlocation\plusone \fi \else - \let\makenumber\mkdorightlinenumber + \let\makenumber\mkrightlinenumber \ifcase\linenumberlocation\or \chardef\linenumberlocation\plustwo \or @@ -310,8 +326,9 @@ \def\dosomelinenumber#1#2#3#4% tag 1=left|2=right linenumber leftskip {\begingroup \def\currentlinenumbering{#1}% - \chardef\linenumberlocation \executeifdefined{\??rn:l:\linenumberparameter\c!location}\plusone % left - \chardef\linenumberalignment\executeifdefined{\??rn:a:\linenumberparameter\c!align }\plusfive % auto + \def\linenumber{#3}% unsafe +% \chardef\linenumberlocation \executeifdefined{\??rn:l:\linenumberparameter\c!location}\plusone % left +% \chardef\linenumberalignment\executeifdefined{\??rn:a:\linenumberparameter\c!align }\plusfive % auto \doifelse{\linenumberparameter\c!width}\v!margin {\linenumberwidth\leftmarginwidth} {\linenumberwidth\linenumberparameter\c!width}% @@ -411,7 +428,7 @@ \protect \endinput -\iffalse % \iftrue +\iffalse % \iftrue eventually we will do it like ... \appendtoks\ctxlua{nodes.lines.flowed.prepare()}\to\everyshipout \appendtoks\ctxlua{nodes.lines.flowed.cleanup()}\to\everybye diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index c17e6044c..1b7443840 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -64,7 +64,7 @@ {\edef\currentnofitems {\ctxlua{structure.itemgroups.nofitems("\currentitemgroup",\number\currentnoflists)}}% \edef\currentitemmaxwidth{\ctxlua{structure.itemgroups.maxwidth("\currentitemgroup",\number\currentnoflists)}\scaledpoint}} -% todo: \dodosetreference +% todo: \dodosetreference -> \dostructurecountercomponent (to be checked) \def\dohandleitemreference % we will make a decent number helper {\ifx\currentitemreference \empty \else @@ -80,6 +80,16 @@ internal = \nextinternalreference, section = structure.sections.currentid(), }, + prefixdata = structure.helpers.simplify { + prefix = "\structurecounterparameter\currentitemgroupcounter\c!prefix", + separatorset = "\structurecounterparameter\currentitemgroupcounter\c!prefixseparatorset", + conversion = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconversion\!!es, + conversionset = "\structurecounterparameter\currentitemgroupcounter\c!prefixconversionset", + set = "\structurecounterparameter\currentitemgroupcounter\c!prefixset", + segments = "\structurecounterparameter\currentitemgroupcounter\c!prefixsegments", + % segments = "\askedprefixsegments", + connector = \!!bs\structurecounterparameter\currentitemgroupcounter\c!prefixconnector\!!es, + }, numberdata = structure.helpers.simplify { numbers = structure.counters.compact("\currentitemgroupcounter",nil,true), separatorset = "\structurecounterparameter\currentitemgroupcounter\c!numberseparatorset", @@ -95,6 +105,7 @@ \begingroup\dosetattribute{destination}\currentitemattribute\kern\zeropoint\endgroup % todo \fi} + % \startitemize[n,packed] % \item test \item test \item test % \stopitemize @@ -420,7 +431,15 @@ {\begingroup \setupstructurecounter [\currentitemgroupcounter] - [\c!prefix=\v!no, + [%\c!prefix=\v!no, + \c!prefix=\getitemparameter\currentitemlevel\c!prefix, + \c!prefixstopper=\getitemparameter\currentitemlevel\c!prefixstopper, + \c!prefixseparatorset=\getitemparameter\currentitemlevel\c!prefixseparatorset, + \c!prefixconversion=\getitemparameter\currentitemlevel\c!prefixconversion, + \c!prefixconversionset=\getitemparameter\currentitemlevel\c!prefixseparatorset, + \c!prefixset=\getitemparameter\currentitemlevel\c!prefixset, + \c!prefixsegments=\getitemparameter\currentitemlevel\c!prefixsegments, + \c!prefixconnector=\getitemparameter\currentitemlevel\c!prefixconnector, \c!criterium=\getitemparameter\currentitemlevel\c!criterium, \c!numberorder=\ifconditional\reverselistitem\v!reverse\else\v!normal\fi, \c!numberstopper=\expdoif{\getitemparameter\currentitemlevel\c!placestopper}\v!yes{\getitemparameter\currentitemlevel\c!stopper}, @@ -1238,7 +1257,16 @@ \c!symbol=\currentitemlevel] \setupitemgroups - [\c!numberseparatorset=, + [\c!prefix=\v!no, +% \c!prefixstopper=., +% \c!prefixseparatorset=, +% \c!prefixconversion=, +% \c!prefixconversionset=, +% \c!prefixset=, +% \c!prefixsegments=1:100, + \c!prefixconnector=., + % + \c!numberseparatorset=, \c!numberconversionset=, \c!numberstopper=., \c!numbersegments=1] diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv index 5ae161456..ac0c54e05 100644 --- a/tex/context/base/strc-num.mkiv +++ b/tex/context/base/strc-num.mkiv @@ -431,8 +431,8 @@ conversion = \!!bs#3\c!prefixconversion\!!es, conversionset = "#3\c!prefixconversionset", set = "#3\c!prefixset", -% segments = "#3\c!prefixsegments", -segments = "\askedprefixsegments", + % segments = "#3\c!prefixsegments", + segments = "\askedprefixsegments", connector = \!!bs#3\c!prefixconnector\!!es, }, numberdata = { diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua index 7edd91f77..d7340f498 100644 --- a/tex/context/base/strc-pag.lua +++ b/tex/context/base/strc-pag.lua @@ -191,7 +191,7 @@ function helpers.analyse(entry,specification) if not entry then return false, false, "no entry" end - local no = variables.no + local yes, no = variables.yes, variables.no -- section data local references = entry.references if not references then @@ -220,7 +220,7 @@ end function helpers.prefix(data,prefixspec) if data then - local _, prefixdata = helpers.analyse(data,prefixspec) + local _, prefixdata, status = helpers.analyse(data,prefixspec) if prefixdata then sections.typesetnumber(prefixdata,"prefix",prefixspec or false,data.prefixdata or false,prefixdata or false) end diff --git a/tex/context/base/supp-ran.lua b/tex/context/base/supp-ran.lua index 9e4330f57..a0e3d1cf6 100644 --- a/tex/context/base/supp-ran.lua +++ b/tex/context/base/supp-ran.lua @@ -11,7 +11,14 @@ if not modules then modules = { } end modules ['supp-ran'] = { commands = commands or { } -local texwrite, random, seed, last = tex.write, math.random, false, 1 +local texwrite, random, randomseed, round, seed, last = tex.write, math.random, math.randomseed, math.round, false, 1 + +function math.setrandomseedi(n) + if n <= 1 then + n = n*1073741823 -- maxcount + end + randomseed(round(n)) +end function commands.getrandomcounta(min,max) last = random(min,max) @@ -25,7 +32,7 @@ end function commands.setrandomseed(n) last = n - math.randomseed(n) + math.setrandomseedi(n) end function commands.getrandomseed(n) @@ -40,7 +47,7 @@ end function commands.defrostrandomseed() if seed ~= false then - math.randomseed(last) + math.setrandomseedi(last) seed = false end end diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index 639cac03e..937838364 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -123,12 +123,11 @@ \startxmlsetups xml:setups:register \xmlsetup{#1}{xml:setups:assemblename} - %expanded{\texcommand[stp:x:\currentSETUPfullname]{\currentSETUPfullname}} \expanded{\texcommand[stp:x:\currentSETUPfullname]{#1}} \stopxmlsetups \startxmlsetups xml:setups:basics - \xmlsetsetup {setups} { + \xmlsetsetup {#1} { sequence|string|variable|assignments|keywords|content|displaymath|index|math| nothing|file|position|reference|csname|destination|triplet|word| resolve|parameter|constant|inherit|parameter|define @@ -139,15 +138,17 @@ \def\loadsetups{\complexorsimple\loadsetups} +\let\loadedsetups\empty % we load more setups, setups:<name> + \def\simpleloadsetups {\doifnotmode{no-setup-main}{\complexloadsetups[cont-en.xml]}} \def\complexloadsetups[#1]% {\doifsomething{#1} {\doonlyonce{setups:#1} - {\xmlloadonly{setups}{#1}{setups}% -% \xmlcommand{setups}{/interface/command}{xml:setups:register}}}} % qualified path saves > 50% runtime - \xmlfilter{setups}{/interface/command/command(xml:setups:register)}}}} % qualified path saves > 50% runtime + {\doglobal\prependtocommalist{setups:#1}\loadedsetups % last overloads first + \xmlloadonly{setups:#1}{#1}{setups}% + \xmlfilter{setups:#1}{/interface/command/command(xml:setups:register)}}}} % qualified path saves > 50% runtime \newif\ifshortsetup @@ -176,8 +177,7 @@ \showsetupindeed{#1}} \def\showsetupindeed#1% -% {\xmlcommand{setups}{/interface/command[@name='#1']}{xml:setups:typeset}} - {\xmlfilter{setups}{/interface/command[@name='#1']/command(xml:setups:typeset)}} + {\xmlfilterlist{\loadedsetups}{/interface/command[@name='#1']/command(xml:setups:typeset)}} \def\placesetup {\placelistofsorts[texcommand][\c!criterium=\v!used]} \def\placeallsetups{\placelistofsorts[texcommand][\c!criterium=\v!all ]} @@ -213,7 +213,6 @@ } { \tex{} } -% \xmlfirst{#1}{/sequence} \xmlfilter{#1}{/sequence/first()} \ignorespaces \egroup @@ -222,7 +221,6 @@ \enablemode[setups-pass-one] \doglobal\newcounter\currentSETUPargument \ignorespaces -% \xmltext{#1}{/arguments} \xmlfilter{#1}{/arguments/text()} \egroup } @@ -233,7 +231,6 @@ \ttsl } \tex{\e!stop} -% \xmlfirst{#1}{/sequence/variable} \xmlfilter{#1}{/sequence/variable/first()} \ignorespaces \egroup @@ -245,7 +242,6 @@ \doglobal\newcounter\currentSETUPargument \blank[\v!line] \switchtobodyfont[small] -% \ignorespaces\xmltext{#1}{/arguments}\endgraf \ignorespaces\xmlfilter{#1}{/arguments/text()}\endgraf \egroup } @@ -260,8 +256,7 @@ \startxmlsetups xml:setups:resolve \ignorespaces -% \xmlfirst{setups}{define[@name='\xmlatt{#1}{name}']} - \xmlfilter{setups}{/interface/define[@name='\xmlatt{#1}{name}']/first()} + \xmlfilterlist{\loadedsetups}{/interface/define[@name='\xmlatt{#1}{name}']/first()} \stopxmlsetups %D This is the first pass; here we generate the top line. @@ -332,17 +327,12 @@ } { \xdef\currentSETUPwidth{0pt}% \bgroup -% \xmlcommand{#1}{/parameter}{xml:setups:parameter:measure} \xmlfilter{#1}{/parameter/command(xml:setups:parameter:measure)} \egroup \startfirstSETUPcolumn{\showSETUPnumber}% -% \xmldoifelseempty {#1} {} { - \ignorespaces - \xmlflush{#1} - \let\previousSETUPargument\currentSETUPargument -% } { -% \secondSETUPcolumn{\c!setup!text!{see} \previousSETUPargument}{} -% } + \ignorespaces + \xmlflush{#1} + \let\previousSETUPargument\currentSETUPargument \stopfirstSETUPcolumn \blank[\v!halfline] \ignorespaces @@ -354,13 +344,9 @@ \showSETUPkeyword{#1} } { \startfirstSETUPcolumn{\showSETUPnumber}% -% \xmldoifelseempty {#1} {} { - \ignorespaces - \xmlflush{#1} - \let\previousSETUPargument\currentSETUPargument -% }{ -% \secondSETUPcolumn{see \previousSETUPargument}{} -% } + \ignorespaces + \xmlflush{#1} + \let\previousSETUPargument\currentSETUPargument \stopfirstSETUPcolumn \blank[\v!halfline] \ignorespaces |