From 43986f8edd2afd919afbb9988cb6778fc3c02077 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 25 Sep 2009 09:42:00 +0200 Subject: beta 2009.09.25 09:42 --- tex/context/base/buff-ini.mkii | 8 +- tex/context/base/buff-ini.mkiv | 4 +- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.mkiv | 7 +- tex/context/base/context.tex | 2 +- tex/context/base/lxml-ini.lua | 36 +- tex/context/base/lxml-ini.mkiv | 17 +- tex/context/base/lxml-pth.lua | 80 +- tex/context/base/lxml-tab.lua | 11 +- tex/context/base/m-chart.mkii | 48 + tex/context/base/m-chart.mkiv | 20 + tex/context/base/m-chart.tex | 36 +- tex/context/base/m-punk.mkiv | 232 ++ tex/context/base/m-punk.tex | 232 -- tex/context/base/m-steps.mkii | 83 + tex/context/base/m-steps.mkiv | 20 + tex/context/base/m-steps.tex | 69 - tex/context/base/page-ini.mkiv | 5 +- tex/context/base/spac-ver.lua | 90 +- tex/context/base/spac-ver.mkiv | 25 +- tex/context/base/strc-itm.mkiv | 16 +- tex/context/base/strc-not.mkiv | 7 +- tex/context/base/strc-sec.mkiv | 64 +- tex/context/base/x-calcmath.mkiv | 2 - tex/context/base/x-contml.mkii | 491 ++++ tex/context/base/x-contml.tex | 493 ---- tex/context/base/x-corres.mkii | 136 + tex/context/base/x-corres.tex | 136 - tex/context/base/x-fe.mkii | 143 + tex/context/base/x-fe.tex | 143 - tex/context/base/x-fo.mkii | 4059 +++++++++++++++++++++++++++ tex/context/base/x-fo.tex | 4059 --------------------------- tex/context/base/x-foxet.mkii | 28 + tex/context/base/x-foxet.mkiv | 29 + tex/context/base/x-foxet.tex | 15 - tex/context/base/x-pending.mkiv | 38 + tex/context/base/x-set-11.mkiv | 37 +- tex/context/base/x-set-12.tex | 4 +- tex/context/base/x-xtag.mkiv | 23 + tex/context/interface/cont-cs.xml | 1 + tex/context/interface/cont-de.xml | 1 + tex/context/interface/cont-en.xml | 1 + tex/context/interface/cont-fr.xml | 1 + tex/context/interface/cont-it.xml | 1 + tex/context/interface/cont-nl.xml | 1 + tex/context/interface/cont-pe.xml | 1 + tex/context/interface/cont-ro.xml | 1 + tex/generic/context/luatex-fonts-merged.lua | 2 +- 48 files changed, 5630 insertions(+), 5330 deletions(-) create mode 100644 tex/context/base/m-chart.mkii create mode 100644 tex/context/base/m-chart.mkiv create mode 100644 tex/context/base/m-punk.mkiv delete mode 100644 tex/context/base/m-punk.tex create mode 100644 tex/context/base/m-steps.mkii create mode 100644 tex/context/base/m-steps.mkiv create mode 100644 tex/context/base/x-contml.mkii delete mode 100644 tex/context/base/x-contml.tex create mode 100644 tex/context/base/x-corres.mkii delete mode 100644 tex/context/base/x-corres.tex create mode 100644 tex/context/base/x-fe.mkii delete mode 100644 tex/context/base/x-fe.tex create mode 100644 tex/context/base/x-fo.mkii delete mode 100644 tex/context/base/x-fo.tex create mode 100644 tex/context/base/x-foxet.mkii create mode 100644 tex/context/base/x-foxet.mkiv delete mode 100644 tex/context/base/x-foxet.tex create mode 100644 tex/context/base/x-pending.mkiv create mode 100644 tex/context/base/x-xtag.mkiv (limited to 'tex') diff --git a/tex/context/base/buff-ini.mkii b/tex/context/base/buff-ini.mkii index 0f0655ea1..fc147d090 100644 --- a/tex/context/base/buff-ini.mkii +++ b/tex/context/base/buff-ini.mkii @@ -188,15 +188,15 @@ \letvalue{\??bu#1\c!number }\nofdefinedbuffers \letvalue{\??bu#1\c!paragraph}\v!no \setevalue{\e!start#1}{\noexpand\dostartbuffer[#1][def-\nofdefinedbuffers][\e!start#1][\e!stop#1]}% - \setevalue{\e!get #1}{\noexpand\dogetbuffer [#1][def-\nofdefinedbuffers]}% - \setevalue{\e!type #1}{\noexpand\dotypebuffer [#1][def-\nofdefinedbuffers]}% + \unexpanded\setevalue{\e!get #1}{\noexpand\dogetbuffer [#1][def-\nofdefinedbuffers]}% + \unexpanded\setevalue{\e!type #1}{\noexpand\dotypebuffer [#1][def-\nofdefinedbuffers]}% \getparameters[\??bu#1][#2]% \fi} \def\definebuffer {\dodoubleempty\dodefinebuffer} -\def\getbuffer +\unexpanded\def\getbuffer {\dodoubleempty\dogetbuffer} \def\dogetbuffer[#1][#2]% @@ -213,7 +213,7 @@ \dobuffer{16}{#2}\dogetbufferasis \getvalue{\??bu#1\c!after}} -\def\typebuffer +\unexpanded\def\typebuffer {\dodoubleempty\dotypebuffer} \def\dogetfilebuffer{\typefile{\TEXbufferfile{\currentbuffer}}} diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 0c258a81d..1cdeaa844 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -162,8 +162,8 @@ \letvalue{\??bu#1\c!number }\nofdefinedbuffers \letvalue{\??bu#1\c!paragraph}\v!no \setevalue{\e!start#1}{\noexpand\dostartbuffer[#1][def-\nofdefinedbuffers][\e!start#1][\e!stop#1]}% - \setevalue{\e!get #1}{\noexpand\dogetbuffer [#1][def-\nofdefinedbuffers]}% - \setevalue{\e!type #1}{\noexpand\dotypebuffer [#1][def-\nofdefinedbuffers]}% + \unexpanded\setevalue{\e!get #1}{\noexpand\dogetbuffer [#1][def-\nofdefinedbuffers]}% + \unexpanded\setevalue{\e!type #1}{\noexpand\dotypebuffer [#1][def-\nofdefinedbuffers]}% \getparameters[\??bu#1][#2]% \fi} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 5f255585e..02117c4b8 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.23 10:07} +\newcontextversion{2009.09.25 09:42} %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.mkiv b/tex/context/base/context.mkiv index 387c8aa90..378a00873 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -315,12 +315,7 @@ \loadmarkfile{bibl-bib} \loadmarkfile{bibl-tra} -\loadcorefile{xtag-ini} % might go away -\loadcorefile{xtag-ext} % might go away -\loadcorefile{xtag-exp} % will go away -\loadcorefile{xtag-pre} % has old encoding code -\loadcorefile{xtag-xsd} % will go away (stub anyway) -\loadcorefile{xtag-rng} % will go away (stub anyway) +\loadmarkfile{x-xtag} % at some point this will nto be preloaded \loadcorefile{meta-xml} diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 9ba4f8287..3bba2b9d0 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.23 10:07} +\edef\contextversion{2009.09.25 09:42} %D For those who want to use this: diff --git a/tex/context/base/lxml-ini.lua b/tex/context/base/lxml-ini.lua index 8db90c960..d837dfd6d 100644 --- a/tex/context/base/lxml-ini.lua +++ b/tex/context/base/lxml-ini.lua @@ -58,7 +58,7 @@ end local traverse, lpath = xml.traverse, xml.lpath -local xmlfilter, xmlfirst, xmllast, xmlall = xml.filter, xml.first, xml.last, xml.all +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 @@ -460,9 +460,9 @@ function lxml.include(id,pattern,attribute,recurse) xml.include(get_id(id),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) -end + if file.dirname(filename) == "" then + filename = file.join(file.dirname(paths[currentdocument]),filename) + end if trace_loading then commands.writestatus("lxml","including file: %s",filename) end @@ -515,6 +515,7 @@ function lxml.strip(id,pattern,nolines) end function lxml.text(id,pattern) + -- we can avoid some steps by passing xmlsprint xmltprint(xmlcollect_texts(get_id(id),pattern) or {}) end @@ -614,7 +615,7 @@ function lxml.chainattribute(id,pattern,a,default) --todo: snelle xmlatt end function lxml.count(id,pattern) - texsprint(xml.count(get_id(id),pattern) or 0) + texsprint(xmlcount(get_id(id),pattern) or 0) end function lxml.nofelements(id) local e = get_id(id) @@ -653,7 +654,7 @@ end --~ end function lxml.concatrange(id,what,start,stop,separator,lastseparator) -- test this on mml - local t = xmlcollect_elements(lxml.id(id),what,true) -- ignorespaces + local t = xmlcollect_elements(get_id(id),what,true) -- ignorespaces local separator = separator or "" local lastseparator = lastseparator or separator or "" start, stop = (start == "" and 1) or tonumber(start) or 1, (stop == "" and #t) or tonumber(stop) or #t @@ -687,7 +688,7 @@ end -- we use a real tex.sprint, else spaces go wrong -- maybe just a .. because this happens often -function xml.command(root, command) +function lxml.serialize(root, command) local tc = type(command) if tc == "string" then -- setup @@ -699,7 +700,8 @@ function xml.command(root, command) --~ lxml.addindex(root) --~ ix = root.ix --~ end - texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",ix,command)) +--~ texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",ix,command)) + texsprint(ctxcatcodes,format("\\xmls{%s}{%s}",ix,command)) elseif tc == "function" then -- function command(root) @@ -713,6 +715,8 @@ function xml.command(root, command) end end +xml.setserializer(lxml.serialize) + function lxml.setaction(id,pattern,action) for rt, dt, dk in xmlelements(get_id(id),pattern) do dt[dk].command = action @@ -1292,19 +1296,21 @@ end local found, isempty = xml.found, xml.isempty -function lxml.doif (id,pattern) commands.doif (found(get_id(id),pattern,false)) end -function lxml.doifnot (id,pattern) commands.doifnot (found(get_id(id),pattern,false)) end -function lxml.doifelse (id,pattern) commands.doifelse(found(get_id(id),pattern,false)) end +local doif, doifnot, doifelse = commands.doif, commands.doifnot, commands.doifelse + +function lxml.doif (id,pattern) doif (found(get_id(id),pattern,false)) end +function lxml.doifnot (id,pattern) doifnot (found(get_id(id),pattern,false)) end +function lxml.doifelse (id,pattern) doifelse(found(get_id(id),pattern,false)) end -- todo: if no second arg or second arg == "" then quick test -function lxml.doiftext (id,pattern) commands.doif (found (get_id(id),pattern,true)) end -function lxml.doifnottext (id,pattern) commands.doifnot (found (get_id(id),pattern,true)) end -function lxml.doifelsetext (id,pattern) commands.doifelse(found (get_id(id),pattern,true)) end +function lxml.doiftext (id,pattern) doif (found (get_id(id),pattern,true)) end +function lxml.doifnottext (id,pattern) doifnot (found (get_id(id),pattern,true)) end +function lxml.doifelsetext (id,pattern) doifelse(found (get_id(id),pattern,true)) end -- special case: "*" and "" -> self else lpath lookup -function lxml.doifelseempty(id,pattern) commands.doifelse(isempty(get_id(id),pattern ~= "" and pattern ~= nil)) end -- not yet done, pattern +function lxml.doifelseempty(id,pattern) doifelse(isempty(get_id(id),pattern ~= "" and pattern ~= nil)) end -- not yet done, pattern -- status info diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 81a611bf1..02703d2da 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -115,6 +115,8 @@ {\def\xmlself{#1}% % by using #1 inside a setup; maybe self becomes obsolete \setupwithargument{#2}{#1}} +\let\xmls\xmlsetup + \newtoks \registeredxmlsetups % todo: 1:xml:whatever alwas before 3:xml:something @@ -157,9 +159,6 @@ \def\xmlstarttiming{\ctxlua{statistics.starttiming(lxml)}} \def\xmlstoptiming {\ctxlua{statistics.stoptiming (lxml)}} -\def\xmlpushdocument#1{\ctxlua{lxml.pushdocument("#1")}} -\def\xmlpopdocument {\ctxlua{lxml.popdocument()}} - \def\doxmlprocess#1#2#3#4#5% {\begingroup \edef\xmldocument{#3}% #2 can be \xmldocument and set as such @@ -416,11 +415,13 @@ %D Experimental: -\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}} +\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} diff --git a/tex/context/base/lxml-pth.lua b/tex/context/base/lxml-pth.lua index ab78af1dc..e0520edbd 100644 --- a/tex/context/base/lxml-pth.lua +++ b/tex/context/base/lxml-pth.lua @@ -17,11 +17,7 @@ functions that set the tracers. Here we overload a previously defined function.

--ldx]]-- -local trace_lpath = false - -if trackers then - trackers.register("xml.lpath", function(v) trace_lpath = v end) -end +local trace_lpath = false if trackers then trackers.register("xml.lpath", function(v) trace_lpath = v end) end local settrace = xml.settrace -- lxml-tab @@ -797,17 +793,19 @@ local r, d, k = xml.filter(root,"/a/b/c/position(4)" --ldx]]-- +xml.filters = { } + local traverse, lpath, convert = xml.traverse, xml.lpath, xml.convert -xml.filters = { } +local filters = xml.filters -function xml.filters.default(root,pattern) +function filters.default(root,pattern) local rt, dt, dk traverse(root, lpath(pattern), function(r,d,k) rt,dt,dk = r,d,k return true end) return dt and dt[dk], rt, dt, dk end -function xml.filters.attributes(root,pattern,arguments) +function filters.attributes(root,pattern,arguments) local rt, dt, dk traverse(root, lpath(pattern), function(r,d,k) rt, dt, dk = r, d, k return true end) local ekat = (dt and dt[dk] and dt[dk].at) or (rt and rt.at) @@ -828,7 +826,7 @@ local rt, dt, dk local function action(r,d,k) rt, dt, dk = r, d, k return true end -function xml.filters.chainattribute(root,pattern,arguments) -- todo: optional levels +function filters.chainattribute(root,pattern,arguments) -- todo: optional levels rt, dt, dk = nil, nil, nil traverse(root, lpath(pattern), action) local dtk = dt and dt[dk] @@ -852,13 +850,13 @@ end -- -function xml.filters.reverse(root,pattern) +function filters.reverse(root,pattern) local rt, dt, dk traverse(root, lpath(pattern), function(r,d,k) rt,dt,dk = r,d,k return true end, 'reverse') return dt and dt[dk], rt, dt, dk end -function xml.filters.count(root,pattern,everything) +function filters.count(root,pattern,everything) local n = 0 traverse(root, lpath(pattern), function(r,d,t) if everything or type(d[t]) == "table" then @@ -868,7 +866,19 @@ function xml.filters.count(root,pattern,everything) return n end -function xml.filters.elements(root, pattern) -- == all +--~ local n = 0 +--~ local function doit(r,d,t) +--~ if everything or type(d[t]) == "table" then +--~ n = n + 1 +--~ end +--~ end +--~ function filters.count(root,pattern,everything) +--~ n = 0 +--~ traverse(root, lpath(pattern), doit) +--~ return n +--~ end + +function filters.elements(root, pattern) -- == all local t = { } traverse(root, lpath(pattern), function(r,d,k) local e = d[k] @@ -879,7 +889,7 @@ function xml.filters.elements(root, pattern) -- == all return t end -function xml.filters.texts(root, pattern) +function filters.texts(root, pattern) local t = { } traverse(root, lpath(pattern), function(r,d,k) local e = d[k] @@ -890,19 +900,19 @@ function xml.filters.texts(root, pattern) return t end -function xml.filters.first(root,pattern) +function filters.first(root,pattern) local rt, dt, dk traverse(root, lpath(pattern), function(r,d,k) rt,dt,dk = r,d,k return true end) return dt and dt[dk], rt, dt, dk end -function xml.filters.last(root,pattern) +function filters.last(root,pattern) local rt, dt, dk traverse(root, lpath(pattern), function(r,d,k) rt,dt,dk = r,d,k return true end, 'reverse') return dt and dt[dk], rt, dt, dk end -function xml.filters.index(root,pattern,arguments) +function filters.index(root,pattern,arguments) local rt, dt, dk, reverse, i = nil, nil, nil, false, tonumber(arguments or '1') or 1 if i and i ~= 0 then if i < 0 then @@ -916,16 +926,25 @@ function xml.filters.index(root,pattern,arguments) return nil, nil, nil, nil end -function xml.filters.attribute(root,pattern,arguments) - local rt, dt, dk - traverse(root, lpath(pattern), function(r,d,k) rt, dt, dk = r, d, k return true end) - local ekat = (dt and dt[dk] and dt[dk].at) or (rt and rt.at) - -- return (ekat and (ekat[arguments] or ekat[gsub(arguments,"^([\"\'])(.*)%1$","%2")])) or "" +--~ function filters.attribute(root,pattern,arguments) +--~ local rt, dt, dk +--~ traverse(root, lpath(pattern), function(r,d,k) rt, dt, dk = r, d, k return true end) +--~ local ekat = (dt and dt[dk] and dt[dk].at) or (rt and rt.at) +--~ return (ekat and (ekat[arguments] or (find(arguments,"^[\'\"]") and ekat[sub(arguments,2,-2)]))) or "" +--~ end + +local rt, dt, dk +local function doit(r,d,k) rt, dt, dk = r, d, k return true end +function filters.attribute(root,pattern,arguments) + rt, dt, dk = nil, nil, nil + traverse(root, lpath(pattern), doit) + local dtk = dt and dt[k] + local ekat = (dtk and dtk.at) or (rt and rt.at) return (ekat and (ekat[arguments] or (find(arguments,"^[\'\"]") and ekat[sub(arguments,2,-2)]))) or "" end -function xml.filters.text(root,pattern,arguments) -- ?? why index, tostring slow - local dtk, rt, dt, dk = xml.filters.index(root,pattern,arguments) +function filters.text(root,pattern,arguments) -- ?? why index, tostring slow + local dtk, rt, dt, dk = filters.index(root,pattern,arguments) if dtk then -- n local dtkdt = dtk.dt if not dtkdt then @@ -940,7 +959,7 @@ function xml.filters.text(root,pattern,arguments) -- ?? why index, tostring slow end end -function xml.filters.tag(root,pattern,n) +function filters.tag(root,pattern,n) local tag = "" traverse(root, lpath(pattern), function(r,d,k) tag = xml.functions.tag(d,k,n and tonumber(n)) @@ -949,7 +968,7 @@ function xml.filters.tag(root,pattern,n) return tag end -function xml.filters.name(root,pattern,n) +function filters.name(root,pattern,n) local tag = "" traverse(root, lpath(pattern), function(r,d,k) tag = xml.functions.name(d,k,n and tonumber(n)) @@ -1054,13 +1073,13 @@ function xml.collect_texts(root, pattern, flatten) if tx then t[#t+1] = xml.tostring(tx) or "" else - t[#t+1] = "" + t[#t+1] = "" -- hm end else t[#t+1] = tx or "" end else - t[#t+1] = "" + t[#t+1] = "" -- hm end end) return t @@ -1068,7 +1087,7 @@ end function xml.collect_tags(root, pattern, nonamespace) local t = { } - xml.traverse(root, xml.lpath(pattern), function(r,d,k) + xml.traverse(root, lpath(pattern), function(r,d,k) local dk = d and d[k] if dk and type(dk) == "table" then local ns, tg = e.ns, e.tg @@ -1128,6 +1147,11 @@ function xml.each_element(root, pattern, handle, reverse) return ok end +--~ todo: +--~ +--~ function xml.process_elements(root, pattern, handle) +--~ traverse(root, lpath(pattern), fnc, nil, nil, nil, handle) -> fnc gets r, d, k and handle (...) passed + function xml.process_elements(root, pattern, handle) traverse(root, lpath(pattern), function(r,d,k) local dkdt = d[k].dt diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 407950086..52e04befd 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -500,6 +500,12 @@ alternative.

local fallbackhandle = (tex and tex.sprint) or io.write +local serializer + +function xml.setserializer(f) + serializer = f +end + local function serialize(e, handle, textconverter, attributeconverter, specialconverter, nocommands) if not e then return @@ -519,9 +525,8 @@ local function serialize(e, handle, textconverter, attributeconverter, specialco end end end - local xc = xml.command - if xc then - xc(e,ec) + if serializer then + serializer(e,ec) return end end diff --git a/tex/context/base/m-chart.mkii b/tex/context/base/m-chart.mkii new file mode 100644 index 000000000..2554fa2d4 --- /dev/null +++ b/tex/context/base/m-chart.mkii @@ -0,0 +1,48 @@ +%D \module +%D [ file=m-chart, +%D version=1998.10.10, +%D title=\CONTEXT\ Modules, +%D subtitle=Flow Charts, +%D author={Hans Hagen \& Ton Otten}, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The \XML\ interface: + +\unprotect + +\startXMLdefinitions flowchart + +\defineXMLargument [flowchartdefinition] + {\defineFLOWchart[\XMLpar{flowchartdefinition}{identifier}{unknown}]} + +\defineXMLpickup [flowcell] + {\startFLOWcell + \defineXMLargument[name]{\unspaceafter\name}% + \defineXMLargument[shape]{\unspaceafter\shape}% + \defineXMLnestedargument[text]{\text}} + {\stopFLOWcell} + +\defineXMLenvironment [location] % global unspace/store + {\bgroup\defineXMLpush[x]\defineXMLpush[y]} + {\XMLunspace{x}\XMLunspace{y}% + \expanded{\egroup\noexpand\location{\XMLpop{x},\XMLpop{y}}}} + +\defineXMLenvironment [connection] + {\bgroup\defineXMLpush[type]\defineXMLpush[name]}% + {\XMLunspace{type}\XMLunspace{name}% + \expanded{\egroup\noexpand\connection[\XMLpop{type}]{\XMLpop{name}}}} + +\defineXMLsingular [flowchart] + {\expanded{\FLOWchart[\XMLpar{flowchart}{identifier}{unknown}]}} + +\defineXMLdirective [flowchart] [shapes] \setupFLOWshapes +\defineXMLdirective [flowchart] [lines] \setupFLOWlines + +\stopXMLdefinitions + +\protect \endinput diff --git a/tex/context/base/m-chart.mkiv b/tex/context/base/m-chart.mkiv new file mode 100644 index 000000000..4c008a5ee --- /dev/null +++ b/tex/context/base/m-chart.mkiv @@ -0,0 +1,20 @@ +%D \module +%D [ file=m-chart, +%D version=1998.10.10, +%D title=\CONTEXT\ Modules, +%D subtitle=Flow Charts, +%D author={Hans Hagen \& Ton Otten}, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The \XML\ interface: + +\unprotect + +\writestatus\m!systems{The chart mkiv xml interface is not yet defined!} + +\protect \endinput diff --git a/tex/context/base/m-chart.tex b/tex/context/base/m-chart.tex index c8928f2d5..5ccf4c2ad 100644 --- a/tex/context/base/m-chart.tex +++ b/tex/context/base/m-chart.tex @@ -15,8 +15,8 @@ % todo: make mkiv variant % todo: use dimexpr/numspr -% will be redone with layers and dimexpr ro even better, by just using -% textext +% will be redone with layers and dimexpr or even better, by just using +% textext .. a nice example of old code %D This is an experimental module. Pieces of code will be moved %D to other modules. More features are possible but will be @@ -1280,36 +1280,6 @@ % \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}} % \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]} -%D The XML interface [will be mode protected or separate x-chart file] - -\startXMLdefinitions flowchart - -\defineXMLargument [flowchartdefinition] - {\defineFLOWchart[\XMLpar{flowchartdefinition}{identifier}{unknown}]} - -\defineXMLpickup [flowcell] - {\startFLOWcell - \defineXMLargument[name]{\unspaceafter\name}% - \defineXMLargument[shape]{\unspaceafter\shape}% - \defineXMLnestedargument[text]{\text}} - {\stopFLOWcell} - -\defineXMLenvironment [location] % global unspace/store - {\bgroup\defineXMLpush[x]\defineXMLpush[y]} - {\XMLunspace{x}\XMLunspace{y}% - \expanded{\egroup\noexpand\location{\XMLpop{x},\XMLpop{y}}}} - -\defineXMLenvironment [connection] - {\bgroup\defineXMLpush[type]\defineXMLpush[name]}% - {\XMLunspace{type}\XMLunspace{name}% - \expanded{\egroup\noexpand\connection[\XMLpop{type}]{\XMLpop{name}}}} - -\defineXMLsingular [flowchart] - {\expanded{\FLOWchart[\XMLpar{flowchart}{identifier}{unknown}]}} - -\defineXMLdirective [flowchart] [shapes] \setupFLOWshapes -\defineXMLdirective [flowchart] [lines] \setupFLOWlines - -\stopXMLdefinitions +\loadmarkfile{m-chart} \protect \endinput diff --git a/tex/context/base/m-punk.mkiv b/tex/context/base/m-punk.mkiv new file mode 100644 index 000000000..3b1baa75b --- /dev/null +++ b/tex/context/base/m-punk.mkiv @@ -0,0 +1,232 @@ +%D \module +%D [ file=m-punk, +%D version=2008.04.15, +%D title=\CONTEXT\ Modules, +%D subtitle=Punk Support, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\ifx\luaversion\undefined \endinput \fi + +% At some point the font generation code will move into the +% ConTeXt MkIV kernel. + +\startluacode +do + local concat = table.concat + local chardata = characters.data + local fontdata = fonts.ids + + fonts.mp = fonts.mp or { } + + fonts.mp.version = fonts.mp.version or 1.11 + fonts.mp.inline = true + fonts.mp.cache = containers.define("fonts", "mp", fonts.mp.version, true) + + metapost.characters = metapost.characters or { } + +-- todo: use table share as in otf + + local characters, descriptions = { }, { } + local factor, l, n, w, h, d, total, variants = 100, { }, 0, 0, 0, 0, 0, 0, true + + -- A next version of mplib will provide the tfm font information which + -- gives better glyph dimensions, plus additional kerning information. + + local flusher = { + startfigure = function(chrnum,llx,lly,urx,ury) + l, n = { }, chrnum + w, h, d = urx - llx, ury, -lly + total = total + 1 + inline = fonts.mp.inline + end, + flushfigure = function(t) + for i=1, #t do + l[#l+1] = t[i] + end + end, + stopfigure = function() + local cd = chardata[n] + if inline then + descriptions[n] = { + -- unicode = n, + name = cd and cd.adobename, + width = w*100, + height = h*100, + depth = d*100, + boundingbox = { 0, -d, w, h }, + } + characters[n] = { + commands = { -- todo: xforms, should happen in backend + { "special", "pdf: " .. concat(l," ") }, + } + } + else + descriptions[n] = { + -- unicode = n, + name = cd and cd.adobename, + width = w*100, + height = h*100, + depth = d*100, + boundingbox = { 0, -d, w, h }, + } + characters[n] = { + commands = { + { "image", { stream = concat(l," "), bbox = { 0, -d*65536, w*65536, h*65536 } } }, + } + } + end + end + } + + metapost.characters.instances = metapost.characters.instances or 10 + + function metapost.characters.process(mpxformat, name, instances, scalefactor) + statistics.starttiming(metapost.characters) + scalefactor = scalefactor or 1 + instances = instances or metapost.characters.instances or 10 + local fontname = file.removesuffix(file.basename(name)) + local hash = file.robustname(string.format("%s %05i %03i", fontname, scalefactor*1000, instances)) + local lists = containers.read(fonts.mp.cache(), hash) + if not lists then + statistics.starttiming(flusher) + -- we can use a format per font + local data = io.loaddata(resolvers.find_file(name)) + metapost.reset(mpxformat) + metapost.set_outer_color(2) -- no outer color and no reset either + lists = { } + for i=1,instances do + list = { } + characters, descriptions = { }, { } + metapost.process( + mpxformat, + { + "randomseed := " .. i*10 .. ";", + "scale_factor := " .. scalefactor .. " ;", + data + }, + false, + flusher + ) + lists[i] = { + designsize = 655360, + name = string.format("%s-%03i",hash,i), + parameters = { + slant = 0, + space = 333 * scalefactor, + space_stretch = 166.5 * scalefactor, + space_shrink = 111 * scalefactor, + x_height = 431 * scalefactor, + quad =1000 * scalefactor, + extra_space = 0 + }, + ["type"] = "virtual", + characters = characters, + descriptions = descriptions, + -- embedding = "subset", + -- mkiv: + spacer = "space", + unit = 1000, + shared = { }, + unique = { }, + } + end + metapost.reset(mpxformat) -- saves memory + lists = containers.write(fonts.mp.cache(), hash, lists) + statistics.stoptiming(flusher) + end + variants = variants + #lists + statistics.stoptiming(metapost.characters) + return lists + end + + function fonts.vf.aux.combine.commands.metafont(g,v) + local size = g.specification.size + local data = metapost.characters.process(v[2],v[3],v[4],size/655360) + local list, t = { }, { } + for d=1,#data do + t = data[d] + t = fonts.tfm.scale(t, -1000) + local id = font.nextid() + t.fonts = { { id = id } } + fontdata[id] = t + fonts.vf.aux.compose_characters(t) + list[d] = font.define(t) + end + for k, v in pairs(t) do + g[k] = v -- kind of replace, when not present, make nil + end + g.virtualized = true + g.variants = list + end + + fonts.define.methods.install( "punk", { + { "metafont", "mfplain", "punkfont.mp", 10 }, + } ) + + cases.actions[99] = function(current) + local used = fontdata[current.font].variants + if used then + local f = math.random(1,#used) + current.font = used[f] + return current, true + else + return current, false + end + end + + metapost.characters.flusher = flusher + + statistics.register("metapost font generation", function() + local time = statistics.elapsedtime(flusher) + if total > 0 then + return string.format("%i glyphs, %.3f seconds runtime, %i glyphs/second", total, time, total/time) + else + return string.format("%i glyphs, %.3f seconds runtime", total, time) + end + end) + + statistics.register("metapost font loading",function() + local time = statistics.elapsedtime(metapost.characters) + if variants > 0 then + return string.format("%.3f seconds, %i instances, %0.3f instances/second", time, variants, variants/time) + else + return string.format("%.3f seconds, %i instances", time, variants) + end + end) + +end +\stopluacode + +\unexpanded\def\EnableRandomPunk {\setcharactercasing[99]} +\unexpanded\def\RandomPunk {\groupedcommand\EnableRandomPunk\donothing} +\unexpanded\def\StartRandomPunk {\begingroup\EnableRandomPunk} +\unexpanded\def\StopRandomPunk {\endgroup} + +\starttypescript [serif] [punk] [default] + \setups[font:fallback:serif] % no style variants yet + \definefontsynonym [Serif] [demo@punk] +\stoptypescript + +\starttypescript [punk] + \definetypeface [punk] [rm] [serif] [punk] [default] +\stoptypescript + +\endinput + +\usetypescript[punk] + +\setupbodyfont[punk,14pt] + +\starttext + \definedfont[demo@punk at 10pt]hello world\par + \definedfont[demo@punk at 12pt]hello world\par + \definedfont[demo@punk at 16pt]hello world\par + \definedfont[demo@punk at 20pt]hello world\par +\stoptext + diff --git a/tex/context/base/m-punk.tex b/tex/context/base/m-punk.tex deleted file mode 100644 index 3b1baa75b..000000000 --- a/tex/context/base/m-punk.tex +++ /dev/null @@ -1,232 +0,0 @@ -%D \module -%D [ file=m-punk, -%D version=2008.04.15, -%D title=\CONTEXT\ Modules, -%D subtitle=Punk Support, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright=PRAGMA] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\ifx\luaversion\undefined \endinput \fi - -% At some point the font generation code will move into the -% ConTeXt MkIV kernel. - -\startluacode -do - local concat = table.concat - local chardata = characters.data - local fontdata = fonts.ids - - fonts.mp = fonts.mp or { } - - fonts.mp.version = fonts.mp.version or 1.11 - fonts.mp.inline = true - fonts.mp.cache = containers.define("fonts", "mp", fonts.mp.version, true) - - metapost.characters = metapost.characters or { } - --- todo: use table share as in otf - - local characters, descriptions = { }, { } - local factor, l, n, w, h, d, total, variants = 100, { }, 0, 0, 0, 0, 0, 0, true - - -- A next version of mplib will provide the tfm font information which - -- gives better glyph dimensions, plus additional kerning information. - - local flusher = { - startfigure = function(chrnum,llx,lly,urx,ury) - l, n = { }, chrnum - w, h, d = urx - llx, ury, -lly - total = total + 1 - inline = fonts.mp.inline - end, - flushfigure = function(t) - for i=1, #t do - l[#l+1] = t[i] - end - end, - stopfigure = function() - local cd = chardata[n] - if inline then - descriptions[n] = { - -- unicode = n, - name = cd and cd.adobename, - width = w*100, - height = h*100, - depth = d*100, - boundingbox = { 0, -d, w, h }, - } - characters[n] = { - commands = { -- todo: xforms, should happen in backend - { "special", "pdf: " .. concat(l," ") }, - } - } - else - descriptions[n] = { - -- unicode = n, - name = cd and cd.adobename, - width = w*100, - height = h*100, - depth = d*100, - boundingbox = { 0, -d, w, h }, - } - characters[n] = { - commands = { - { "image", { stream = concat(l," "), bbox = { 0, -d*65536, w*65536, h*65536 } } }, - } - } - end - end - } - - metapost.characters.instances = metapost.characters.instances or 10 - - function metapost.characters.process(mpxformat, name, instances, scalefactor) - statistics.starttiming(metapost.characters) - scalefactor = scalefactor or 1 - instances = instances or metapost.characters.instances or 10 - local fontname = file.removesuffix(file.basename(name)) - local hash = file.robustname(string.format("%s %05i %03i", fontname, scalefactor*1000, instances)) - local lists = containers.read(fonts.mp.cache(), hash) - if not lists then - statistics.starttiming(flusher) - -- we can use a format per font - local data = io.loaddata(resolvers.find_file(name)) - metapost.reset(mpxformat) - metapost.set_outer_color(2) -- no outer color and no reset either - lists = { } - for i=1,instances do - list = { } - characters, descriptions = { }, { } - metapost.process( - mpxformat, - { - "randomseed := " .. i*10 .. ";", - "scale_factor := " .. scalefactor .. " ;", - data - }, - false, - flusher - ) - lists[i] = { - designsize = 655360, - name = string.format("%s-%03i",hash,i), - parameters = { - slant = 0, - space = 333 * scalefactor, - space_stretch = 166.5 * scalefactor, - space_shrink = 111 * scalefactor, - x_height = 431 * scalefactor, - quad =1000 * scalefactor, - extra_space = 0 - }, - ["type"] = "virtual", - characters = characters, - descriptions = descriptions, - -- embedding = "subset", - -- mkiv: - spacer = "space", - unit = 1000, - shared = { }, - unique = { }, - } - end - metapost.reset(mpxformat) -- saves memory - lists = containers.write(fonts.mp.cache(), hash, lists) - statistics.stoptiming(flusher) - end - variants = variants + #lists - statistics.stoptiming(metapost.characters) - return lists - end - - function fonts.vf.aux.combine.commands.metafont(g,v) - local size = g.specification.size - local data = metapost.characters.process(v[2],v[3],v[4],size/655360) - local list, t = { }, { } - for d=1,#data do - t = data[d] - t = fonts.tfm.scale(t, -1000) - local id = font.nextid() - t.fonts = { { id = id } } - fontdata[id] = t - fonts.vf.aux.compose_characters(t) - list[d] = font.define(t) - end - for k, v in pairs(t) do - g[k] = v -- kind of replace, when not present, make nil - end - g.virtualized = true - g.variants = list - end - - fonts.define.methods.install( "punk", { - { "metafont", "mfplain", "punkfont.mp", 10 }, - } ) - - cases.actions[99] = function(current) - local used = fontdata[current.font].variants - if used then - local f = math.random(1,#used) - current.font = used[f] - return current, true - else - return current, false - end - end - - metapost.characters.flusher = flusher - - statistics.register("metapost font generation", function() - local time = statistics.elapsedtime(flusher) - if total > 0 then - return string.format("%i glyphs, %.3f seconds runtime, %i glyphs/second", total, time, total/time) - else - return string.format("%i glyphs, %.3f seconds runtime", total, time) - end - end) - - statistics.register("metapost font loading",function() - local time = statistics.elapsedtime(metapost.characters) - if variants > 0 then - return string.format("%.3f seconds, %i instances, %0.3f instances/second", time, variants, variants/time) - else - return string.format("%.3f seconds, %i instances", time, variants) - end - end) - -end -\stopluacode - -\unexpanded\def\EnableRandomPunk {\setcharactercasing[99]} -\unexpanded\def\RandomPunk {\groupedcommand\EnableRandomPunk\donothing} -\unexpanded\def\StartRandomPunk {\begingroup\EnableRandomPunk} -\unexpanded\def\StopRandomPunk {\endgroup} - -\starttypescript [serif] [punk] [default] - \setups[font:fallback:serif] % no style variants yet - \definefontsynonym [Serif] [demo@punk] -\stoptypescript - -\starttypescript [punk] - \definetypeface [punk] [rm] [serif] [punk] [default] -\stoptypescript - -\endinput - -\usetypescript[punk] - -\setupbodyfont[punk,14pt] - -\starttext - \definedfont[demo@punk at 10pt]hello world\par - \definedfont[demo@punk at 12pt]hello world\par - \definedfont[demo@punk at 16pt]hello world\par - \definedfont[demo@punk at 20pt]hello world\par -\stoptext - diff --git a/tex/context/base/m-steps.mkii b/tex/context/base/m-steps.mkii new file mode 100644 index 000000000..3e1f86312 --- /dev/null +++ b/tex/context/base/m-steps.mkii @@ -0,0 +1,83 @@ +%D \module +%D [ file=m-steps, +%D version=2001.05.28, +%D title=\CONTEXT\ Modules, +%D subtitle=Step Charts \& Tables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The \XML\ interface: + +\unprotect + +\defineXMLdirective [stepchart] [charts] \setupSTEPcharts +\defineXMLdirective [stepchart] [cells] \setupSTEPcells +\defineXMLdirective [stepchart] [texts] \setupSTEPtexts +\defineXMLdirective [stepchart] [lines] \setupSTEPlines + +\defineXMLdirective [steptable] [tables] \setupSTEPtables +\defineXMLdirective [steptable] [cells] \setupSTEPcells +\defineXMLdirective [steptable] [texts] \setupSTEPtexts +\defineXMLdirective [steptable] [lines] \setupSTEPlines + +\defineXMLpickup[stepchart][@@STPC] + {\bgroup + \defineXMLpush[top]% + \defineXMLpush[bot]% + \defineXMLenvironment[lines][@@STEL] + {\expanded{\startlines[\theXMLarguments{@@STEL}]}} + {\stoplines}% + \defineXMLenvironment[cells][@@STEC] + {\XMLerase{top}\XMLerase{bot}} + {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{top}}{\XMLpop{bot}}}}% + \defineXMLenvironment[texts][@@STET] + {\XMLerase{top}\XMLerase{bot}} + {\expanded{\texts[\theXMLarguments{@@STET}]{\XMLpop{top}}{\XMLpop{bot}}}}% + \defineXMLenvironmentpush[cell][@@STEC] + {\XMLerase{cell}} + {\expanded{\cell [\theXMLarguments{@@STEC}]{\XMLpop{cell}}}}% + \defineXMLenvironmentpush [text] [@@STET] + {\XMLerase{text}} + {\expanded{\text [\theXMLarguments{@@STET}]{\XMLpop{text}}}}% + \expanded{\startSTEPchart[\theXMLarguments{@@STPC}]}} + {\stopSTEPchart + \egroup} + +\defineXMLpickup[steptable][@@STPT] + {\bgroup + \defineXMLenvironment[lines][@@STEL] + {\expanded{\startlines[\theXMLarguments{@@STEL}]}} + {\stoplines}% + \defineXMLargument[cell][@@STEC] + {\expanded{\cell[\theXMLarguments{@@STEC}]}}% + \defineXMLargument[text][@@STET] + {\expanded{\text[\theXMLarguments{@@STET}]}}% + \defineXMLargument[prep] + {\prep}% + \expanded{\startSTEPtable[\theXMLarguments{@@STPT}]}} + {\stopSTEPtable + \egroup} + +\defineXMLpickup[stepaligntable][@@STPT] + {\bgroup + \defineXMLenvironment[lines][@@STEL] + {\expanded{\setupSTEPlines[\theXMLarguments{@@STEL}]}} + {}% + \defineXMLpush[c1]\defineXMLpush[c2]\defineXMLpush[c3]% + \defineXMLenvironment[cells][@@STEC] + {\XMLerase{c1}\XMLerase{c1}\XMLerase{c3}} + {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{c1}}{\XMLpop{c2}}{\XMLpop{c3}}}}% + \defineXMLargument[text][@@STET] + {\expanded{\text[\theXMLarguments{@@STET}]}}% + \defineXMLargument[prep] + {\prep}% + \expanded{\startSTEPaligntable[\theXMLarguments{@@STPT}]}} + {\stopSTEPaligntable + \egroup} + +\protect \endinput diff --git a/tex/context/base/m-steps.mkiv b/tex/context/base/m-steps.mkiv new file mode 100644 index 000000000..9bb56c532 --- /dev/null +++ b/tex/context/base/m-steps.mkiv @@ -0,0 +1,20 @@ +%D \module +%D [ file=m-steps, +%D version=2001.05.28, +%D title=\CONTEXT\ Modules, +%D subtitle=Step Charts \& Tables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The \XML\ interface: + +\unprotect + +\writestatus\m!systems{The steps mkiv xml interface is not yet defined!} + +\protect \endinput diff --git a/tex/context/base/m-steps.tex b/tex/context/base/m-steps.tex index 1e2f5d97d..1f6a37403 100644 --- a/tex/context/base/m-steps.tex +++ b/tex/context/base/m-steps.tex @@ -116,18 +116,6 @@ %D ... -\defineXMLdirective [stepchart] [charts] \setupSTEPcharts -\defineXMLdirective [stepchart] [cells] \setupSTEPcells -\defineXMLdirective [stepchart] [texts] \setupSTEPtexts -\defineXMLdirective [stepchart] [lines] \setupSTEPlines - -\defineXMLdirective [steptable] [tables] \setupSTEPtables -\defineXMLdirective [steptable] [cells] \setupSTEPcells -\defineXMLdirective [steptable] [texts] \setupSTEPtexts -\defineXMLdirective [steptable] [lines] \setupSTEPlines - -%D ... - \presetlocalframed[\@@STPF] \def\@@stepcell#1% @@ -664,31 +652,6 @@ \@@STELalternative, get_step_chart_bot_line(#1,#2), \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} -%D \XML\ coupling. - -\defineXMLpickup[stepchart][@@STPC] - {\bgroup - \defineXMLpush[top]% - \defineXMLpush[bot]% - \defineXMLenvironment[lines][@@STEL] - {\expanded{\startlines[\theXMLarguments{@@STEL}]}} - {\stoplines}% - \defineXMLenvironment[cells][@@STEC] - {\XMLerase{top}\XMLerase{bot}} - {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{top}}{\XMLpop{bot}}}}% - \defineXMLenvironment[texts][@@STET] - {\XMLerase{top}\XMLerase{bot}} - {\expanded{\texts[\theXMLarguments{@@STET}]{\XMLpop{top}}{\XMLpop{bot}}}}% - \defineXMLenvironmentpush[cell][@@STEC] - {\XMLerase{cell}} - {\expanded{\cell [\theXMLarguments{@@STEC}]{\XMLpop{cell}}}}% - \defineXMLenvironmentpush [text] [@@STET] - {\XMLerase{text}} - {\expanded{\text [\theXMLarguments{@@STET}]{\XMLpop{text}}}}% - \expanded{\startSTEPchart[\theXMLarguments{@@STPC}]}} - {\stopSTEPchart - \egroup} - %D Step tables are the vertical counterpart of stepcharts. \newcounter\currentsteptable @@ -846,38 +809,6 @@ \@@STELalternative, get_step_table_line(\cellcounter), \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} -\defineXMLpickup[steptable][@@STPT] - {\bgroup - \defineXMLenvironment[lines][@@STEL] - {\expanded{\startlines[\theXMLarguments{@@STEL}]}} - {\stoplines}% - \defineXMLargument[cell][@@STEC] - {\expanded{\cell[\theXMLarguments{@@STEC}]}}% - \defineXMLargument[text][@@STET] - {\expanded{\text[\theXMLarguments{@@STET}]}}% - \defineXMLargument[prep] - {\prep}% - \expanded{\startSTEPtable[\theXMLarguments{@@STPT}]}} - {\stopSTEPtable - \egroup} - -\defineXMLpickup[stepaligntable][@@STPT] - {\bgroup - \defineXMLenvironment[lines][@@STEL] - {\expanded{\setupSTEPlines[\theXMLarguments{@@STEL}]}} - {}% - \defineXMLpush[c1]\defineXMLpush[c2]\defineXMLpush[c3]% - \defineXMLenvironment[cells][@@STEC] - {\XMLerase{c1}\XMLerase{c1}\XMLerase{c3}} - {\expanded{\cells[\theXMLarguments{@@STEC}]{\XMLpop{c1}}{\XMLpop{c2}}{\XMLpop{c3}}}}% - \defineXMLargument[text][@@STET] - {\expanded{\text[\theXMLarguments{@@STET}]}}% - \defineXMLargument[prep] - {\prep}% - \expanded{\startSTEPaligntable[\theXMLarguments{@@STPT}]}} - {\stopSTEPaligntable - \egroup} - \protect \endinput % A simple paragraph-flow test: diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 96590d9a1..476acfd1e 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -706,7 +706,8 @@ \v!frame=>\chardef\gridboxlinemode \plusthree, \v!nonumber=>\chardef\gridboxlinenomode\zerocount, \v!right=>\chardef\gridboxlinenomode\plusone, - \v!left=>\chardef\gridboxlinenomode\plustwo]% + \v!left=>\chardef\gridboxlinenomode\plustwo, + \v!outer=>\chardef\gridboxlinenomode\plusthree]% \ifcase\showgridstate \let\addtextgridlayer\gobbleoneargument \else % 1=bottom 2=top @@ -1230,8 +1231,6 @@ \def\dodefinepagebreak[#1][#2]% non recursive, meant for simple mappings {\setvalue{\??pe::#1}{#2}} -% hier nog uti blokkeren - % don't change this / test case: % % \setupbackgrounds[state=repeat] diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua index 712307626..a5daa96f1 100644 --- a/tex/context/base/spac-ver.lua +++ b/tex/context/base/spac-ver.lua @@ -75,7 +75,7 @@ vspacing.data.snapmethods = vspacing.data.snapmethods or { } storage.register("vspacing/data/snapmethods", vspacing.data.snapmethods, "vspacing.data.snapmethods") -local snapmethods, snapht, snapdp, snaphtdp = vspacing.data.snapmethods, 0, 0, 0 +local snapmethods = vspacing.data.snapmethods local default = { maxheight = true, @@ -132,6 +132,8 @@ function vspacing.define_snap_method(name,method) tex.write(n) end +local snapht, snapdp, snaphtdp = 0, 0, 0 + function vspacing.freeze_snap_method(ht,dp) snapht, snapdp = ht or texdimen.bodyfontstrutheight, dp or texdimen.bodyfontstrutdepth snaphtdp = snapht + snapdp @@ -241,6 +243,7 @@ vspacing.categories = { [5] = 'disable', [6] = 'nowhite', [7] = 'goback', + [8] = 'together' } local categories = vspacing.categories @@ -291,6 +294,9 @@ do -- todo: interface.variables local k_fixed, k_flexible, k_category, k_penalty, k_order = variables.fixed, variables.flexible, "category", "penalty", "order" + -- This will change: just node.write and we can store the values in skips which + -- then obeys grouping + local function analyse(str,oldcategory,texsprint) for s in gmatch(str,"([^ ,]+)") do local amount, keyword, detail = splitter:match(s) @@ -512,7 +518,7 @@ local skips = { local free_glue_node = free_node local free_glue_spec = free_node -local discard, largest, force, penalty, add, disable, nowhite, goback = 0, 1, 2, 3, 4, 5, 6, 7 +local discard, largest, force, penalty, add, disable, nowhite, goback, together = 0, 1, 2, 3, 4, 5, 6, 7, 8 function vspacing.snap_box(n,how) local sv = snapmethods[how] @@ -520,10 +526,18 @@ function vspacing.snap_box(n,how) local list = texbox[n].list --~ if list and (list.id == hlist or list.id == vlist) then if list then - local h, d, ch, cd, lines = snap_hlist(list,sv,texht[n],texdp[n]) - texht[n], texdp[n] = ch, cd - if trace_vsnapping then - logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,"direct",lines) + local s = has_attribute(list,snap_method) + if s == 0 then + if trace_vsnapping then + logs.report("snapper", "hlist not snapped, already done") + end + else + local h, d, ch, cd, lines = snap_hlist(list,sv,texht[n],texdp[n]) + texht[n], texdp[n] = ch, cd + if trace_vsnapping then + logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,"direct",lines) + end + set_attribute(list,snap_method,0) end end end @@ -552,10 +566,15 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail reset_tracing(head) trace_info("start analyzing",where,what) end - local current = head + local current, oldhead = head, head + snapht, snapdp = ht or texdimen.bodyfontstrutheight, dp or texdimen.bodyfontstrutdepth + snaphtdp = snapht + snapdp local glue_order, glue_data, force_glue = 0, nil, false local penalty_order, penalty_data, natural_penalty = 0, nil, nil - local parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false + local parskip, ignore_parskip, ignore_following, ignore_whitespace, keep_together = nil, false, false, false, false + -- + -- todo: keep_together: between headers + -- local function flush(why) if penalty_data then local p = make_penalty_node(penalty_data) @@ -584,24 +603,25 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail if id == hlist or id == vlist then if snap then local s = has_attribute(current,snap_method) - if s then - unset_attribute(current,snap_method) - if not has_attribute(current,snap_done) then - local sv = snapmethods[s] - if sv then - local h, d, ch, cd, lines = snap_hlist(current,sv) - if trace_vsnapping then - logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,where,lines) - end - elseif trace_vsnapping then - logs.report("snapper", "hlist not snapped due to unknown snap specification") + if not s then + -- if trace_vsnapping then + -- logs.report("snapper", "hlist not snapped") + -- end + elseif s == 0 then + if trace_vsnapping then + logs.report("snapper", "hlist not snapped, already done") + end + else + local sv = snapmethods[s] + if sv then + local h, d, ch, cd, lines = snap_hlist(current,sv) + if trace_vsnapping then + logs.report("snapper", "hlist snapped from (%s,%s) to (%s,%s) using method '%s' (%s) for '%s' (%s lines)",h,d,ch,cd,sv.name,sv.specification,where,lines) end - set_attribute(current,snap_done,s) elseif trace_vsnapping then - logs.report("snapper", "hlist not snapped, already done") + logs.report("snapper", "hlist not snapped due to unknown snap specification") end - elseif trace_vsnapping then - -- logs.report("snapper", "hlist not snapped") + set_attribute(current,snap_method,0) end else -- @@ -636,6 +656,7 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail elseif penalty_order == so and sp > penalty_data then penalty_data = sp end + if trace then trace_skip('penalty in skip',sc,so,sp,current) end head, current = remove_node(head, current, true) elseif not sc then -- if not sc then if glue_data then @@ -677,6 +698,10 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail ignore_following = true if trace then trace_skip("disable",sc,so,sp,current) end head, current = remove_node(head, current, true) + elseif sc == together then + keep_together = true + if trace then trace_skip("together",sc,so,sp,current) end + head, current = remove_node(head, current, true) elseif sc == nowhite then ignore_whitespace = true head, current = remove_node(head, current, true) @@ -745,9 +770,9 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail end elseif subtype == line_skip then if snap then - local sn = has_attribute(current,snap_method) - if sn then - unset_attribute(current,snap_method) + local s = has_attribute(current,snap_method) + if s and s ~= 0 then + set_attribute(current,snap_method,0) local spec = current.spec if spec then spec.width = 0 @@ -766,9 +791,9 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail current = current.next elseif subtype == baseline_skip then if snap then - local sn = has_attribute(current,snap_method) - if sn then - unset_attribute(current,snap_method) + local s = has_attribute(current,snap_method) + if s and s ~= 0 then + set_attribute(current,snap_method,0) local spec = current.spec if spec then spec.width = 0 @@ -806,8 +831,8 @@ local function collapser(head,where,what,trace,snap) -- maybe also pass tail elseif subtype == top_skip_code or subtype == split_top_skip_code then if snap then local s = has_attribute(current,snap_method) - if s then - unset_attribute(current,snap_method) + if s and s ~= 0 then + set_attribute(current,snap_method,0) local sv = snapmethods[s] local w, cw = snap_topskip(current,sv) if trace_vsnapping then @@ -886,6 +911,9 @@ current = current.next trace_info("stop flushing",where,what) end show_tracing(head) + if oldhead ~= head then + trace_info("head has been changed from '%s' to '%s'",node.type(oldhead.id),node.type(head.id)) + end end return head, true end diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 8849d71c1..15e37d61a 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -1274,13 +1274,24 @@ \resetsnapvalue \dowithnextbox{\dododosnaptogrid{#1}}} +% eventually there will always be a line snap + \def\dododosnaptogrid#1% {\ifvbox\nextbox \ctxlua{nodes.collapse_vbox(\number\nextbox)}% \fi \doifelsenothing{#1}{\setsnapvalue\v!normal}{\autosetsnapvalue{#1}}% \ctxlua{vspacing.snap_box(\number\nextbox,\number\attribute\snapmethodattribute)}% - \box\nextbox +% \ifzeropt\ht\nextbox +% \ifzeropt\dp\nextbox +% \box\nextbox % here, else empty and zero +% \kern-\bodyfontlineheight +% \else +% \box\nextbox +% \fi +% \else + \box\nextbox +% \fi \egroup} % no off @@ -1322,8 +1333,8 @@ \hss}% \flushnextbox}}} -\chardef\gridboxlinenomode\plusone -\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame +\chardef\gridboxlinenomode\plusone % 0:nothing 1:all 2:lines 3:frame 4:l/r +\chardef\gridboxlinemode \plusone \def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi} \def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth} @@ -1335,6 +1346,9 @@ \offinterlineskip \hsize#2% \baselinerulefalse + \ifnum\gridboxlinenomode=\plusthree + \chardef\gridboxlinenomode\ifodd\realpageno\plusone\else\plustwo\fi + \fi \gridboxvbox % calculated size {\getrawnoflines{#3}% \getnoflines{#3}% % \ifgridsnapping \else @@ -1588,7 +1602,7 @@ \fi\fi \relax} -\definevspacing[\v!samepage][penalty:10000] +\definevspacing[\v!samepage][penalty:10000] % real strong \definevspacing[\v!max] [category:1] \definevspacing[\v!force] [category:2] \definevspacing[\v!disable] [category:5] @@ -1600,6 +1614,9 @@ \definevspacing[\s!default] [\v!white] % was big for a while +\dorecurse{10} % todo: other values < 4000 + {\expanded{\definevspacing[\v!samepage-\recurselevel][penalty:\the\numexpr4000+250*\recurselevel\relax]}} + \setfalse\vspacingenabled \newtoks\everyenablevspacing diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index 315fb8236..b76abb9ed 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -230,10 +230,10 @@ \ifx\itemgroupconstantvalue\empty\else \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond \ifx\itemgroupsecond\empty - \ifcsname\??op:::\itemgroupfirst\endcsname\csname\??op:::\itemgroupfirst\endcsname\fi - \else - \ifcsname\??op:::\itemgroupsecond\endcsname\csname\??op:::\itemgroupsecond\endcsname\fi + \let\itemgroupsecond\itemgroupfirst + \let\itemgroupfirst\!!plusone \fi + \ifcsname\??op:::\itemgroupsecond\endcsname\csname\??op:::\itemgroupsecond\endcsname\fi \fi} \newconditional\inlinelistitem \setfalse\inlinelistitem @@ -913,7 +913,7 @@ \else \scratchdimen\zeropoint \fi - \llap{\hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+}\fi\box\itemgroupitembox\hss}}% was: \hfill + \llap{\hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hss}}% was: \hfill \hskip\scratchdimen} \def\optimizelistitemsbreak @@ -982,7 +982,7 @@ % so that content differs per run (esp mp graphics afterwards) \checkforrepeatedlistitem \ifdim\itemgroupaskedwidth<\zeropoint\relax - \llap{\ifconditional\sublistitem\llap{+}\fi\box\itemgroupitembox\hskip\leftmargindistance}% + \llap{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hskip\leftmargindistance}% \else \ifdim\itemgroupaskedwidth=\zeropoint\relax \calculatelistwidth1% @@ -990,14 +990,14 @@ \calculatelistwidth\currentitemlevel \fi \ifconditional\textlistitem - \hbox{\ifconditional\sublistitem+\fi\box\itemgroupitembox\hskip\interwordspace}\nobreak + \hbox{\ifconditional\sublistitem+\enspace\fi\box\itemgroupitembox\hskip\interwordspace}\nobreak \else\ifconditional\inlinelistitem - \hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+}\fi\box\itemgroupitembox\hss}% was: \hfill + \hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+\enspace}\fi\box\itemgroupitembox\hss}% was: \hfill \else\ifconditional\txtlistitem \dodotxtitem \else % todo: align+marge binnen de hbox - \llap{\hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+}\fi + \llap{\hbox to \itemgrouplistwidth{\ifconditional\sublistitem\llap{+\enspace}\fi \symalignleft \box\itemgroupitembox\hfil \hskip\getitemparameter\currentitemlevel\c!distance% T h diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 48c48caa0..4598be00c 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -993,8 +993,11 @@ \def\doaddtototalnoteheight#1% {\ifdim\ht#1>\zeropoint - \advance\totalnoteheight\ht #1% - \advance\totalnoteheight\skip#1% + \ifcase\count#1\else + % todo: divide by count + \advance\totalnoteheight\ht #1% + \advance\totalnoteheight\skip#1% + \fi \fi} \def\docalculatetotalnoteheight diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index b7e18746d..aa1d4721f 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -611,40 +611,56 @@ % \chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing \chardef\somestructureheadbreakmethod\plusthree +% \def\dopreventbreakafterstructureheadauto % used after \c!before +% {\ifcase\somestructureheadbreakmethod +% % 0 = nothing +% \or +% % 1 = old weighted version +% \ifnum\currentstructureheadlevel>\precedingstructurelevel +% \dosomebreak{\penalty\numexpr20000+500*\currentstructureheadlevel\relax}% +% \else +% \dosomebreak\allowbreak % brr +% \fi +% \or +% % 2 = strict version +% \dosomebreak{\penalty\maxdimen}% +% \or +% % 3 = vspacing +% \vspacing[\v!samepage]% if preceded by ! then a loop +% \else +% % nothing +% \fi} +% +% \def\dopreventbreakafterstructureheadspec#1% see enumerations etc +% {\ifcase\somestructureheadbreakmethod +% % 0 = nothing +% \or +% % 1 = old weighted version +% \dosomebreak{\penalty\numexpr20000+500*(\currentstructureheadlevel+#1)\relax}% +% \or +% % 2 = strict version +% \dosomebreak{\penalty\maxdimen}% +% \or +% % 3 = vspacing +% \vspacing[\v!samepage]% +% \else +% % nothing +% \fi} +% +% todo: \vspacing[category:8] == keep_together + \def\dopreventbreakafterstructureheadauto % used after \c!before {\ifcase\somestructureheadbreakmethod % 0 = nothing - \or - % 1 = old weighted version - \ifnum\currentstructureheadlevel>\precedingstructurelevel - \dosomebreak{\penalty\numexpr20000+500*\currentstructureheadlevel\relax}% - \else - \dosomebreak\allowbreak % brr - \fi - \or - % 2 = strict version - \dosomebreak{\penalty\maxdimen}% - \or - % 3 = vspacing - \vspacing[\v!samepage]% if preceded by ! then a loop \else - % nothing + \vspacing[\v!samepage-\currentstructureheadlevel]% \fi} \def\dopreventbreakafterstructureheadspec#1% see enumerations etc {\ifcase\somestructureheadbreakmethod % 0 = nothing - \or - % 1 = old weighted version - \dosomebreak{\penalty\numexpr20000+500*(\currentstructureheadlevel+#1)\relax}% - \or - % 2 = strict version - \dosomebreak{\penalty\maxdimen}% - \or - % 3 = vspacing - \vspacing[\v!samepage]% \else - % nothing + \vspacing[\v!samepage-\the\numexpr\currentstructureheadlevel+1\relax]% todo #1 \fi} \def\dohandlepagebreakX{\dopreventbreakafterstructureheadspec} % no \let so we can redefind diff --git a/tex/context/base/x-calcmath.mkiv b/tex/context/base/x-calcmath.mkiv index 29bc1af9a..c726843fa 100644 --- a/tex/context/base/x-calcmath.mkiv +++ b/tex/context/base/x-calcmath.mkiv @@ -1,5 +1,3 @@ -% engine=luatex - %D \module %D [ file=m-calcmath, %D version=2006.04.24, % 1999.11.06, diff --git a/tex/context/base/x-contml.mkii b/tex/context/base/x-contml.mkii new file mode 100644 index 000000000..a582d8eb9 --- /dev/null +++ b/tex/context/base/x-contml.mkii @@ -0,0 +1,491 @@ +%M \usemodule [contml] \autoXMLnamespace [context] +%M \definefilesynonym [context] [x-contml.xsd] + +%D \module +%D [ file=x-contml, +%D version=mid 2001, +%D title=\CONTEXT\ XML Support, +%D subtitle=Basic \CONTEXT\ commands, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% This module provides some basic \XML\ elements. These definitions +% are highly experimental and serve as a playground for interface +% development. + +\unprotect + +%D \elements {include} +%D +%D \startbuffer +%D You can include another file in the current document with the +%D include element. When including the file, &context; +%D will look at the suffix, in order to decide how to include the file. +%D +%D +%D +%D +%D +%D +%D \stopbuffer +%D +%D \showelements [context] [include] + +\defineXMLsingular [context:include] [name=,type=xml] + {\doifsomethingXMLop{name} + {\processaction + [\XMLop{type}] + [xml=>\readfile{\XMLop{name}}\donothing\donothing, + tex=>{{\disableXML\readfile{\XMLop{name}}\donothing\donothing}}, + txt=>{{\disableXML\typefile{\XMLop{name}}}}]}} + +% or, nicer: +% +% \defineXMLsingular [context:include] [name=unknown,type=txt] +% {\XMLval{include:type}{\XMLop{type}}{}} +% +% \mapXMLvalue {include:type} {xml} {\readfile{\XMLop{name}}\donothing\donothing} +% \mapXMLvalue {include:type} {tex} {{\disableXML\readfile{\XMLop{name}}\donothing\donothing}} +% \mapXMLvalue {include:type} {txt} {{\disableXML\typefile{\XMLop{name}}}} + +%D \elements {compound} +%D +%D \startbuffer +%D Instead of using hard coded compound tokens, you should use the +%D compound element, as in highlow. +%D The overhead in keying is rewarded with proper symbols and hyphenation. +%D \stopbuffer +%D +%D \showelements [context] [compound] + +\ifx\normalcompound\undefined \let\normalcompound=| \fi + +% \defineXMLsingular [context:compound] [token=] +% {\expanded{\normalcompound\XMLop{token}}|} + +% \defineXMLsingular [context:compound] [token=] +% {\ifmmode +% \doifXMLop{token}{\XMLop{token}}{\compoundhyphen}% +% \else +% \expanded{\normalcompound\XMLop{token}}|% +% \fi} + +\defineXMLsingular [context:compound] [token=] + {\mathortext % disc comm looks ahead, so \relax + {\doifXMLop{token}{\XMLop{token}}\compoundhyphen}% + {\expanded{\directdiscretionary{\XMLop{token}}}\relax}} + +\defineXMLenvironmentsave [context:cp] + {} + {\expanded{\directdiscretionary{\XMLflush{cp}}}\relax} + +%D \elements {p} +%D +%D \startbuffer +%D

Although for &tex; it is often enough to mark the end of a paragraph, +%D in &xml; we want to add a bit more structure.

This permits a more +%D robust implementation of beginofpar actions

+%D \stopbuffer +%D +%D \showelements [context] [p] + +\defineXMLenvironment [context:p] {} \endgraf +\defineXMLsingular [context:p] \endgraf + +%D \elements {pageref,textref,lineref} +%D +%D \startbuffer +%D You can ask for a page (the last pagenumber +%D is aka page ), text or line reference +%D with the following three elements. The label may be any valid &context; +%D reference label. +%D \stopbuffer +%D +%D \showelements [context] [references] + +\defineXMLpickup [context:pageref] [label=] {\at} {[\XMLop{label}]} +\defineXMLpickup [context:textref] [label=] {\in} {[\XMLop{label}]} +\defineXMLpickup [context:lineref] [label=] {\inline} {[\XMLop{label}]} + +%D \elements{text} +%D +%D \startbuffer +%D If you have a self contained &xml; file, you need to signal &context; the +%D begin and end of the document. The following elements can be used for +%D that purpose: +%D +%D +%D +%D ... +%D +%D +%D \stopbuffer +%D +%D \showelements [context] [text] + +\defineXMLenvironment [context:text] \starttext \stoptext + +%D \elements {em} +%D +%D \startbuffer +%D Authors often want some control over the way a text is typeset, which is +%D why we provide the em element. We may only hope that +%D the author is consistent in his decisions on what to emphasize. +%D \stopbuffer +%D +%D \showelements [context] [em] + +\defineXMLgrouped [context:em] \em + +%D \elements {b} +%D +%D \startbuffer +%D Bold is not always beautiful but if you really want it, you can +%D get it by using this element. +%D \stopbuffer +%D +%D \showelements [context] [b] + +\defineXMLgrouped [context:b] \bf + +%D \elements {verbatim,typing,line,verb,type} +%D +%D \startbuffer +%D Although the following method can be used to typeset a piece of code +%D verbatim +%D +%D verbatim ! +%D ]]> +%D +%D we prefer the more structured: +%D +%D +%D Dit \is nogal verbatim ! +%D Dit is {nogal} verbatim ! +%D Dit is verbatim ! +%D +%D \stopbuffer +%D +%D The element to tag inline verbatim is . +%D +%D \showelements [context] [verbatim] + +\defineXMLenvironment [context:verbatim] + {\startpacked + \defineXMLargument[context:line]{\endgraf\type}} + {\stoppacked} + +\defineXMLenvironment [context:typing] + {\startpacked\defineXMLargument[context:line]{\endgraf\type}} + {\stoppacked} + +\defineXMLargument [context:verb] \type +\defineXMLargument [context:type] \type + +%D \elements {itemize,item} +%D +%D \startbuffer +%D Itemized lists are quite common in documents, al least in the ones that +%D we produce. For the moment we only provide a few options, later we will +%D hook it into the &context; attribute handler. +%D +%D +%D test +%D test +%D +%D +%D +%D test +%D test what? +%D +%D \stopbuffer +%D +%D \showelements [context] [itemize] + +\defineXMLenvironment [context:itemize] [type=,packed=] + {\let\XMLoptions\empty + \doifsomethingXMLop{type}{\addtocommalist{\XMLop{type}}\XMLoptions}% + \doifXMLop{packed}{yes}{\addtocommalist{packed}\XMLoptions}% + \expanded{\startitemize[\XMLoptions]}} + {\stopitemize} + +\defineXMLenvironment [context:item] [label=] + {\expanded{\item[\XMLop{label}]}} + {\endgraf} + +%D \elements {externalfigure} +%D +%D \startbuffer +%D The previous examples already demonstrated how we can include a graphic: +%D +%D +%D +%D +%D \stopbuffer +%D +%D \showelements [context] [externalfigure] + +\defineXMLsingular [context:externalfigure] [\??ef] [base=,label=,file=] + {\bgroup % \getXMLta \expandXMLta \expandXMLtp{file}% + \expandXMLta + \getXMLta % expand entities first + \doifelsenothing{\XMLtp{label}} + {\expanded{\externalfigure[\XMLtp{file}][\XMLta]}} + {\doifsomething{\XMLtp{base}}{\usefigurebase[\XMLtp{base}]}% + \expanded{\externalfigure[\XMLtp{label}][\XMLta]}} + \egroup} + +%D \elements {fixed} +%D \setupexternalfigures[directory={../sample}] +%D \startbuffer +%D Something fixed will end up at the place where it defined in the input +%D stream. The main idea behind this element is that it gives you control +%D over the placement. +%D +%D +%D +%D +%D +%D +%D +%D +%D +%D +%D \stopbuffer +%D +%D \showelements [context] [fixed] + +\defineXMLenvironment [context:fixed] [type=figure,location=,label=] + {\bgroup + \defineXMLsave[context:caption] + \defineXMLsave[context:content]} + {\expanded{\startfixed[\XMLop{location}]}% + \doifXMLdataelse{context:caption} + {\startcombination[1*1] + {\XMLflush{context:content}} {\XMLflush{context:caption}} + \stopcombination} + {\XMLflush{context:content}}% + \stopfixed + \egroup} + +%D \elements {float} +%D \setupexternalfigures[directory={../sample}] +%D \startbuffer +%D A floating body will be placed at the first location available, unless +%D a location is specified. As with the fixed element, +%D you can provide a caption. +%D +%D +%D +%D +%D +%D This is a cow! +%D +%D \stopbuffer +%D +%D \showelements [context] [float] + +\defineXMLenvironment [context:float] [type=figure,location=here,label=] + {\bgroup + \defineXMLsave[context:caption] + \defineXMLsave[context:content]} + {\expanded + {\placefloat + [\XMLop{type}] [\XMLop{location}] [\XMLop{label}] + {\XMLflush{context:caption}} {\XMLflush{context:content}}} + \egroup} + +%D \elements {quotation,quote} +%D +%D \startbuffer +%D There is a (not so) subtle difference between a display +%D quotation and an inline +%D one. +%D \stopbuffer +%D +%D \showelements [context] [table] + +\defineXMLgrouped [context:quote] \quote +\defineXMLgrouped [context:quotation] \quotation + +%D \elements {table,tr,td} +%D +%D \startbuffer +%D There are (currently) three table mechanisms in &context;. One of them +%D resembles the well known &html; tables. +%D +%D +%D +%D +%D +%D
one a first
two b second
+%D +%D +%D As you can see here, we use a similar syntax but stick to the &context; +%D attributes (which provide quite advanced control over the layout). +%D +%D +%D +%D +%D +%D
xx xx
xx xx
+%D +%D \stopbuffer +%D +%D \showelements [context] [table] + +\defineXMLenvironment [context:table] [\@@tbl\@@tbl] + {\bgroup + \defineXMLnested [context:tr] [\@@tbl] {\expanded{\bTR[\theXMLarguments{\@@tbl}}]} \eTR + \defineXMLnested [context:td] [\@@tbl] {\expanded{\bTD[\theXMLarguments{\@@tbl}}]} \eTD + \expanded{\bTABLE[\theXMLarguments{\@@tbl\@@tbl}]}} + {\eTABLE + \egroup} + +%D \elements {tabulate,tspec,thead,tbody,ttail,trule,tr,td} +%D +%D \startbuffer +%D The second mechanism that we support is tabulation. The advantage of this +%D mechanism is that it it well tuned for tables that have much text in the +%D cells and cross page boundaires. +%D +%D +%D +%D +%D +%D +%D +%D bagger bagger bagger +%D +%D +%D +%D +%D +%D +%D bagger bagger bagger +%D bagg ger gr +%D bag er gger +%D +%D +%D \stopbuffer +%D +%D \showelements [context] [tabulate] + +\newtoks\XMLtabtoks + +\defineXMLgrouped [context:tabulate] {\XMLtabtoks{|l|p|}} + +\defineXMLpickup [context:tbody] + {\expanded{\definetabulate[dummy][\the\XMLtabtoks]} + \startdummy\XMLflush{context:thead}} + {\XMLflush{context:ttail}\stopdummy} + +\defineXMLsave [context:thead] +\defineXMLsave [context:ttail] + +\defineXMLenvironment[context:tspec] + {\XMLtabtoks\emptytoks} + {\appendtoks|\to\XMLtabtoks} + +\defineXMLsingular [context:trule] % verrrry ugly + {\crcr\noalign{\kern-\lineheight}\HL} + +\defineXMLsingular [context:tcell] [align=] + {\appendtoks|\to\XMLtabtoks + \expanded{\processallactionsinset + [\XMLop{align}]} + [ paragraph=>\appendtoks p\to\XMLtabtoks, + left=>\appendtoks l\to\XMLtabtoks, + right=>\appendtoks r\to\XMLtabtoks, + center=>\appendtoks c\to\XMLtabtoks, + middle=>\appendtoks c\to\XMLtabtoks]} + +\defineXMLenvironment [context:tr] {\ignorespaces} {\NC\NR} +\defineXMLenvironment [context:td] {\NC} {\ignorespaces} + +%D \elements {hide} +%D +%D \startbuffer +%D This is the way to [this is gone] something for the +%D typesetting engine. Normally this element is only used for testing +%D purposes. +%D \stopbuffer +%D +%D \showelements [context] [tabulate] + +\defineXMLignore[context:hide] + +%D \elements {unknown} +%D +%D \startbuffer +%D We can go on and on and with defining elements that map onto +%D &context; commands, but why not just use &tex; input syntax then? +%D \stopbuffer +%D +%D \showelements [context] [unknown] + +\defineXMLsingular [context:unknown] \unknown + +%D A (for the moment) private one. + +\defineXMLargument [context:element] \type + +%D The following common schema definitions apply: +%D +%D {\setupcolors[state=stop]\showXSDcomponent[context][definitions]} + +\defineXMLargument [context:chapter] [label=] {\chapter[\XMLop{label}]} +\defineXMLargument [context:section] [label=] {\section[\XMLop{label}]} +\defineXMLargument [context:subsection] [label=] {\subsection[\XMLop{label}]} +\defineXMLargument [context:subsubsection] [label=] {\subsubsection[\XMLop{label}]} +\defineXMLargument [context:subsubsubsection] [label=] {\subsubsubsection[\XMLop{label}]} + +\defineXMLargument [context:title] [label=] {\title[\XMLop{label}]} +\defineXMLargument [context:subject] [label=] {\subject[\XMLop{label}]} +\defineXMLargument [context:subsubject] [label=] {\subsubject[\XMLop{label}]} +\defineXMLargument [context:subsubsubject] [label=] {\subsubsubject[\XMLop{label}]} +\defineXMLargument [context:subsubsubsubject] [label=] {\subsubsubsubject[\XMLop{label}]} + +\defineXMLenvironment [context:frontmatter] \startfrontmatter \stopfrontmatter +\defineXMLenvironment [context:bodymatter] \startbodymatter \stopbodymatter +\defineXMLenvironment [context:backmatter] \startbackmatter \stopbackmatter +\defineXMLenvironment [context:appendices] \startappendices \stopappendices + +\defineXMLargument [context:index] [key=] + {\doifelsenothingXMLop{key}{\index}{\expanded{\index[\XMLop{key}]}}} + +% \enableXMLfiledata + +% Needed for example (stickers and so): + +\defineXMLenvironment [context:makeup] + \startstandardmakeup \stopstandardmakeup + +\protect \endinput + +% TO DO + +\defineXMLenvironment [combination] [columns=2,rows=1] + {\scratchtoks\emptytoks + \expanded{\appendtoks \noexpand \startcombination + [\XMLop{columns}*\XMLop{rows}]}\to \scratchtoks} + {\appendtoks \stopcombination \to \scratchtoks + \the\scratchtoks} + +\defineXMLprocess[combinationentry] + +\defineXMLpickup [combinationitem] + {\appendtoks\bgroup}{\egroup\to\scratchtoks} + +\defineXMLpickup [combinationcaption] + {\appendtoks\bgroup}{\egroup\to\scratchtoks} + +\endinput diff --git a/tex/context/base/x-contml.tex b/tex/context/base/x-contml.tex deleted file mode 100644 index ba6762e77..000000000 --- a/tex/context/base/x-contml.tex +++ /dev/null @@ -1,493 +0,0 @@ -% interface=en - -%M \usemodule [contml] \autoXMLnamespace [context] -%M \definefilesynonym [context] [x-contml.xsd] - -%D \module -%D [ file=x-contml, -%D version=mid 2001, -%D title=\CONTEXT\ XML Support, -%D subtitle=Basic \CONTEXT\ commands, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -% This module provides some basic \XML\ elements. These definitions -% are highly experimental and serve as a playground for interface -% development. - -\unprotect - -%D \elements {include} -%D -%D \startbuffer -%D You can include another file in the current document with the -%D include element. When including the file, &context; -%D will look at the suffix, in order to decide how to include the file. -%D -%D -%D -%D -%D -%D -%D \stopbuffer -%D -%D \showelements [context] [include] - -\defineXMLsingular [context:include] [name=,type=xml] - {\doifsomethingXMLop{name} - {\processaction - [\XMLop{type}] - [xml=>\readfile{\XMLop{name}}\donothing\donothing, - tex=>{{\disableXML\readfile{\XMLop{name}}\donothing\donothing}}, - txt=>{{\disableXML\typefile{\XMLop{name}}}}]}} - -% or, nicer: -% -% \defineXMLsingular [context:include] [name=unknown,type=txt] -% {\XMLval{include:type}{\XMLop{type}}{}} -% -% \mapXMLvalue {include:type} {xml} {\readfile{\XMLop{name}}\donothing\donothing} -% \mapXMLvalue {include:type} {tex} {{\disableXML\readfile{\XMLop{name}}\donothing\donothing}} -% \mapXMLvalue {include:type} {txt} {{\disableXML\typefile{\XMLop{name}}}} - -%D \elements {compound} -%D -%D \startbuffer -%D Instead of using hard coded compound tokens, you should use the -%D compound element, as in highlow. -%D The overhead in keying is rewarded with proper symbols and hyphenation. -%D \stopbuffer -%D -%D \showelements [context] [compound] - -\ifx\normalcompound\undefined \let\normalcompound=| \fi - -% \defineXMLsingular [context:compound] [token=] -% {\expanded{\normalcompound\XMLop{token}}|} - -% \defineXMLsingular [context:compound] [token=] -% {\ifmmode -% \doifXMLop{token}{\XMLop{token}}{\compoundhyphen}% -% \else -% \expanded{\normalcompound\XMLop{token}}|% -% \fi} - -\defineXMLsingular [context:compound] [token=] - {\mathortext % disc comm looks ahead, so \relax - {\doifXMLop{token}{\XMLop{token}}\compoundhyphen}% - {\expanded{\directdiscretionary{\XMLop{token}}}\relax}} - -\defineXMLenvironmentsave [context:cp] - {} - {\expanded{\directdiscretionary{\XMLflush{cp}}}\relax} - -%D \elements {p} -%D -%D \startbuffer -%D

Although for &tex; it is often enough to mark the end of a paragraph, -%D in &xml; we want to add a bit more structure.

This permits a more -%D robust implementation of beginofpar actions

-%D \stopbuffer -%D -%D \showelements [context] [p] - -\defineXMLenvironment [context:p] {} \endgraf -\defineXMLsingular [context:p] \endgraf - -%D \elements {pageref,textref,lineref} -%D -%D \startbuffer -%D You can ask for a page (the last pagenumber -%D is aka page ), text or line reference -%D with the following three elements. The label may be any valid &context; -%D reference label. -%D \stopbuffer -%D -%D \showelements [context] [references] - -\defineXMLpickup [context:pageref] [label=] {\at} {[\XMLop{label}]} -\defineXMLpickup [context:textref] [label=] {\in} {[\XMLop{label}]} -\defineXMLpickup [context:lineref] [label=] {\inline} {[\XMLop{label}]} - -%D \elements{text} -%D -%D \startbuffer -%D If you have a self contained &xml; file, you need to signal &context; the -%D begin and end of the document. The following elements can be used for -%D that purpose: -%D -%D -%D -%D ... -%D -%D -%D \stopbuffer -%D -%D \showelements [context] [text] - -\defineXMLenvironment [context:text] \starttext \stoptext - -%D \elements {em} -%D -%D \startbuffer -%D Authors often want some control over the way a text is typeset, which is -%D why we provide the em element. We may only hope that -%D the author is consistent in his decisions on what to emphasize. -%D \stopbuffer -%D -%D \showelements [context] [em] - -\defineXMLgrouped [context:em] \em - -%D \elements {b} -%D -%D \startbuffer -%D Bold is not always beautiful but if you really want it, you can -%D get it by using this element. -%D \stopbuffer -%D -%D \showelements [context] [b] - -\defineXMLgrouped [context:b] \bf - -%D \elements {verbatim,typing,line,verb,type} -%D -%D \startbuffer -%D Although the following method can be used to typeset a piece of code -%D verbatim -%D -%D verbatim ! -%D ]]> -%D -%D we prefer the more structured: -%D -%D -%D Dit \is nogal verbatim ! -%D Dit is {nogal} verbatim ! -%D Dit is verbatim ! -%D -%D \stopbuffer -%D -%D The element to tag inline verbatim is . -%D -%D \showelements [context] [verbatim] - -\defineXMLenvironment [context:verbatim] - {\startpacked - \defineXMLargument[context:line]{\endgraf\type}} - {\stoppacked} - -\defineXMLenvironment [context:typing] - {\startpacked\defineXMLargument[context:line]{\endgraf\type}} - {\stoppacked} - -\defineXMLargument [context:verb] \type -\defineXMLargument [context:type] \type - -%D \elements {itemize,item} -%D -%D \startbuffer -%D Itemized lists are quite common in documents, al least in the ones that -%D we produce. For the moment we only provide a few options, later we will -%D hook it into the &context; attribute handler. -%D -%D -%D test -%D test -%D -%D -%D -%D test -%D test what? -%D -%D \stopbuffer -%D -%D \showelements [context] [itemize] - -\defineXMLenvironment [context:itemize] [type=,packed=] - {\let\XMLoptions\empty - \doifsomethingXMLop{type}{\addtocommalist{\XMLop{type}}\XMLoptions}% - \doifXMLop{packed}{yes}{\addtocommalist{packed}\XMLoptions}% - \expanded{\startitemize[\XMLoptions]}} - {\stopitemize} - -\defineXMLenvironment [context:item] [label=] - {\expanded{\item[\XMLop{label}]}} - {\endgraf} - -%D \elements {externalfigure} -%D -%D \startbuffer -%D The previous examples already demonstrated how we can include a graphic: -%D -%D -%D -%D -%D \stopbuffer -%D -%D \showelements [context] [externalfigure] - -\defineXMLsingular [context:externalfigure] [\??ef] [base=,label=,file=] - {\bgroup % \getXMLta \expandXMLta \expandXMLtp{file}% - \expandXMLta - \getXMLta % expand entities first - \doifelsenothing{\XMLtp{label}} - {\expanded{\externalfigure[\XMLtp{file}][\XMLta]}} - {\doifsomething{\XMLtp{base}}{\usefigurebase[\XMLtp{base}]}% - \expanded{\externalfigure[\XMLtp{label}][\XMLta]}} - \egroup} - -%D \elements {fixed} -%D \setupexternalfigures[directory={../sample}] -%D \startbuffer -%D Something fixed will end up at the place where it defined in the input -%D stream. The main idea behind this element is that it gives you control -%D over the placement. -%D -%D -%D -%D -%D -%D -%D -%D -%D -%D -%D \stopbuffer -%D -%D \showelements [context] [fixed] - -\defineXMLenvironment [context:fixed] [type=figure,location=,label=] - {\bgroup - \defineXMLsave[context:caption] - \defineXMLsave[context:content]} - {\expanded{\startfixed[\XMLop{location}]}% - \doifXMLdataelse{context:caption} - {\startcombination[1*1] - {\XMLflush{context:content}} {\XMLflush{context:caption}} - \stopcombination} - {\XMLflush{context:content}}% - \stopfixed - \egroup} - -%D \elements {float} -%D \setupexternalfigures[directory={../sample}] -%D \startbuffer -%D A floating body will be placed at the first location available, unless -%D a location is specified. As with the fixed element, -%D you can provide a caption. -%D -%D -%D -%D -%D -%D This is a cow! -%D -%D \stopbuffer -%D -%D \showelements [context] [float] - -\defineXMLenvironment [context:float] [type=figure,location=here,label=] - {\bgroup - \defineXMLsave[context:caption] - \defineXMLsave[context:content]} - {\expanded - {\placefloat - [\XMLop{type}] [\XMLop{location}] [\XMLop{label}] - {\XMLflush{context:caption}} {\XMLflush{context:content}}} - \egroup} - -%D \elements {quotation,quote} -%D -%D \startbuffer -%D There is a (not so) subtle difference between a display -%D quotation and an inline -%D one. -%D \stopbuffer -%D -%D \showelements [context] [table] - -\defineXMLgrouped [context:quote] \quote -\defineXMLgrouped [context:quotation] \quotation - -%D \elements {table,tr,td} -%D -%D \startbuffer -%D There are (currently) three table mechanisms in &context;. One of them -%D resembles the well known &html; tables. -%D -%D -%D -%D -%D -%D
one a first
two b second
-%D -%D -%D As you can see here, we use a similar syntax but stick to the &context; -%D attributes (which provide quite advanced control over the layout). -%D -%D -%D -%D -%D -%D
xx xx
xx xx
-%D -%D \stopbuffer -%D -%D \showelements [context] [table] - -\defineXMLenvironment [context:table] [\@@tbl\@@tbl] - {\bgroup - \defineXMLnested [context:tr] [\@@tbl] {\expanded{\bTR[\theXMLarguments{\@@tbl}}]} \eTR - \defineXMLnested [context:td] [\@@tbl] {\expanded{\bTD[\theXMLarguments{\@@tbl}}]} \eTD - \expanded{\bTABLE[\theXMLarguments{\@@tbl\@@tbl}]}} - {\eTABLE - \egroup} - -%D \elements {tabulate,tspec,thead,tbody,ttail,trule,tr,td} -%D -%D \startbuffer -%D The second mechanism that we support is tabulation. The advantage of this -%D mechanism is that it it well tuned for tables that have much text in the -%D cells and cross page boundaires. -%D -%D -%D -%D -%D -%D -%D -%D bagger bagger bagger -%D -%D -%D -%D -%D -%D -%D bagger bagger bagger -%D bagg ger gr -%D bag er gger -%D -%D -%D \stopbuffer -%D -%D \showelements [context] [tabulate] - -\newtoks\XMLtabtoks - -\defineXMLgrouped [context:tabulate] {\XMLtabtoks{|l|p|}} - -\defineXMLpickup [context:tbody] - {\expanded{\definetabulate[dummy][\the\XMLtabtoks]} - \startdummy\XMLflush{context:thead}} - {\XMLflush{context:ttail}\stopdummy} - -\defineXMLsave [context:thead] -\defineXMLsave [context:ttail] - -\defineXMLenvironment[context:tspec] - {\XMLtabtoks\emptytoks} - {\appendtoks|\to\XMLtabtoks} - -\defineXMLsingular [context:trule] % verrrry ugly - {\crcr\noalign{\kern-\lineheight}\HL} - -\defineXMLsingular [context:tcell] [align=] - {\appendtoks|\to\XMLtabtoks - \expanded{\processallactionsinset - [\XMLop{align}]} - [ paragraph=>\appendtoks p\to\XMLtabtoks, - left=>\appendtoks l\to\XMLtabtoks, - right=>\appendtoks r\to\XMLtabtoks, - center=>\appendtoks c\to\XMLtabtoks, - middle=>\appendtoks c\to\XMLtabtoks]} - -\defineXMLenvironment [context:tr] {\ignorespaces} {\NC\NR} -\defineXMLenvironment [context:td] {\NC} {\ignorespaces} - -%D \elements {hide} -%D -%D \startbuffer -%D This is the way to [this is gone] something for the -%D typesetting engine. Normally this element is only used for testing -%D purposes. -%D \stopbuffer -%D -%D \showelements [context] [tabulate] - -\defineXMLignore[context:hide] - -%D \elements {unknown} -%D -%D \startbuffer -%D We can go on and on and with defining elements that map onto -%D &context; commands, but why not just use &tex; input syntax then? -%D \stopbuffer -%D -%D \showelements [context] [unknown] - -\defineXMLsingular [context:unknown] \unknown - -%D A (for the moment) private one. - -\defineXMLargument [context:element] \type - -%D The following common schema definitions apply: -%D -%D {\setupcolors[state=stop]\showXSDcomponent[context][definitions]} - -\defineXMLargument [context:chapter] [label=] {\chapter[\XMLop{label}]} -\defineXMLargument [context:section] [label=] {\section[\XMLop{label}]} -\defineXMLargument [context:subsection] [label=] {\subsection[\XMLop{label}]} -\defineXMLargument [context:subsubsection] [label=] {\subsubsection[\XMLop{label}]} -\defineXMLargument [context:subsubsubsection] [label=] {\subsubsubsection[\XMLop{label}]} - -\defineXMLargument [context:title] [label=] {\title[\XMLop{label}]} -\defineXMLargument [context:subject] [label=] {\subject[\XMLop{label}]} -\defineXMLargument [context:subsubject] [label=] {\subsubject[\XMLop{label}]} -\defineXMLargument [context:subsubsubject] [label=] {\subsubsubject[\XMLop{label}]} -\defineXMLargument [context:subsubsubsubject] [label=] {\subsubsubsubject[\XMLop{label}]} - -\defineXMLenvironment [context:frontmatter] \startfrontmatter \stopfrontmatter -\defineXMLenvironment [context:bodymatter] \startbodymatter \stopbodymatter -\defineXMLenvironment [context:backmatter] \startbackmatter \stopbackmatter -\defineXMLenvironment [context:appendices] \startappendices \stopappendices - -\defineXMLargument [context:index] [key=] - {\doifelsenothingXMLop{key}{\index}{\expanded{\index[\XMLop{key}]}}} - -% \enableXMLfiledata - -% Needed for example (stickers and so): - -\defineXMLenvironment [context:makeup] - \startstandardmakeup \stopstandardmakeup - -\protect \endinput - -% TO DO - -\defineXMLenvironment [combination] [columns=2,rows=1] - {\scratchtoks\emptytoks - \expanded{\appendtoks \noexpand \startcombination - [\XMLop{columns}*\XMLop{rows}]}\to \scratchtoks} - {\appendtoks \stopcombination \to \scratchtoks - \the\scratchtoks} - -\defineXMLprocess[combinationentry] - -\defineXMLpickup [combinationitem] - {\appendtoks\bgroup}{\egroup\to\scratchtoks} - -\defineXMLpickup [combinationcaption] - {\appendtoks\bgroup}{\egroup\to\scratchtoks} - -\endinput diff --git a/tex/context/base/x-corres.mkii b/tex/context/base/x-corres.mkii new file mode 100644 index 000000000..09c7263dc --- /dev/null +++ b/tex/context/base/x-corres.mkii @@ -0,0 +1,136 @@ +%D \module +%D [ file=x-corres, +%D version=2003.12.15, % replaces keep-02a cum suis +%D title=\CONTEXT\ XML Modules, +%D subtitle=Handling Correspondence Base, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The selection spec: + +\setvariables + [contacts] + [selection=, + file=x-corres.xml] % fall back + +%D First we define the group expansion pass: + +\startsetups[contacts:collect] + + \defineXMLprocess [contacts] + + \defineXMLignore [contact] + + \defineXMLargument [contactfile] + \processfile + + \defineXMLenvironmentsave [contactgroup] [label=] + {\startXMLmappinggroup[contacts]} + {\XMLaddcontactgrouptoselection + \stopXMLmappinggroup} + +\stopsetups + +%D Next we define the main processing pass: + +\startsetups[contacts:process] + + \defineXMLprocess[contacts] + + \defineXMLignore [contactgroup] + + \defineXMLargument [contactfile] + \processfile + + \defineXMLenvironmentsave[contact] [label=] + {\startXMLmappinggroup[contacts]} + {\XMLselectcontact + \stopXMLmappinggroup} + +\stopsetups + +\startXMLmapping[contacts] + + \defineXMLsave [initials] + \defineXMLsave [formalname] + \defineXMLsave [informalname] + \defineXMLsave [title] + \defineXMLsave [prefix] + \defineXMLsave [suffix] + \defineXMLsave [telephone] + \defineXMLsave [mobiletelephone] + \defineXMLsave [telefax] + \defineXMLsave [email] + \defineXMLsave [address] + \defineXMLsave [information] + + \defineXMLenvironment [p] \endgraf \endgraf + + \defineXMLargument [member] \XMLaddcontacttoselection + +\stopXMLmapping + +%D The selection macros: we expand groups and replace them +%D by contact labels in the selection spec. + +\def\XMLaddcontactgrouptoselection + {\edef\XMLcontactlist{\getvariable{contacts}{selection}}% + \edef\XMLgrouplabel {\XMLop{label}}% + \expanded{\doifinset{\XMLgrouplabel}{\XMLcontactlist}} + {\let\XMLgrouplist\empty + \XMLflush{contactgroup}% + \substituteincommalist\XMLgrouplabel\XMLgrouplist\XMLcontactlist + \expanded + {\globalsetvariables + [contacts] + [selection={\XMLcontactlist}]}}} + +\def\XMLaddcontacttoselection#1% + {\addtocommalist{#1}\XMLgrouplist} + +%D The main selector: + +\def\XMLselectcontact + {\edef\XMLcontactlist {\getvariable{contacts}{selection}}% + \edef\XMLcontactlabel{\XMLop{label}}% + \doifelsenothing{\XMLcontactlist} + {\donetrue} + {\expanded{\doifinsetelse{\XMLcontactlabel}{\XMLcontactlist}} + {\donetrue} + {\donefalse}}% + \ifdone + \XMLflush{contact}% + \setups[contact:handle]% + \fi} + +%D The default: + +\startsetups[contact:handle] + + \XMLflush{address} + +\stopsetups + +\setups[contacts:process] + +%D Handy: + +\def\XMLprocesscontacts + {\dosingleempty\XMLprocesscontacts} + +\def\XMLprocesscontacts[#1]% + {\bgroup + \doifelsenothing{#1} + {\XMLprocesscontacts[\getvariable{contacts}{file}]} + {\setups[contacts:collect]% + \processcommacommand[#1]\processXMLfile + \setups[contacts:process]% + \processcommacommand[#1]\processXMLfile}% + \egroup} + +\endinput diff --git a/tex/context/base/x-corres.tex b/tex/context/base/x-corres.tex deleted file mode 100644 index 09c7263dc..000000000 --- a/tex/context/base/x-corres.tex +++ /dev/null @@ -1,136 +0,0 @@ -%D \module -%D [ file=x-corres, -%D version=2003.12.15, % replaces keep-02a cum suis -%D title=\CONTEXT\ XML Modules, -%D subtitle=Handling Correspondence Base, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -%D The selection spec: - -\setvariables - [contacts] - [selection=, - file=x-corres.xml] % fall back - -%D First we define the group expansion pass: - -\startsetups[contacts:collect] - - \defineXMLprocess [contacts] - - \defineXMLignore [contact] - - \defineXMLargument [contactfile] - \processfile - - \defineXMLenvironmentsave [contactgroup] [label=] - {\startXMLmappinggroup[contacts]} - {\XMLaddcontactgrouptoselection - \stopXMLmappinggroup} - -\stopsetups - -%D Next we define the main processing pass: - -\startsetups[contacts:process] - - \defineXMLprocess[contacts] - - \defineXMLignore [contactgroup] - - \defineXMLargument [contactfile] - \processfile - - \defineXMLenvironmentsave[contact] [label=] - {\startXMLmappinggroup[contacts]} - {\XMLselectcontact - \stopXMLmappinggroup} - -\stopsetups - -\startXMLmapping[contacts] - - \defineXMLsave [initials] - \defineXMLsave [formalname] - \defineXMLsave [informalname] - \defineXMLsave [title] - \defineXMLsave [prefix] - \defineXMLsave [suffix] - \defineXMLsave [telephone] - \defineXMLsave [mobiletelephone] - \defineXMLsave [telefax] - \defineXMLsave [email] - \defineXMLsave [address] - \defineXMLsave [information] - - \defineXMLenvironment [p] \endgraf \endgraf - - \defineXMLargument [member] \XMLaddcontacttoselection - -\stopXMLmapping - -%D The selection macros: we expand groups and replace them -%D by contact labels in the selection spec. - -\def\XMLaddcontactgrouptoselection - {\edef\XMLcontactlist{\getvariable{contacts}{selection}}% - \edef\XMLgrouplabel {\XMLop{label}}% - \expanded{\doifinset{\XMLgrouplabel}{\XMLcontactlist}} - {\let\XMLgrouplist\empty - \XMLflush{contactgroup}% - \substituteincommalist\XMLgrouplabel\XMLgrouplist\XMLcontactlist - \expanded - {\globalsetvariables - [contacts] - [selection={\XMLcontactlist}]}}} - -\def\XMLaddcontacttoselection#1% - {\addtocommalist{#1}\XMLgrouplist} - -%D The main selector: - -\def\XMLselectcontact - {\edef\XMLcontactlist {\getvariable{contacts}{selection}}% - \edef\XMLcontactlabel{\XMLop{label}}% - \doifelsenothing{\XMLcontactlist} - {\donetrue} - {\expanded{\doifinsetelse{\XMLcontactlabel}{\XMLcontactlist}} - {\donetrue} - {\donefalse}}% - \ifdone - \XMLflush{contact}% - \setups[contact:handle]% - \fi} - -%D The default: - -\startsetups[contact:handle] - - \XMLflush{address} - -\stopsetups - -\setups[contacts:process] - -%D Handy: - -\def\XMLprocesscontacts - {\dosingleempty\XMLprocesscontacts} - -\def\XMLprocesscontacts[#1]% - {\bgroup - \doifelsenothing{#1} - {\XMLprocesscontacts[\getvariable{contacts}{file}]} - {\setups[contacts:collect]% - \processcommacommand[#1]\processXMLfile - \setups[contacts:process]% - \processcommacommand[#1]\processXMLfile}% - \egroup} - -\endinput diff --git a/tex/context/base/x-fe.mkii b/tex/context/base/x-fe.mkii new file mode 100644 index 000000000..8562b1d52 --- /dev/null +++ b/tex/context/base/x-fe.mkii @@ -0,0 +1,143 @@ +%D \module +%D [ file=x-fe, +%D version=2004.03.12, % based on earlier experiments +%D title=\FOXET, +%D subtitle=Simple Extensions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Extensions: fe:definecolor + +% menus +% extra areas +% protruding and hz +% compound +% title container +% more float placements + +\unprotect + +% \XMLattributes{aural}, + +\defineXMLnested + [fe:table-next] + [id=, + \XMLattributes{accessibility}, + \XMLattributes{border-padding-background}, + \XMLattributes{relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + visibility=] + {\bTABLEnext} + {\eTABLEnext} + +% definitions + +\defineXMLcommand + [fe:definecolor] + [name=,r=,g=,b=,c=,m=,y=,k=,s=,p=,a=,t=] + {\expanded{\definecolor[\XMLop{name}] + [r=\XMLop r,g=\XMLop g,b=\XMLop b, + c=\XMLop c,m=\XMLop m,y=\XMLop y,k=\XMLop k, + s=\XMLop s,p=\XMLop p,a=\XMLop a,t=\XMLop t]}} + +\defineXMLcommand + [fe:definefontsynonym] + [name=,file=,encoding=] + {\doifelsenothing{\XMLop{encoding}} + {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}][encoding=\XMLop{encoding}]}} + {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}]}}} + +%D Extensions: fe:include + +\defineXMLsingular + [fe:include] + [url=,n=1] + {\doifelse{\XMLop{n}}{1} + {\readfile{\XMLpar{fe:include}{url}{}}{}{}} + {\dorecurse{\XMLop{n}}{\readfile{\XMLpar{fe:include}{url}{}}{}{}\endgraf}}} + +%D Extensions: fe:sample + +\defineXMLenvironment + [fe:sample] + [origin=unknown] + {\removeunwantedspaces\ignorespaces} + {\removeunwantedspaces} + +%D Extensions: fe: + +% \defineXMLenvironmentsave +% [fe:loop] +% [n=1] +% {} +% {\dorecurse{\XMLop{n}}{\XMLflush{fe:loop}}} + +\defineXMLargument + [fe:loop] + [n=1] + {\dorecurse{\XMLop{n}}} + +%D Extensions: fe:compound + +\defineXMLsingular + [fe:compound] + [character=-] + {\prewordbreak\XMLop{character}\prewordbreak} + +%D Extensions: fe:message + +\defineXMLargument + [fe:message] + [category=XML-FO] + {\expanded{\writestatus{\XMLop{category}}}} + +%D Handy + +\defineXMLargument + [fe:trace] + [attribute=,option=] + {\showXMLinh[\XMLop{attribute}]% + \XMLval{fe:trace}{\XMLop{option}}{}} + +\mapXMLvalue + {fe:trace} + {font} + {\hbox\bgroup\infofont[% + \xFOfont/\xFOfontsize/\xFOfontsizeadjust/\xFOfontfamily/\xFOfontweight/\xFOfontstyle/\xFOfontvariant:\FOfontdefinition + ]\egroup} + +%D Extensions: + +\startsetups fe:page:option:fit:start + \startTEXpage[margin=page] +\stopsetups + +\startsetups fe:page:option:fit:stop + \stopTEXpage +\stopsetups + +\useMPlibrary[pre] + +\mapXMLvalue {fe:tracing} {true} {\tracingFOtrue} +\mapXMLvalue {fe:tracing} {false} {\tracingFOfalse} +\mapXMLvalue {fe:testgrid} {true} {\setupbackgrounds[page][background=pagegrid]} + +\startsetups fe:setup + \XMLval{fe:tracing} {\XMLop{fe:tracing}} {} + \XMLval{fe:testgrid}{\XMLop{fe:testgrid}}{} +\stopsetups + +%D Private (testing) + +\defineXMLcommand[fe:synchronizeoutput]{\synchronizeoutput} + + +\protect \endinput diff --git a/tex/context/base/x-fe.tex b/tex/context/base/x-fe.tex deleted file mode 100644 index 8562b1d52..000000000 --- a/tex/context/base/x-fe.tex +++ /dev/null @@ -1,143 +0,0 @@ -%D \module -%D [ file=x-fe, -%D version=2004.03.12, % based on earlier experiments -%D title=\FOXET, -%D subtitle=Simple Extensions, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -%D Extensions: fe:definecolor - -% menus -% extra areas -% protruding and hz -% compound -% title container -% more float placements - -\unprotect - -% \XMLattributes{aural}, - -\defineXMLnested - [fe:table-next] - [id=, - \XMLattributes{accessibility}, - \XMLattributes{border-padding-background}, - \XMLattributes{relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - visibility=] - {\bTABLEnext} - {\eTABLEnext} - -% definitions - -\defineXMLcommand - [fe:definecolor] - [name=,r=,g=,b=,c=,m=,y=,k=,s=,p=,a=,t=] - {\expanded{\definecolor[\XMLop{name}] - [r=\XMLop r,g=\XMLop g,b=\XMLop b, - c=\XMLop c,m=\XMLop m,y=\XMLop y,k=\XMLop k, - s=\XMLop s,p=\XMLop p,a=\XMLop a,t=\XMLop t]}} - -\defineXMLcommand - [fe:definefontsynonym] - [name=,file=,encoding=] - {\doifelsenothing{\XMLop{encoding}} - {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}][encoding=\XMLop{encoding}]}} - {\expanded{\definefontsynonym[\XMLop{name}][\XMLop{file}]}}} - -%D Extensions: fe:include - -\defineXMLsingular - [fe:include] - [url=,n=1] - {\doifelse{\XMLop{n}}{1} - {\readfile{\XMLpar{fe:include}{url}{}}{}{}} - {\dorecurse{\XMLop{n}}{\readfile{\XMLpar{fe:include}{url}{}}{}{}\endgraf}}} - -%D Extensions: fe:sample - -\defineXMLenvironment - [fe:sample] - [origin=unknown] - {\removeunwantedspaces\ignorespaces} - {\removeunwantedspaces} - -%D Extensions: fe: - -% \defineXMLenvironmentsave -% [fe:loop] -% [n=1] -% {} -% {\dorecurse{\XMLop{n}}{\XMLflush{fe:loop}}} - -\defineXMLargument - [fe:loop] - [n=1] - {\dorecurse{\XMLop{n}}} - -%D Extensions: fe:compound - -\defineXMLsingular - [fe:compound] - [character=-] - {\prewordbreak\XMLop{character}\prewordbreak} - -%D Extensions: fe:message - -\defineXMLargument - [fe:message] - [category=XML-FO] - {\expanded{\writestatus{\XMLop{category}}}} - -%D Handy - -\defineXMLargument - [fe:trace] - [attribute=,option=] - {\showXMLinh[\XMLop{attribute}]% - \XMLval{fe:trace}{\XMLop{option}}{}} - -\mapXMLvalue - {fe:trace} - {font} - {\hbox\bgroup\infofont[% - \xFOfont/\xFOfontsize/\xFOfontsizeadjust/\xFOfontfamily/\xFOfontweight/\xFOfontstyle/\xFOfontvariant:\FOfontdefinition - ]\egroup} - -%D Extensions: - -\startsetups fe:page:option:fit:start - \startTEXpage[margin=page] -\stopsetups - -\startsetups fe:page:option:fit:stop - \stopTEXpage -\stopsetups - -\useMPlibrary[pre] - -\mapXMLvalue {fe:tracing} {true} {\tracingFOtrue} -\mapXMLvalue {fe:tracing} {false} {\tracingFOfalse} -\mapXMLvalue {fe:testgrid} {true} {\setupbackgrounds[page][background=pagegrid]} - -\startsetups fe:setup - \XMLval{fe:tracing} {\XMLop{fe:tracing}} {} - \XMLval{fe:testgrid}{\XMLop{fe:testgrid}}{} -\stopsetups - -%D Private (testing) - -\defineXMLcommand[fe:synchronizeoutput]{\synchronizeoutput} - - -\protect \endinput diff --git a/tex/context/base/x-fo.mkii b/tex/context/base/x-fo.mkii new file mode 100644 index 000000000..b2b0b59f9 --- /dev/null +++ b/tex/context/base/x-fo.mkii @@ -0,0 +1,4059 @@ +%D \module +%D [ file=x-fo, +%D version=2004.03.12, % based on earlier experiments +%D title=\FOXET, +%D subtitle=Formatting Objects, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% \showframe + +% This is a first implementation, maybe I will write another one with mixed +% element indifferent vars and something 'when set, act upon it, and forget', +% for instance: in each element check if font set, if so, change font and +% reset font attributes. I'm not sure if this is wise. + +% todo: global assignment in order to limit restore +% todo: combine mp graphics (see end) saves 30% +% todo: using contants and variables (for internal use) + +% todo: language at more levels + +% beware: aftergroup vs egroup/endgroup + +\useXMLfilter[prs,run] + +% \input xtag-run + +\unprotect + +% syst-new.tex + +\long\def\unstringed#1% " ' space + {\csname\ifcsname @u@s@#1\endcsname @u@s@#1\else\s!empty\fi\endcsname#1} + +\long\setvalue{@u@s@"}#1#2"{#2} +\long\setvalue{@u@s@'}#1#2'{#2} +\long\setvalue{@u@s@ }#1#2 {#2} + +% xtag-ini + +\def\letXMLpar #1#2{\@EA \let\csname\@@XMLvariable:#1:#2\endcsname} +\def\setXMLpar #1#2{\@EA \def\csname\@@XMLvariable:#1:#2\endcsname} +\def\setXMLepar#1#2{\@EA\edef\csname\@@XMLvariable:#1:#2\endcsname} + +\protect + +%D Most time went into figuring out the specifications, especially +%D because there are no examples included. Samples that circulate on the +%D web are often border cases and torture test and don't have much to do +%D with real live. Another complication lays in the inheritance model: +%D some of the attributes are inherited. This also leaves some room for +%D interpretation, for instance do values that are used at a certain +%D point migrate downwards or not. +%D +%D The \CONTEXT\ \XML handler can deal with attributes in several ways +%D and for this purpose I have played with a few experimental mechanisms +%D just to end up with the existing begin/end mechanism combined with +%D a recursive attribute resolver which means that one has to implicitly +%D ask for an inherited attributes. This approach is probably one of the +%D most efficient ways of dealing with formatting objects in \CONTEXT, +%D unless of course I start adding rather specific support to the kernel. +%D +%D This module is rather experimental. More information about its usage +%D can be found in the \FOXET\ manual. + +%D Since we're not dealing with the fine points of typesetting here, we +%D can safely ignore \TEX's warnings about overful or underful boxes. + +\dontcomplain + +%D We will use fonts that have the characters in the normal (ascii) +%D slots. We will also use the stupid verbatim handler. + +\chardef\XMLtokensreduction = 2 +\chardef\XMLcdatamethod = 2 + +%D For the purpose of testing. + +\startmode[fo-verbose] + \def\writeFOstatus{\writestatus{XML-FO}} +\stopmode + +\startnotmode[fo-verbose] + \let\writeFOstatus\gobbleoneargument +\stopnotmode + +%D For the moment we stick to utf-8. + +\useXMLfilter[utf] + +%D This will be sorted out later (esp in relation to mathml). + +\setupbodyfont[pos,10pt] + +%D There are a couple of predefined colors. Don't ask me why, but +%D formatting objects are not a fresh start but a mix of existing +%D technologies. Color support is poluted by cascading stylesheets. +%D +%D Because hexadecimal color specifications are not enabled by +%D default, this feature has to be enables by loading the appropriate +%D color module. Here we define colors in \RGB\ values because we +%D don't want to loose accuracy. + +\setupcolors[state=start] \setupcolor[hex] + +\definecolor [black] [s=0] % [h=000000] +\definecolor [gray] [s=.5] % [h=808080] +\definecolor [silver] [s=.75] % [h=C0C0C0] +\definecolor [white] [s=1] % [h=FFFFFF] +\definecolor [maroon] [r=.5] % [h=800000] +\definecolor [red] [r=1] % [h=FF0000] +\definecolor [purple] [r=.5,b=.5] % [h=800080] +\definecolor [fuchsia] [r=1,b=1] % [h=FF00FF] +\definecolor [green] [g=.5] % [h=008000] +\definecolor [lime] [g=1] % [h=00FF00] +\definecolor [olive] [r=.5,g=.5] % [h=808000] +\definecolor [yellow] [r=1,g=1] % [h=FFFF00] +\definecolor [navy] [r=1,g=1] % [h=000080] +\definecolor [blue] [b=1] % [h=0000FF] +\definecolor [teal] [g=.5,b=.5] % [h=008080] +\definecolor [aqua] [g=1,b=1] % [h=00FFFF] + +%D The layout is rather basic. Of the 25 available areas we +%D only use the text area. Maybe some day I will plug in a +%D more dedicated page builder. + +\setuplayout + [backspace=0pt, + topspace=0pt, + header=0pt, + footer=0pt, + width=middle, + height=middle, + % marking=on, + location=middle] + +\setuppagenumbering + [alternative={doublesided,singlesided}, % sic + location=] + +\setuptolerance + [verytolerant,stretch] + +%D We will position the regions using layers. + +\definelayer[regions][width=\paperwidth,height=\paperheight] + +\definelayer[xsl-region-before] +\definelayer[xsl-region-after] +\definelayer[xsl-region-start] +\definelayer[xsl-region-end] +\definelayer[xsl-region-body] + +\setupbackgrounds[page][background=regions] + +%D We now enter the part of this module where the action takes +%D place. As usual we provide some tracing options. + +\newif\iftracingFO \readsysfile{page-run}\donothing\donothing + +%D We will organize the attribute definitions in a similar fashion as in +%D the specification. Unfortunately there are more sets defined in there +%D than are actually used, so the definitions later on will look a bit +%D messy. +%D +%D Quite some attributes can be inherited, which means that they can +%D end up in all elements and influence those way down the tree. + +\defineXMLattributeset + [fo:inherited] + +%D The properties: + +% \defineXMLattributeset +% [fe:tracing] +% [tracing=] + +\defineXMLattributeset + [fo:accessibility] + [source-document=none, + role=none] + +\defineXMLattributeset + [fo:absolute-position] + [absolute-position=auto, + top=auto, + right=auto, + bottom=auto, + left=auto] + +% \defineXMLattributeset +% [fo:aural] +% [azitmuth=, +% cue-after=, +% cue-before=, +% elevation=, +% pause-after=, +% pause-before=, +% pitch=, +% pitch-range=, +% play-during=, +% richness=, +% speak=, +% speak-header=, +% speak-numeral=, +% speak-punctuation=, +% speech-rate=, +% stress=, +% voice-family=, +% volume=] + +\defineXMLattributeset + [fo:border-padding-background] + [background-attachment=scroll, + background-color=transparent, + background-image=none, + background-repeat=repeat, + background-position-horizontal=left, + background-position-vertical=top, + border-color=transparent, + border-style=none, + border-width=medium, + background-position=, + border-top=, + border-bottom=, + border-left=, + border-right=, + border-before-color=\XMLop{border-color}, + border-before-style=\XMLop{border-style}, + border-before-width=\XMLop{border-width}, + border-after-color=\XMLop{border-color}, + border-after-style=\XMLop{border-style}, + border-after-width=\XMLop{border-width}, + border-start-color=\XMLop{border-color}, + border-start-style=\XMLop{border-style}, + border-start-width=\XMLop{border-width}, + border-end-color=\XMLop{border-color}, + border-end-style=\XMLop{border-style}, + border-end-width=\XMLop{border-width}, + border-top-color=\XMLop{border-before-color}, + border-top-style=\XMLop{border-before-style}, + border-top-width=\XMLop{border-before-width}, + border-bottom-color=\XMLop{border-after-color}, + border-bottom-style=\XMLop{border-after-style}, + border-bottom-width=\XMLop{border-after-width}, + border-left-color=\XMLop{border-start-color}, + border-left-style=\XMLop{border-start-style}, + border-left-width=\XMLop{border-start-width}, + border-right-color=\XMLop{border-end-color}, + border-right-style=\XMLop{border-end-style}, + border-right-width=\XMLop{border-end-width}, + padding=,% 0pt, + padding-before=0pt,%\XMLop{padding}, + padding-after=0pt,%\XMLop{padding}, + padding-start=0pt,%\XMLop{padding}, + padding-end=0pt,%\XMLop{padding}, + padding-top=\XMLop{padding-before}, + padding-bottom=\XMLop{padding-after}, + padding-left=\XMLop{padding-start}, + padding-right=\XMLop{padding-end}] + +\extendXMLattributeset + [fo:border-padding-background] + [fe:background-height=, + fe:background-width=] + +\defineXMLattributeset + [fo:font] + [] + +\extendXMLattributeset + [fo:inherited] + [font=, + font-family=,% Times, + font-selection-strategy=, + font-size=,% 12pt, + font-size-adjust=, % 1, + font-style=, % normal, + font-variant=, % normal, + font-weight=] % normal] + +\defineXMLattributeset + [fo:hyphenation] + [] + +\extendXMLattributeset + [fo:inherited] + [country=, + language=, + script=, + hyphenate=, + hyphenation-character=, + hyphenation-push-character-count=, + hyphenation-remain-character-count=] + +\defineXMLattributeset + [fo:margin-block] + [margin=, % 0pt, + margin-top=0pt,% \XMLop{margin}, + margin-bottom=0pt,% \XMLop{margin}, + margin-left=0pt,% \XMLop{margin}, + margin-right=0pt,% \XMLop{margin}, + space-before=0pt, + space-after=0pt, + space-before.precedence=, + space-before.conditionality=, + space-before.minimum=, + space-before.optimum=, + space-before.maximum=, + space-after.precedence=, + space-after.conditionality=, + space-after.minimum=, + space-after.optimum=, + space-after.maximum=] + +\extendXMLattributeset + [fo:inherited] + [start-indent=, + end-indent=] + +\defineXMLattributeset + [fo:margin-inline] + [space-start=, + space-end=] + +\defineXMLattributeset + [fo:relative-position] + [relative-position=, + top=auto, + right=auto, + bottom=auto, + left=auto] + +\defineXMLattributeset + [fo:area-alignment] + [alignment-adjust=, + alignment-baseline=, + baseline-shift=, + dominant-baseline=] + +\extendXMLattributeset + [fo:inherited] + [display-align=, + relative-align=] + +\defineXMLattributeset + [fo:area-dimension] + [block-progression-dimension=, + inline-progression-dimension=, + content-height=, + content-width=, + height=, + width=, + max-height=, + max-width=, + min-height=, + min-width=, + scaling=, + scaling-method=] + +\defineXMLattributeset + [fo:block-and-line] + [] + +\extendXMLattributeset + [fo:inherited] + [hyphenation-keep=, + hyphenation-ladder-count=, + last-line-end-indent=, + line-height=, + line-height-shift-adjustment=, + line-stacking-strategy=, + linefeed-treatment=, + white-space-treatment=, + text-align=, + text-align-last=, + text-indent=, + white-space-collapse=, + wrap-option=] + +\defineXMLattributeset + [fo:character] + [character=, + suppress-at-line-break=, + text-decoration=, + text-shadow=, + treat-as-word-space=] + +\extendXMLattributeset + [fo:inherited] + [letter-spacing=, + text-transform=, + word-spacing=] + +\defineXMLattributeset + [fo:color] + [color-profile-name=, + rendering-intent=] + +\extendXMLattributeset + [fo:inherited] + [color=] + +\defineXMLattributeset + [fo:float] + [clear=, + float=] + +\extendXMLattributeset + [fo:inherited] + [intrusion-displace=] + +\defineXMLattributeset + [fo:keeps-and-breaks] + [break-after=, + break-before=, + keep-with-next.within-line=, + keep-with-next.within-column=, + keep-with-next.within-page=, + keep-with-previous.within-line=, + keep-with-previous.within-column=, + keep-with-previous.within-page=] + +\extendXMLattributeset + [fo:inherited] + [keep-together.within-line=, + keep-together.within-column=, + keep-together.within-page=, + orphans=, + widows=] + +\defineXMLattributeset + [fo:layout] + [clip=, + overflow= + span=] + +\extendXMLattributeset + [fo:inherited] + [reference-orientation=] + +\defineXMLattributeset + [fo:leader-and-rule] + [] + +\extendXMLattributeset + [fo:inherited] + [leader-alignment=, + leader-pattern=, + leader-pattern-width=, + leader-pattern-width=, + leader-length=, + rule-style=, + rule-thickness=] + +\defineXMLattributeset + [fo:dynamic-effects] + [active-state=, + case-name=, + case-title=, + destination-placement-offset=, + external-destination=, + indicate-destination=, + internal-destination=, + show-destination=, + starting-state=, + switch-to=, + target-presentation-context=, + target-processing-context=, + target-stylesheet=] + +\extendXMLattributeset + [fo:inherited] + [auto-restore=] + +\defineXMLattributeset + [fo:markers] + [marker-class-name=, + retrieve-class-name=, + retrieve-position=, + retrieve-boundary=] + +\defineXMLattributeset + [fo:number-to-string] + [country=, + language=, + format=, + grouping-separator=, + grouping-size=, + letter-value=] + +% \defineXMLattributeset +% [fo:pagination-and-layout] +% [black-or-not-blank=, +% column-count=1, +% column-gap=12pt, +% extent=, +% flow-name=, +% force-page-count=, +% initial-page-number=, +% master-name=, +% master-reference=, +% maximum-repeats=, +% media-usage=, +% odd-or-even=, +% page-height=, +% page-position=, +% page-width=, +% precedence=, +% region-name=] + +\defineXMLattributeset + [fo:table] + [border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + column-number=, + column-width=, + ends-row=, + number-columns-repeated=, + number-columns-spanned=, + number-rows-spanned=, + starts-row=, + table-layout=, + table-omit-footer-at-break=, + table-omit-header-at-break=] + +\extendXMLattributeset + [fo:inherited] + [border-collapse=, + border-separation=, + caption-side=, + empty-cells=] + +\defineXMLattributeset + [fo:writing-mode] + [%text-altitude=, + %text-depth=, + unicode-bidi=] + +\extendXMLattributeset % for practical reasons we inherit along the whole chain + [fo:inherited] % unless we implement relax skipping + [text-altitude=, + text-depth=] + +\extendXMLattributeset + [fo:inherited] + [direction=, + glyph-orientation-horizontal=, + glyph-orientation-vertical=, + writing-mode=] + +\defineXMLattributeset + [fo:list-block] + [] + +\extendXMLattributeset + [fo:inherited] + [provisional-label-separation=, + provisional-distance-between-starts=] + +% \starttext +% \setuplayout[topspace=1cm,height=middle,header=0pt,footer=0pt] +% \setupbodyfont[small,tt] +% \expanded{\processcommalist[\XMLattributeset{fo:inherited}]}\endgraf +% \stoptext + +% content-type +% id + +% ref-id +% score-spaces % inherited +% src +% visibility % inherited +% z-index + +% shorthands: +% +% background +% background-position +% border +% border-bottom +% border-left +% border-top +% border-right +% border-style +% border-color +% border-spacing % inherited +% border-width +% cue +% font % inherited +% margin +% padding +% page-break-after +% page-break-before +% page-break-inside % inherited +% pause +% position +% size +% vertical-align +% white-space % inherited + +%D We will speed up the process of setting up attributes by compiling the +%D definitions. Sometimes we need to access attributes explicitly by +%D element (for instance when handling regions). We also need to deal +%D with nested elements (for instance blocks) or a sequence of similar +%D ones, while we may not always want to use grouping. As a result, the +%D next series of definitions and macros are quite ugly. The begin|/|end +%D is needed in order to comfortably fetch attribute values from +%D ancestors. + +\startXMLcompiling[inherit] + +%D Element: fo:root + +%D todo: set defaults here + +\defineXMLenvironment + [fo:root] + [\XMLattributeset{fo:inherited}, +leader-pattern=spaces, +leader-pattern-width=12pt, + media-usage=] + {\directsetup{fo:root:start}} + {\directsetup{fo:root:stop}} + +\startsetups fo:root:start + \starttext \beginXMLelement \startXMLignore + \doifsomething{\XMLop{language}}{\mainlanguage[\XMLop{language}]}% todo, everywhere +\stopsetups + +\startsetups fo:root:stop + \stopXMLignore \endXMLelement \stoptext +\stopsetups + +%D Element: fo:declarations + +\defineXMLprocess + [fo:declarations] + +%D Element: fo:color-profile + +\defineXMLignore + [fo:color-profile] + [src=, + color-profile-name=, + rendering-intent=] + +%D Element: fo:page-sequence + +% master-name and master-reference are often mixed up in examples + +\defineXMLenvironment + [fo:page-sequence] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:number-to-string}, + initial-page-number=auto, + master-reference=any, + force-page-count=auto] + {\beginXMLelement\directsetup{fo:page-sequence:start}} + {\directsetup{fo:page-sequence:stop}\endXMLelement} + +\mapXMLvalue {fo:page-initial} {auto} {\relax} +\mapXMLvalue {fo:page-initial} {auto-odd} {\ifodd\pageno \expanded{\setuppagenumber[number=\the\dimexpr(\pageno+1)]}\fi} +\mapXMLvalue {fo:page-initial} {auto-even} {\ifodd\pageno\else\expanded{\setuppagenumber[number=\the\dimexpr(\pageno+1)]}\fi} + +% todo: blokkeer left/right/etc in geval van blank + +\mapXMLvalue {fo:page-start} {auto} {\page} +\mapXMLvalue {fo:page-start} {even} {\page\setuplayout[blank]\page[even]} +\mapXMLvalue {fo:page-start} {odd} {\page\setuplayout[blank]\page[odd]} +\mapXMLvalue {fo:page-end} {end-on-even} {\page\setuplayout[blank]\page[even]} +\mapXMLvalue {fo:page-end} {end-on-odd} {\page\setuplayout[blank]\page[odd]} +\mapXMLvalue {fo:page-start} {no-force} {\page} + +\startsetups fo:page-sequence:start + + % we're still in the previous page-sequence + + \XMLval{fo:page-start}{\XMLop{force-page-count}}{\page} \begingroup + + \directsetup{fe:setup} + + \iftracingFO \showframe[text] \fi + + \xdef\SavedPageNumber{\the\realpageno} + + % now we enter the new page-sequence + + % todo: check on number + + \doifXMLvalelse{fo:page-initial}{\XMLop{initial-page-number}} + {\XMLval{fo:page-initial}{\XMLop{initial-page-number}}{}} + {\doifnot{\XMLop{initial-page-number}}{auto} + {\expanded{\setuppagenumber[number=\XMLop{initial-page-number}]}}} + + \doifsomething{\XMLpar{fo:page-sequence}{master-reference}{}} + {\doifelseXMLelement{fo:page-sequence-master:\XMLpar{fo:page-sequence}{master-reference}{}} + {%[starting page sequence master: \XMLpar{fo:page-sequence}{master-reference}{}]\endgraf + \flushXMLelement{fo:page-sequence-master:\XMLpar{fo:page-sequence}{master-reference}{}}} + {%[starting simple page master: \XMLpar{fo:page-sequence}{master-reference}{any}]\endgraf + \flushXMLelement{fo:simple-page-master:\XMLpar{fo:page-sequence}{master-reference}{any}}}} + + \doif{\XMLpar{fo:simple-page-master-do}{fe:option}{}}{fit} + {\directsetup{fe:page:option:fit:start}} + + \doifnot{\XMLpar{fo:region-body}{column-count}{1}}{1} + {\directsetup{fo:columns:start}} + +\stopsetups + +\startsetups fo:page-sequence:stop + + \doifnot{\XMLpar{fo:region-body}{column-count}{1}}{1} + {\directsetup{fo:columns:stop}} + + \doif{\XMLpar{fo:simple-page-master-do}{fe:option}{}}{fit} + {\directsetup{fe:page:option:fit:stop}} + + % \XMLval{fo:page-end}{\XMLop{force-page-count}}{\page} \endgroup + + \ifnum\SavedPageNumber=\realpageno + + \ifdim\pagetotal<.5\textheight \null \vfill \fi % force a page with only containers + + \fi + + \XMLval{fo:page-end}{\XMLpar{fo:page-sequence}{force-page-count}{}}{\page} \endgroup + +\stopsetups + +\newdimen\FOcolumngap + +\startsetups fo:columns:start + + \FOcolumngap\textwidth + + \setpercentdimen\FOcolumngap{\XMLpar{fo:region-body}{column-gap}{12pt}} + + % we need to freeze the lineheight here + + \expanded{\definecolumnset + [fo:set] + [n=\XMLpar{fo:region-body}{column-count}{1}, + distance=\FOcolumngap]} + + \expanded{\definecolumnsetspan + [fo:set] + [n=\XMLpar{fo:region-body}{column-count}{1}]} + + \directsetup{fo:font:setup} % else problems + + \directsetup{fo:line-height:setup} + +% \parseXMLattributes{fo:flow}{line-height='normal'} + + \startcolumnset[fo:set] + + % \startcolumns[\XMLpar{fo:region-body}{column-count}{1}] + +\stopsetups + +\startsetups fo:columns:stop + + % \stopcolumns + + \stopcolumnset + +\stopsetups + +%D Element: fo:layout-master-set + +\defineXMLprocess + [fo:layout-master-set] + +%D Element: fo:page-sequence-master + +\defineXMLenvironmentsave + [fo:page-sequence-master] + [\XMLattributeset{fo:inherited}, + master-name=any] + {} + {%[saved page sequence master: \XMLop{master-name}]\endgraf + \gsaveXMLdatainelement + {fo:page-sequence-master:\XMLop{master-name}} + {fo:page-sequence-master-do} + {fo:page-sequence-master}} + +\defineXMLprocess + [fo:page-sequence-master-do] + [\XMLattributeset{fo:inherited}] + +%D Element: fo:single-page-master-reference + +% makeup - one page + +\defineXMLcommand + [fo:single-page-master-reference] + [master-reference=any] + {\flushXMLelement{fo:simple-page-master:\XMLop{master-reference}}} + +%D Element: fo:repeatable-page-master-reference + +\defineXMLcommand + [fo:repeatable-page-master-reference] + [master-reference=any, + maximum-repeats=] + {\flushXMLelement{fo:simple-page-master:\XMLop{master-reference}}} + +%D Element: fo:repeatable-page-master-alternatives + +\defineXMLprocess + [fo:repeatable-page-master-alternatives] + [maximum-repeats=] + +%D Element: fo:conditional-page-master-reference + +% page-position : first last rest any +% odd-or-even : odd even any +% blank-or-not-blank : blank not-blank + +% The page-position default is needed (else possible loops) + +\defineXMLcommand + [fo:conditional-page-master-reference] + [master-reference=any, + page-position=\XMLpar{fo:conditional-page-master-reference}{master-reference}{any}, + blank-or-not-blank=, + odd-or-even=] + {\flushXMLelement{fo:simple-page-master:\XMLpar{fo:conditional-page-master-reference}{master-reference}{}}} + +%D Element: fo:simple-page-master + +% first-page left-page right-page blank-page + +% default dimensions + +\defineXMLenvironmentsave + [fo:simple-page-master] + [master-name=any] + {} + {%[saved simple page master: \XMLop{master-name}]\endgraf + \gsaveXMLdatainelement + {fo:simple-page-master:\XMLop{master-name}} + {fo:simple-page-master-do} + {fo:simple-page-master}} + +% reference-orientation=0deg, +% writing-mode= + +\defineXMLenvironment + [fo:simple-page-master-do] + [\XMLattributeset{fo:inherited}, % added + \XMLattributeset{fo:margin-block}, + page-height=29.7cm, + page-width=21cm] + {\directsetup{fo:simple-page-master:start}} + {\directsetup{fo:simple-page-master:stop}} + +% not needed any more: + +\mapXMLvalue {fo:reference-orientation} {0deg} {0} +\mapXMLvalue {fo:reference-orientation} {90deg} {90} +\mapXMLvalue {fo:reference-orientation} {180deg} {180} +\mapXMLvalue {fo:reference-orientation} {270deg} {270} +\mapXMLvalue {fo:reference-orientation} {-90deg} {270} +\mapXMLvalue {fo:reference-orientation} {-180deg} {180} +\mapXMLvalue {fo:reference-orientation} {-270deg} {90} + +\startsetups fo:simple-page-master:start + + % nothing + +\stopsetups + +% can be low level tex + +\startsetups fo:simple-page-master:stop + + \writeFOstatus{defining papersize '\directsetup{fo:layout:kind}'} + + \expanded + {\definepapersize + [\directsetup{fo:layout:kind}] + [width=\XMLop{page-width}, + height=\XMLop{page-height}]} + + \checkFOpadding {fo:region-body} + \checkFOmargin {fo:region-body} + \checkFOmargin {fo:simple-page-master-do} + + \writeFOstatus{defining layout '\directsetup{fo:layout:kind}'} + + \FOscratchMT\paperheight \setpercentdimen\FOscratchMT{\XMLpar{fo:simple-page-master-do}{margin-top} \zeropoint} + \FOscratchMB\paperheight \setpercentdimen\FOscratchMB{\XMLpar{fo:simple-page-master-do}{margin-bottom}\zeropoint} + \FOscratchML\paperwidth \setpercentdimen\FOscratchML{\XMLpar{fo:simple-page-master-do}{margin-left} \zeropoint} + \FOscratchMR\paperwidth \setpercentdimen\FOscratchMR{\XMLpar{fo:simple-page-master-do}{margin-right} \zeropoint} + + \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-body}{margin-top} \zeropoint} + \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-body}{margin-bottom}\zeropoint} + \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-body}{margin-left} \zeropoint} + \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-body}{margin-right} \zeropoint} + + \FOscratchPB\paperheight \setpercentdimen\FOscratchPB{\XMLpar{fo:region-body}{padding-top} \zeropoint} + \FOscratchPA\paperheight \setpercentdimen\FOscratchPA{\XMLpar{fo:region-body}{padding-bottom}\zeropoint} + \FOscratchPS\paperwidth \setpercentdimen\FOscratchPS{\XMLpar{fo:region-body}{padding-left} \zeropoint} + \FOscratchPE\paperwidth \setpercentdimen\FOscratchPE{\XMLpar{fo:region-body}{padding-right} \zeropoint} + + \expanded + {\definelayout + [\directsetup{fo:layout:kind}] + [ page={\directsetup{fo:layout:kind},\XMLval{fo:reference-orientation}{\XMLop{reference-orientation}}{}}, + paper=\directsetup{fo:layout:kind}, + backspace=\the\dimexpr(\FOscratchML+\FOscratchPS+\FOscratchRS), + cutspace=\the\dimexpr(\FOscratchMR+\FOscratchPE+\FOscratchRE), + topspace=\the\dimexpr(\FOscratchMT+\FOscratchPB+\FOscratchRB), + bottomspace=\the\dimexpr(\FOscratchMB+\FOscratchPA+\FOscratchRA)]} + + \expanded{\setuplayout[\directsetup{fo:layout:kind}]} + + % this is a nasty bit of code: this local setup stores some data that + % needs to be used later + + \startexpanded + \noexpand \startlocalsetups[layout:\directsetup{fo:layout:kind}] + \noexpand \writeFOstatus{processing simple page master '\XMLpar{fo:simple-page-master-do}{master-name}{any}'} + \noexpand \resetsetups[fo:simple-page-master:start] + \noexpand \resetsetups[fo:simple-page-master:stop] + \noexpand \flushXMLelement{fo:simple-page-master:\XMLpar{fo:simple-page-master-do}{master-name}{any}} + \noexpand \stoplocalsetups + \stopexpanded + +\stopsetups + +% \defineXMLcommand[fo:simple-page-master-do-do] +% {\writeFOstatus{setting up master \XMLop{master-name} in page body}} + +%D Element: fo:region-body + +% display-align=, +% reference-orientation=, +% writing-mode=, + +\defineXMLcommand % or process + [fo:region-body] + [\XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + fe:z-order=above, + clip=, + column-count=1, + column-gap=12pt, + overflow=, + region-name=] + {\directsetup{fo:region-body:process}} + +\startsetups fo:region-body:process + \writeFOstatus{refreshing region-body parameters} +\stopsetups + +% todo: naar realfolio handelen ipv folio + +\mapXMLvalue {fo:odd-or-even} {odd} {odd} +\mapXMLvalue {fo:odd-or-even} {even} {even} + +\mapXMLvalue {fo:page-position} {any} {rest} % todo +\mapXMLvalue {fo:page-position} {first} {current} +\mapXMLvalue {fo:page-position} {last} {last} % todo +\mapXMLvalue {fo:page-position} {rest} {rest} % todo + +%mapXMLvalue {fo:blank-or-not-blank} {any} {} % todo +%mapXMLvalue {fo:blank-or-not-blank} {not-blank} {} % todo +%mapXMLvalue {fo:blank-or-not-blank} {blank} {} % todo + +% check this one esp default value + +\startsetups fo:layout:kind + + \XMLpav + {fo:odd-or-even} + {fo:conditional-page-master-reference} + {odd-or-even} + {\XMLpav + {fo:page-position} + {fo:conditional-page-master-reference} + {page-position} + {\XMLpar{fo:page-sequence-master}{master-reference}{any}}} + +\stopsetups + +% common border things + +% clip +% display-align +% extent +% overflow +% precedence +% region-name +% reference-orientation +% writing-mode + +%D Element: fo:region-before fo:region-after fo:region-start fo:region-end + +% border-before-color : | inherit +% border-before-style : | inherit +% border-before-width.length|conditional : | | inherit +% +% style: none hidden dotted dashed solid double groove ridge inset outset +% width: thin medium thick length + +\mapXMLvalue {fo:display-align} {auto} {before} % todo: related to relative-align +\mapXMLvalue {fo:display-align} {before} {high} +\mapXMLvalue {fo:display-align} {after} {low} +\mapXMLvalue {fo:display-align} {center} {lohi} + +% display-align=, +% reference-orientation=, +% writing-mode=, + +\defineXMLcommand % will become process when stable + [fo:region-before] + [\XMLattributeset{fo:border-padding-background}, + clip=, + extent=, + overflow=, + precedence=, + region-name=] + {\directsetup{fo:region-before:process}} + +\startsetups fo:region-before:process + \writeFOstatus{refreshing region-before parameters} +\stopsetups + +\defineXMLprocess + [fo:region-after] + [\XMLattributeset{fo:border-padding-background}, + clip=, + extent=, + overflow=, + precedence=, + region-name=] + +\defineXMLprocess + [fo:region-start] + [\XMLattributeset{fo:border-padding-background}, + clip=, + extent=, + overflow=, + region-name=] + +\defineXMLprocess + [fo:region-end] + [\XMLattributeset{fo:border-padding-background}, + clip=, + extent=, + overflow=, + region-name=] + +\mapXMLvalue {fo:border-style} {none} {0} +\mapXMLvalue {fo:border-style} {hidden} {1} +\mapXMLvalue {fo:border-style} {dotted} {2} +\mapXMLvalue {fo:border-style} {dashed} {3} +\mapXMLvalue {fo:border-style} {solid} {4} +\mapXMLvalue {fo:border-style} {double} {5} +\mapXMLvalue {fo:border-style} {groove} {6} +\mapXMLvalue {fo:border-style} {ridge} {7} +\mapXMLvalue {fo:border-style} {inset} {8} +\mapXMLvalue {fo:border-style} {outset} {9} + +\mapXMLvalue {fo:border-width} {thin} {.25pt} +\mapXMLvalue {fo:border-width} {medium} {.5pt} +\mapXMLvalue {fo:border-width} {thick} {1pt} + +\startsetups fo:regions:check + + \startprocesscommalist[body,before,after,start,end] + + \checkFOborder{fo:region-\currentcommalistitem}{bottom} + \checkFOborder{fo:region-\currentcommalistitem}{top} + \checkFOborder{fo:region-\currentcommalistitem}{left} + \checkFOborder{fo:region-\currentcommalistitem}{right} + + \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-bottom-color}{}] + \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-top-color}{}] + \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-left-color}{}] + \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-right-color}{}] + \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{background-color}{}] + + \checkFOposition{fo:region-\currentcommalistitem}{background} + \checkFOpadding {fo:region-\currentcommalistitem} + \checkFOmargin {fo:region-\currentcommalistitem} + + \stopprocesscommalist + +\stopsetups + +%D Element: fo:flow + +\defineXMLenvironment + [fo:flow] + [\XMLattributeset{fo:inherited}, + flow-name=unknown] + {\beginXMLelement\directsetup{fo:flow:start}} + {\directsetup{fo:flow:stop}\endXMLelement} + +\startsetups fo:flow:start + \begingroup +\stopsetups + +\startsetups fo:flow:stop + \endgroup +\stopsetups + +%D Element: fo:static-content + +% \beginXMLelement \endXMLelement - maybe save with attributes + +\defineXMLenvironmentsave + [fo:static-content] + [flow-name=unknown] + {} + {\directsetup{fo:static-content:process}} + +\startsetups fo:static-content:process + + \gsaveXMLdata{fo:static-content:\XMLop{flow-name}}{fo:static-content} + +\stopsetups + +\newdimen\FOscratchML \newdimen\FOscratchMR \newdimen\FOscratchMT \newdimen\FOscratchMB +\newdimen\FOscratchPB \newdimen\FOscratchPA \newdimen\FOscratchPS \newdimen\FOscratchPE +\newdimen\FOscratchRB \newdimen\FOscratchRA \newdimen\FOscratchRS \newdimen\FOscratchRE + +\mapXMLvalue {fo:background-repeat} {no-repeat} {0} +\mapXMLvalue {fo:background-repeat} {repeat} {1} +\mapXMLvalue {fo:background-repeat} {repeat-x} {2} +\mapXMLvalue {fo:background-repeat} {repeat-y} {3} + +\expanded {\mapXMLvalue {fo:background-location} {left} {0\letterpercent}} +\expanded {\mapXMLvalue {fo:background-location} {right} {100\letterpercent}} +\expanded {\mapXMLvalue {fo:background-location} {top} {0\letterpercent}} +\expanded {\mapXMLvalue {fo:background-location} {bottom} {100\letterpercent}} +\expanded {\mapXMLvalue {fo:background-location} {center} {50\letterpercent}} + +\newdimen\FObgpositionH +\newdimen\FObgpositionV + +\def\FObackgroundimage#1#2#3% + {\doifnot{\XMLpar{fo:#1}{background-image}{none}}{none} + {\setFOimagename{\XMLpar{fo:#1}{background-image}{dummy}}% + \FObgpositionH#2% + \setpercentdimen\FObgpositionH{\XMLpav + {fo:background-location} + {fo:#1} + {background-position-horizontal} + {\XMLpar{fo:#1}{background-position-horizontal}{}}}% + \ifpercentdimendone + \skip0\zeropoint plus \FObgpositionH + \skip2\zeropoint plus \dimexpr(#2-\FObgpositionH)% + \else + \skip0\FObgpositionH + \skip2\zeropoint plus 1fill\relax + \fi + \FObgpositionV#3% + \setpercentdimen\FObgpositionV{\XMLpav + {fo:background-location}{fo:#1}{background-position-vertical} + {\XMLpar{fo:#1}{background-position-vertical}{}}}% + \ifpercentdimendone + \skip4\zeropoint plus \FObgpositionV + \skip6\zeropoint plus \dimexpr(#3-\FObgpositionV)% + \else + \skip4\FObgpositionV + \skip6\zeropoint plus 1fill\relax + \fi + \vbox to #3 \bgroup + \vskip\skip4\relax + \hbox to #2 \bgroup + \hskip\skip0\relax + \backgroundimage + {\XMLpav{fo:background-repeat}{fo:#1}{background-repeat}{}}{#2}{#3}% + {\externalfigure + [\FOimagename] + [width=\XMLpar{fo:#1}{fe:background-width}{}, + height=\XMLpar{fo:#1}{fe:background-height}{}]}% + \hskip\skip2\relax + \egroup + \vskip\skip6\relax + \egroup}} + +\def\checkFOclipping#1% + {\doifsomething{\XMLpar{#1}{clip}{}} + {\analyzefunction{\XMLpar{#1}{clip}{}}% + \doif\functionname{rect} + {\def\postprocessframebox##1% + {\edef\next{\dimen0=\the\wd##1\dimen2=\the\ht##1\dimen4=\the\dp##1}% + \setbox##1\hbox + {\clip % expanded? + [topoffset=-\functionA, + bottomoffset=-\functionC, + leftoffset=-\functionD, + rightoffset=-\functionB] + {\box##1}}% + \next}}}} + +\def\clipFOarea#1% + {\doifsomething{\XMLpar{#1}{clip}{}}% + {\analyzefunction{\XMLpar{#1}{clip}{}}% + \doif\functionname{rect} + {\setbox\scratchbox\hbox{\foregroundbox}% + \edef\next{\dimen0=\the\wd\scratchbox\dimen2=\the\ht\scratchbox\dimen4=\the\dp\scratchbox}% + \setbox\scratchbox\hbox + {\clip % expanded? + [topoffset=-\functionA, + bottomoffset=-\functionC, + leftoffset=-\functionD, + rightoffset=-\functionB] + {\box\scratchbox}}% + \next + \box\scratchbox}}} + +\defineoverlay + [text] + [\clipFOarea{fo:region-body}] + +\setupbackgrounds + [text] + [background=text] + +\def\FOregionbuilder#1#2#3#4#5#6% #1=location #2=preset #3=x #4=y #5=width #6=height + {\writeFOstatus{building region #1}% + \defineoverlay + [image] + [{\framed + [frame=off, + orientation=\XMLpav{fo:reference-orientation}{fo:#1}{reference-orientation}{0}, + offset=overlay, + height=\overlayheight, + width=\overlaywidth] + {\FObackgroundimage{#1}\hsize\vsize}}]% + \setlayerframed + [regions] + [preset=#2,x=\dimexpr(#3),y=\dimexpr(#4)] + [frame=off, + offset=overlay,background={#1-graphic,image,xsl-#1}, + width=\dimexpr(#5),height=\dimexpr(#6)] + {\lrtbbox + {\XMLpar{fo:#1}{padding-left}\zeropoint}% + {\XMLpar{fo:#1}{padding-right}\zeropoint}% + {\XMLpar{fo:#1}{padding-top}\zeropoint}% + {\XMLpar{fo:#1}{padding-bottom}\zeropoint}% + {\checkFOclipping{fo:#1}% + \framed + [frame=off, + offset=overlay, + orientation=\XMLpav{fo:reference-orientation}{fo:#1}{reference-orientation}{0}, + align={\XMLpav{fo:display-align}{fo:#1}{display-align}{high},\XMLpav{fo:align-key}{fo:#1}{text-align}{normal}}, + width=\hsize,height=\vsize] + {\doFObeforeskip{fo:#1}% + \flushXMLelement{fo:static-content:\XMLpar{fo:#1}{region-name}{xsl-#1}}}% + \doFOafterskip{fo:#1}}}} + +\startsetups fo:regions:process + + \directsetup{fo:regions:check} + + \checkFOmargin{fo:simple-page-master-do} + + \FOscratchMT\paperheight \setpercentdimen\FOscratchMT{\XMLpar{fo:simple-page-master-do}{margin-top} \zeropoint} + \FOscratchMB\paperheight \setpercentdimen\FOscratchMB{\XMLpar{fo:simple-page-master-do}{margin-bottom}\zeropoint} + \FOscratchML\paperwidth \setpercentdimen\FOscratchML{\XMLpar{fo:simple-page-master-do}{margin-left} \zeropoint} + \FOscratchMR\paperwidth \setpercentdimen\FOscratchMR{\XMLpar{fo:simple-page-master-do}{margin-right} \zeropoint} + + \doif{\XMLpar{fo:region-body}{fe:z-order}{above}}{below}{\directsetup{fo:regions:process:body}} + + \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-before}{extent}\zeropoint} + \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-after} {extent}\zeropoint} + \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-start} {extent}\zeropoint} + \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-end} {extent}\zeropoint} + + \doifelse{\XMLpar{fo:region-before}{precedence}{false}}{true} + {\doifelse{\XMLpar{fo:region-after}{precedence}{false}}{true} + {\directsetup{fo:regions:process:true:true}} + {\directsetup{fo:regions:process:true:false}}} + {\doifelse{\XMLpar{fo:region-after}{precedence}{false}}{true} + {\directsetup{fo:regions:process:false:true}} + {\directsetup{fo:regions:process:false:false}}} + + \doif{\XMLpar{fo:region-body}{fe:z-order}{above}}{above}{\directsetup{fo:regions:process:body}} + +\stopsetups + +\newdimen\FOscratchEB +\newdimen\FOscratchEA + +\chardef\FOregionmode\zerocount + +\startmode[fo-pt] + \chardef\FOregionmode\plusone % fotex mode -) +\stopmode + +\startsetups fo:regions:modes + + \ifcase\FOregionmode + \FOscratchEB\zeropoint + \FOscratchEA\zeropoint + \or + \FOscratchEB\paperheight \setpercentdimen\FOscratchEB{\XMLpar{fo:region-before}{extent}\zeropoint} + \FOscratchEA\paperheight \setpercentdimen\FOscratchEA{\XMLpar{fo:region-after} {extent}\zeropoint} + \else + \FOscratchEB\zeropoint + \FOscratchEA\zeropoint + \fi + +\stopsetups + +\startsetups fo:regions:process:body + + \bgroup + + \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-body}{margin-top} \zeropoint} + \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-body}{margin-bottom}\zeropoint} + \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-body}{margin-left} \zeropoint} + \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-body}{margin-right} \zeropoint} + + \FOregionbuilder + {region-body} + {lefttop} + {\FOscratchML+\FOscratchRS} + {\FOscratchMT+\FOscratchRA} + {\paperwidth -\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE} + {\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB-\FOscratchRA} + + \egroup + +\stopsetups + +\startsetups fo:regions:process:true:true + + \directsetup{fo:regions:modes} + + \ifdim\FOscratchRB>\zeropoint \FOregionbuilder + {region-before}{lefttop} + {\FOscratchML}{\FOscratchMT-\FOscratchEB} + {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRB} + \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder + {region-after}{leftbottom} + {\FOscratchML}{\FOscratchMB-\FOscratchEA} + {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRA} + \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder + {region-start}{lefttop} + {\FOscratchML}{\FOscratchMT+\FOscratchRB} + {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRA-\FOscratchRB} + \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder + {region-end}{righttop} + {\FOscratchMR}{\FOscratchMT+\FOscratchRA} + {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRA-\FOscratchRB} + \fi + +\stopsetups + +\startsetups fo:regions:process:false:true + + \directsetup{fo:regions:modes} + + \ifdim\FOscratchRB>\zeropoint \FOregionbuilder + {region-before}{lefttop} + {\FOscratchML+\FOscratchRS}{\FOscratchMT-\FOscratchEB} + {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRB} + \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder + {region-after}{leftbottom} + {\FOscratchML}{\FOscratchMB-\FOscratchEA} + {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRA} + \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder + {region-start}{lefttop} + {\FOscratchML}{\FOscratchMT} + {\FOscratchRS}{\paperheight-\FOscratchMB-\FOscratchRA-\FOscratchRB} + \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder + {region-end}{righttop} + {\FOscratchMR}{\FOscratchMT} + {\FOscratchRE}{\paperheight-\FOscratchMB-\FOscratchRA-\FOscratchRB} + \fi + +\stopsetups + +\startsetups fo:regions:process:true:false + + \directsetup{fo:regions:modes} + + \ifdim\FOscratchRB>\zeropoint \FOregionbuilder + {region-before}{lefttop} + {\FOscratchML}{\FOscratchMT-\FOscratchEB} + {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRB} + \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder + {region-after}{leftbottom} + {\FOscratchML+\FOscratchRS}{\FOscratchMB-\FOscratchEA} + {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRA} + \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder + {region-start}{lefttop} + {\FOscratchML}{\FOscratchMT+\FOscratchRB} + {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB} + \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder + {region-end}{righttop} + {\FOscratchMR}{\FOscratchMT+\FOscratchRA} + {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB} + \fi + +\stopsetups + +\startsetups fo:regions:process:false:false + + \directsetup{fo:regions:modes} + + \ifdim\FOscratchRB>\zeropoint \FOregionbuilder + {region-before}{lefttop} + {\FOscratchML+\FOscratchRS}{\FOscratchMT-\FOscratchEB} + {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRB} + \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder + {region-after}{leftbottom} + {\FOscratchML+\FOscratchRS}{\FOscratchMB-\FOscratchEA} + {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRA} + \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder + {region-start}{lefttop} + {\FOscratchML}{\FOscratchMT} + {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB} + \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder + {region-end}{righttop} + {\FOscratchMR}{\FOscratchMT} + {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB} + \fi + +\stopsetups + +\startsetups fo:before:each:page + + \writeFOstatus{setting up layout \currentlayout} + \directsetup{layout:\currentlayout} + \directsetup{fo:regions:process} + +\stopsetups + +\prependtoks + \directsetup{fo:before:each:page}% +\to \everybeforepagebody + +%D Element: fo:title + +% \XMLattributeset{fo:aural}, +% color=, +% line-height=, + +\defineXMLignore + [fo:title] + [\XMLattributeset{fo:inherited},\XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:margin-inline}, + visibility=] + +%D Element: fo:block + +\defineXMLenvironment + [fo:block] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:hyphenation}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:relative-position}, + \XMLattributeset{fo:keeps-and-breaks}, +% text-depth=, +% text-altitude=, + span=, + visibility=] + {\beginXMLelement\directsetup{fo:block:start}} + {\directsetup{fo:block:stop}\endXMLelement} + +\startsetups fo:block:start + + \endgraf + + \writeFOstatus{fo:block in line \the\inputlineno} + +\doif{\XMLpar{fo:block}{span}{}}{all}{\ifinsidecolumns \startcolumnsetspan[fo:set] \fi} + + \begingroup + + \directsetup{fe:setup} + + \directsetup{fo:break-and-space:before} + + \begingroup + + \setFOreference{fo:block} + + \increment\FOblocklevel + + \directsetup{fo:font:setup} + + % \setupinterlinespace % no, interferes with columnset and lineheight + + \directsetup{fo:line-height:setup} + + \directsetup{fo:indent:setup}% hier ? + + \doifsomething{\XMLop{background-color}} + {\checkhexcolor[\XMLop{background-color}] + \doifcolorelse{\XMLop{background-color}} + \donothing + {\setXMLpar{fo:block}{background-color}{}}} + + \doifsomething{\XMLop{color}} + {\checkhexcolor[\XMLop{color}] + \doifcolorelse{\XMLop{color}} + \donothing + {\setXMLpar{fo:block}{color}{}}} + + \doifsomething{\XMLop{background-color}} + {\expanded + {\definetextbackground + [FOattribute-\FOblocklevel] + [location=paragraph, + color=\XMLop{color}, + style=, + before=, + after=, + background=color, + backgroundcolor=\XMLop{background-color}]}} + + \endgraf + + \getvalue{startFOattribute-\FOblocklevel} + + \directsetup{fo:hyphenation:setup} + \directsetup{fo:align:setup} + \directsetup{fo:margin:setup} + + \doif{\XMLop{wrap-option}}{no-wrap} + {\obeylines} + + \doif{\XMLop{white-space-collapse}}{false} + {\obeyspaces} + + % todo : remember old one and do like fonts + + \directsetup{fo:textindent:setup} + +\stopsetups + +\startsetups fo:block:stop + + \endstrut \endgraf + + \getvalue{stopFOattribute-\FOblocklevel} + + \endgraf + + \endgroup + + \directsetup{fo:break-and-space:after} + + \endgroup + + \doif{\XMLpar{fo:block}{span}{}}{all}{\ifinsidecolumns \stopcolumnsetspan \fi} + +\stopsetups + +\startsetups fo:textindent:setup + + \edefXMLinh\xFOtextindent{text-indent} + + \doifsomething\xFOtextindent + {\scratchdimen\hsize + \setpercentdimen\scratchdimen\xFOtextindent + \expanded{\setupindenting[\the\scratchdimen]}} + +\stopsetups + +\indenting[always] % can be zero points + +% todo: map + +\mapXMLvalue {fo:break} {column} {\column} +\mapXMLvalue {fo:break} {page} {\page} +\mapXMLvalue {fo:break} {even-page} {\page[even]} +\mapXMLvalue {fo:break} {odd-page} {\page[odd]} + +% keep-together : either vbox or something \interlinepenalty\maxdimen ? +% +% nasty interference with accumulated skips + +\mapXMLvalue {fo:keep-next} {auto} {} +\mapXMLvalue {fo:keep-next} {always} {\nobreak} + +\mapXMLvalue {fo:keep-prev} {auto} {} +\mapXMLvalue {fo:keep-prev} {always} {\nobreak} + +\mapXMLvalue {fo:keep-start} {auto} {} +\mapXMLvalue {fo:keep-start} {always} {\interlinepenalty\maxdimen} + +\mapXMLvalue {fo:keep-stop} {auto} {} +\mapXMLvalue {fo:keep-stop} {always} {} + +\newskip\FOsavedlastskip + +\startsetups fo:break-and-space:before + + \XMLval{fo:break}{\XMLop{break-before}}{} + + \FOsavedlastskip \lastskip \ifdim\FOsavedlastskip>\zeropoint \vskip-\FOsavedlastskip \fi + + \XMLval{fo:keep-start}{\XMLop{keep-together}}\empty + \XMLval{fo:keep-start}{\XMLop{keep-together.within-column}}\empty + \XMLval{fo:keep-start}{\XMLop{keep-together.within-page}}\empty + + \XMLval{fo:keep-prev} {\XMLop{keep-with-previous}}\empty + \XMLval{fo:keep-prev} {\XMLop{keep-with-previous.within-column}}\empty + \XMLval{fo:keep-prev} {\XMLop{keep-with-previous.within-page}}\empty + + \ifdim\FOsavedlastskip>\zeropoint \vskip\FOsavedlastskip \fi + + \doFObeforeskip\currentXMLelement + +\stopsetups + +\startsetups fo:break-and-space:after + +% \doFOafterskip\currentXMLelement + + \FOsavedlastskip \lastskip \ifdim\FOsavedlastskip>\zeropoint \vskip-\FOsavedlastskip \fi + + \XMLval{fo:keep-stop}{\XMLop{keep-together}}\empty + \XMLval{fo:keep-stop}{\XMLop{keep-together.within-column}}\empty + \XMLval{fo:keep-stop}{\XMLop{keep-together.within-page}}\empty + + \XMLval{fo:keep-next}{\XMLop{keep-with-next}}\empty + \XMLval{fo:keep-next}{\XMLop{keep-with-next.within-column}}\empty + \XMLval{fo:keep-next}{\XMLop{keep-with-next.within-page}}\empty + + \ifdim\FOsavedlastskip>\zeropoint \vskip\FOsavedlastskip \fi + + \doFOafterskip\currentXMLelement + + \XMLval{fo:break}{\XMLop{break-after}}{} + +\stopsetups + +\startsetups fo:space:start + \doFOstartspace\currentXMLelement +\stopsetups + +\startsetups fo:space:end + \doFOendspace\currentXMLelement +\stopsetups + +\startsetups fo:indent:setup + + \doifsomething{\XMLop{start-indent}}{\advance\leftskip \XMLop{start-indent}\relax} + \doifsomething{\XMLop{end-indent}} {\advance\rightskip\XMLop{end-indent} \relax} + +% \FOattributeT +% \FOattributeR +% \FOattributeB +% \FOattributeL + + +\stopsetups + +\mapXMLvalue {fo:align} {center} {\raggedcenter} +\mapXMLvalue {fo:align} {left} {\raggedright} +\mapXMLvalue {fo:align} {right} {\raggedleft} +\mapXMLvalue {fo:align} {begin} {\raggedright} +\mapXMLvalue {fo:align} {start} {\raggedright} +\mapXMLvalue {fo:align} {end} {\raggedleft} + +\mapXMLvalue {fo:align-key} {center} {middle} +\mapXMLvalue {fo:align-key} {left} {flushleft} +\mapXMLvalue {fo:align-key} {right} {flushright} +\mapXMLvalue {fo:align-key} {begin} {flushleft} +\mapXMLvalue {fo:align-key} {start} {flushleft} +\mapXMLvalue {fo:align-key} {end} {flushright} + +\startsetups fo:align:setup + + \XMLval{fo:align}{\XMLop{text-align}}{} + +\stopsetups + +\startsetups fo:margin:setup + + \checkFOmargin{fo:block} + + \FOscratchML \XMLpar{fo:block}{margin-left} \zeropoint + \FOscratchMR \XMLpar{fo:block}{margin-right} \zeropoint + \FOscratchMT \XMLpar{fo:block}{margin-top} \zeropoint + \FOscratchMB \XMLpar{fo:block}{margin-bottom}\zeropoint + + \advance\leftskip \FOscratchML + \advance\rightskip\FOscratchMR + +\stopsetups + +% todo: font-stretch +% +% ultra-condensed +% extra-condensed +% condensed +% semi-condensed +% expanded +% extra-expanded +% ultra-expanded +% +% wider narrower + +\mapXMLvalue {fo:font-size} {xx-small} {\dFOfontsize0.58\dFOfontsize} +\mapXMLvalue {fo:font-size} {x-small} {\dFOfontsize0.69\dFOfontsize} +\mapXMLvalue {fo:font-size} {small} {\dFOfontsize0.83\dFOfontsize} +\mapXMLvalue {fo:font-size} {medium} {\relax} +\mapXMLvalue {fo:font-size} {large} {\dFOfontsize1.20\dFOfontsize} +\mapXMLvalue {fo:font-size} {x-large} {\dFOfontsize1.44\dFOfontsize} +\mapXMLvalue {fo:font-size} {xx-large} {\dFOfontsize1.73\dFOfontsize} + +\mapXMLvalue {fo:font-size} {smaller} {\dFOfontsize0.83\dFOfontsize} +\mapXMLvalue {fo:font-size} {larger} {\dFOfontsize1.20\dFOfontsize} + +\newdimen\dFOfontsize + +% evt class Times Helvetica + +\definefontsynonym [FO:Times] [Times-Roman] +\definefontsynonym [FO:Times:bold] [Times-Bold] +\definefontsynonym [FO:Times:italic] [Times-Italic] +\definefontsynonym [FO:Times:bold:italic] [Times-BoldItalic] + +\definefontsynonym [FO:Times:small-caps] [Times-Roman] +\definefontsynonym [FO:Times:bold:small-caps] [Times-Bold] +\definefontsynonym [FO:Times:italic:small-caps] [Times-Italic] +\definefontsynonym [FO:Times:bold:italic:small-caps] [Times-BoldItalic] + +\definefontsynonym [FO:Helvetica] [Helvetica] +\definefontsynonym [FO:Helvetica:bold] [Helvetica-Bold] +\definefontsynonym [FO:Helvetica:italic] [Helvetica-Italic] +\definefontsynonym [FO:Helvetica:bold:italic] [Helvetica-BoldItalic] + +\definefontsynonym [FO:Helvetica:small-caps] [Helvetica] +\definefontsynonym [FO:Helvetica:bold:small-caps] [Helvetica-Bold] +\definefontsynonym [FO:Helvetica:italic:small-caps] [Helvetica-Italic] +\definefontsynonym [FO:Helvetica:bold:italic:small-caps] [Helvetica-BoldItalic] + +\definefontsynonym [FO:Courier] [Courier] +\definefontsynonym [FO:Courier:bold] [Courier-Bold] +\definefontsynonym [FO:Courier:italic] [Courier-Oblique] +\definefontsynonym [FO:Courier:bold:italic] [Courier-BoldOblique] + +\definefontsynonym [FO:Courier:small-caps] [Courier] +\definefontsynonym [FO:Courier:bold:small-caps] [Courier-Bold] +\definefontsynonym [FO:Courier:italic:small-caps] [Courier-Oblique] +\definefontsynonym [FO:Courier:bold:italic:small-caps] [Courier-BoldOblique] + +\definefontsynonym [FO:Symbol] [ZapfDingbats] + +\definefontsynonym [FO:Computer-Modern-Typewriter] [ComputerModernMono] +\definefontsynonym [FO:Computer-Modern-Typewriter:italic] [ComputerModernMono-Slanted] + +\definefontsynonym [*Times Roman*] [Times] + +% nasty: no FO prefix + +\definefontsynonym [*serif*] [Times] +\definefontsynonym [*sans-serif*] [Helvetica] +\definefontsynonym [*monospace*] [Courier] + +\definefontsynonym [*cursive*] [Times] +\definefontsynonym [*fantasy*] [Helvetica] + +\definefontsynonym [*Arial*] [Helvetica] +\definefontsynonym [*Times Roman*] [Times] +\definefontsynonym [*Wingdings*] [ZapfDingbats] + +% \definefontsynonym [Computer-Modern-Typewriter] [ComputerModernMono] +% \definefontsynonym [monospace] [ComputerModernMono] + +\startsetups fo:fonts:reset + + \dFOfontsize=\bodyfontsize + + \def\FOfontsize {10pt}% {12pt} + \def\FOfontfamily {Times} + \def\FOfontweight {normal} + \def\FOfontstyle {normal} + \def\FOfontvariant {normal} + \def\FOfontsizeadjust{1} + + \def\FOtextdepth {} + \def\FOtextaltitude {} + \def\FOlineheight {} + + \def\FOfontdefinition{} + \def\FOfontname {} + +\stopsetups + +\def\FOfontdefinition{} +\def\FOfontname {} + +\directsetup{fo:fonts:reset} + +% test for \FOfontvariant: normal or else + +\def\setFOfontname + {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight:\FOfontstyle:\FOfontvariant}% + %\begingroup\infofont\xFOfontname]\endgroup + \doifelsefontsynonym\xFOfontname + {\let\FOfontname\xFOfontname} + {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight:\FOfontstyle}% + \doifelsefontsynonym\xFOfontname + {\let\FOfontname\xFOfontname} + {\edef\xFOfontname{FO:\FOfontfamily:\FOfontstyle}% + \doifelsefontsynonym\xFOfontname + {\let\FOfontname\xFOfontname} + {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight}% + \doifelsefontsynonym\xFOfontname + {\let\FOfontname\xFOfontname} + {\edef\xFOfontname{FO:\FOfontfamily}% + \doifelsefontsynonym\xFOfontname + {\let\FOfontname\xFOfontname} + {}}}}}} + +% \unprotected \def\doifelseFOfontsynonym#1#2#3#4#5% family weight style variant default +% {\edef\FOfontname +% {\ifcsname \??ff\fontclass FO:#1:#2:#3:#4\endcsname FO:#1:#2:#3:#4% +% \else\ifcsname\??ff\fontclass FO:#1:#2:#3\endcsname FO:#1:#2:#3% +% \else\ifcsname\??ff\fontclass FO:#1:#3\endcsname FO:#1:#3% +% \else\ifcsname\??ff\fontclass FO:#1:#2\endcsname FO:#1:#2% +% \else\ifcsname\??ff\fontclass FO:#1\endcsname FO:#1% +% \else #5% +% \fi\fi\fi\fi\fi}} + +\startsetups fo:font:family:check + + \doifelsefontsynonym{*\FOfontfamily*} + {\expandfontsynonym\FOfontfamily{*\FOfontfamily*}} + {} + +\stopsetups + +\let\FOfont\empty + +\startsetups fo:font:setup + + % todo: optimize, define fonts first time and do that global + + \edefXMLinh\xFOfont {font} + \edefXMLinh\xFOfontsize {font-size} + \edefXMLinh\xFOfontsizeadjust{font-size-adjust} + \edefXMLinh\xFOfontfamily {font-family} + \edefXMLinh\xFOfontweight {font-weight} + \edefXMLinh\xFOfontstyle {font-style} + \edefXMLinh\xFOfontvariant {font-variant} + +% \edef\xFOfont {\XMLpar{fo}{font}{}} +% \edef\xFOfontsize {\XMLpar{fo}{font-size}{}} +% \edef\xFOfontsizeadjust{\XMLpar{fo}{font-size-adjust}{}} +% \edef\xFOfontfamily {\XMLpar{fo}{font-family}{}} +% \edef\xFOfontweight {\XMLpar{fo}{font-weight}{}} +% \edef\xFOfontstyle {\XMLpar{fo}{font-style}{}} +% \edef\xFOfontvariant {\XMLpar{fo}{font-variant}{}} + + \donefalse + + \ifx\xFOfont\empty \else \ifx\xFOfont\relax \else + \let\FOfont\xFOfont + \checkFOfont\FOfont + \fi \fi + + \ifx\xFOfontsize\empty \else \ifx\xFOfontsize\FOfontsize \else + \let\FOfontsize\xFOfontsize + \doifXMLvalelse{fo:font-size}\FOfontsize + {\XMLval{fo:font-size}\FOfontsize\empty} + {\setpercentdimen\dFOfontsize\FOfontsize} + \fi \fi + + \ifx\xFOfontsizeadjust\empty \else + \doifelse\xFOfontsizeadjust{none} + {\def\FOfontsizeadjust{1}} + {\let\FOfontsizeadjust\xFOfontsizeadjust} + \fi + + \ifx\xFOfontfamily\empty \else \ifx\xFOfontfamily\FOfontfamily \else + \donetrue \let\FOfontfamily\xFOfontfamily \directsetup{fo:font:family:check} + \fi \fi + \ifx\xFOfontweight\empty \else \ifx\xFOfontweight\FOfontweight \else + \donetrue \let\FOfontweight\xFOfontweight + \fi \fi + \ifx\xFOfontstyle\empty \else \ifx\xFOfontstyle\FOfontstyle \else + \donetrue \let\FOfontstyle\xFOfontstyle + \fi \fi + \ifx\xFOfontvariant\empty \else \ifx\xFOfontvariant\FOfontvariant \else + \donetrue \let\FOfontvariant\xFOfontvariant + \fi \fi + + \ifdone + \setFOfontname + \ifx\FOfontname\empty % klopt dit + \edef\xFOfontdefinition{\purefontname{\font} at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} +% \let\xFOfontdefinition\empty + \else + \edef\xFOfontdefinition{\FOfontname\space at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} + \fi + \else + \edef\xFOfontdefinition{\purefontname{\font} at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} + \fi + + \ifx\xFOfontdefinition\empty \else + \ifx\FOfontdefinition\xFOfontdefinition + \else + \let\FOfontdefinition\xFOfontdefinition + \expanded{\definedfont[\FOfontdefinition]} + \fi + \fi + +\stopsetups + +\newdimen\dFOlineheight +\newdimen\dFOdepth +\newdimen\dFOaltitude + +\let\FOlineheight \empty +\let\FOtextdepth \empty +\let\FOtextaltitude\empty + +\startsetups fo:line-height:setup + + \edefXMLinh\xFOtextdepth {text-depth} + \edefXMLinh\xFOtextaltitude{text-altitude} + \edefXMLinh\xFOlineheight {line-height} + +% \edef\xFOtextdepth {\XMLpar{fo}{text-depth}{}} +% \edef\xFOtextaltitude{\XMLpar{fo}{text-altitude}{}} +% \edef\xFOlineheight {\XMLpar{fo}{line-height}{}} + + \ifx\xFOtextdepth\empty \else \ifx\xFOtextdepth\FOtextdepth \else + \let\FOtextdepth\xFOtextdepth + \doifnot\FOtextdepth{use-font-metrics} + {\setstrut \dFOdepth\strutdepth + \setpercentdimen\dFOdepth\FOtextdepth + \setupinterlinespace[mindepth=\dFOdepth]} + \fi \fi + + \ifx\xFOtextaltitude\empty \else \ifx\xFOtextaltitude\FOtextaltitude \else + \let\FOtextaltitude\xFOtextaltitude + \doifnot\FOtextaltitude{use-font-metrics} + {\setstrut \dFOaltitude\strutheight \advance\dFOaltitude\strutdepth + \setpercentdimen\dFOaltitude\FOtextaltitude + \setupinterlinespace[minheight=\dFOaltitude]} + \fi \fi + +\ifinsidecolumns \else + + \ifx\xFOlineheight\empty \else \ifx\xFOlineheight\FOlineheight \else + \let\FOlineheight\xFOlineheight + \doifelse\FOlineheight{normal} + {\dFOlineheight2.8ex + \setupinterlinespace[line=\dFOlineheight]} + {\doifnot\FOlineheight{use-font-metrics} + {\setstrut \dFOlineheight\strutheight \advance\dFOlineheight\strutdepth + \setpercentdimen\dFOlineheight\FOlineheight + \setupinterlinespace[line=\dFOlineheight]}} + \fi \fi + +\fi + +\stopsetups + +\let\orphanpenalty \clubpenalty +\let\orphanpenalties\clubpenalties + +\newcount\FOwidows \FOwidows =2 +\newcount\FOorphans \FOorphans=2 + +\mapXMLvalue {fo:hyphens} {false} {\nohyphens} +\mapXMLvalue {fo:hyphens} {true} {\dohyphens} + +\startsetups fo:hyphenation:setup + + \edefXMLinh\xFOhyphenate {hyphenate} + \edefXMLinh\xFOwidows {widows} + \edefXMLinh\xFOorphans {orphans} + +% \edef\xFOhyphenate {\XMLpar{fo}{hyphenate}{}} +% \edef\xFOwidows {\XMLpar{fo}{widows}{}} +% \edef\xFOorphans {\XMLpar{fo}{orphans}{}} + + \ifx\xFOhyphenate\empty \else + \XMLval{fo:hyphens}{\xFOhyphenate}\empty + \fi + \ifx\xFOwidows\empty \else \ifnum\xFOwidows=\FOwidows \else + \FOwidows\xFOwidows \setpenalties\widowpenalties\FOwidows\maxdimen + \fi \fi + \ifx\xFOorphans\empty \else \ifnum\xFOorphans=\FOorphans \else + \FOorphans\xFOorphans \setpenalties\clubpenalties\FOorphans\maxdimen + \fi \fi + + % hyphenation-character + +\stopsetups + +%D fo:block-container + +% todo: potential optimization: set fonts and spacing at container level + +% display-align=, +% intrusion-displace=, +% reference-orientation=, +% writing-mode=, + +\defineXMLenvironment + [fo:block-container] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:absolute-positioning}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:keeps-and-breaks}, + block-progression-dimension=, + inline-progression-dimension=, + clip=, + height=, + overflow=, + span=, + width=, + z-index=] + {\beginXMLelement\directsetup{fo:block-container:start}} + {\directsetup{fo:block-container:stop}\endXMLelement} + +\mapXMLvalue {fo:block-container:start} {absolute} {\directsetup{fo:block-container:start:pos}} +\mapXMLvalue {fo:block-container:start} {fixed} {\directsetup{fo:block-container:start:pos}} + +\mapXMLvalue {fo:block-container:stop} {absolute} {\directsetup{fo:block-container:stop:pos}} +\mapXMLvalue {fo:block-container:stop} {fixed} {\directsetup{fo:block-container:stop:pos}} + +\startsetups fo:block-container:start + + \XMLval{fo:block-container:start}{\XMLpar{fo:block-container}{absolute-position}{}}{} + + \setFOreference{fo:block-container} + +\stopsetups + +\startsetups fo:block-container:stop + + \XMLval{fo:block-container:stop}{\XMLpar{fo:block-container}{absolute-position}{}}{} + +\stopsetups + +% i need to figure out the details (specs are a bit fuzzy) + +% replaced, see position + +\newdimen\FOcontainerW \newdimen\FOcontainerX \newdimen\FOcontainerL \newdimen\FOcontainerR \newdimen\FOcontainerWW +\newdimen\FOcontainerH \newdimen\FOcontainerY \newdimen\FOcontainerT \newdimen\FOcontainerB \newdimen\FOcontainerHH + +\startsetups fo:block-container:start:pos + + % todo: textwidth -> region dimensions + + \begingroup % \forgetall + + \FOcontainerWW\textwidth + \FOcontainerHH\textheight + \def\FOlayername{\XMLpar{fo:flow}{flow-name}{xsl-region-body}} + + \iftracingFO \tracelayerstrue \fi + + \directsetup{fo:preset:layer} + + \setlayerframed + [\XMLpar{fo:flow}{flow-name}{xsl-region-body}] + [frame=off, + width=\FOcontainerW, + height=\FOcontainerH] + + \bgroup + +\stopsetups + +\startsetups fo:block-container:stop:pos + + \egroup + + \endgroup + +\stopsetups + +%D fo:bidi-override + +% \XMLattributeset{aural}, +% color=, +% direction=, +% letter-spacing=, +% line-height=, +% word-spacing=, + +\defineXMLenvironment + [fo:bidi-override] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:relative-position}, + score-spaces=, + unicode-bidi=] + {\beginXMLelement} + {\endXMLelement} + +% todo + +%D fo:character + +% \XMLattributeset{fo:aural}, +% color=, +% glyph-orientation-horizontal=, +% glyph-orientation-vertical=, +% line-height=, + +\defineXMLsingular + [fo:character] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:hyphenation}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + \XMLattributeset{fo:character}, + alignment-adjust=, + baseline-shift=, + dominant-baseline=, +% text-depth=, +% text-altitude=, + keep-with-next=, + keep-with-previous=, + score-spaces=, + visibility=] + {\directsetup{fo:character:process}} + +\mapXMLvalue {fo:vertical-align} {baseline} {\hbox} +\mapXMLvalue {fo:vertical-align} {sub} {\low} +\mapXMLvalue {fo:vertical-align} {super} {\high} +\mapXMLvalue {fo:vertical-align} {inherit} {\firstofoneargument} + +\startsetups fo:character:process + + % border + % font + % margin + % positioning + % baseline + % color + % depth and altitude + % keep-with + % lineheight + + \dontleavehmode \begingroup + + \directsetup{fe:setup} + \directsetup{fo:font:setup} + + \iftracingFO \ruledhbox \else \hbox \fi \bgroup + + \doifsomethingXMLop{vertical-align} + {\doifXMLvalelse{fo:vertical-align}{\XMLop{vertical-align}} + {\XMLval{fo:vertical-align}{\XMLop{vertical-align}}{}} + {\wordshiftamount\lineheight + \setpercentdimen\wordshiftamount{\XMLop{vertical-align}} + \shiftedword}} + + {\directsetup{fo:character:orient}} + + \egroup \endgroup + +\stopsetups + +\startsetups fo:character:orient + +% \rotate[rotation=-\XMLop{glyph-orientation-horizontal}] + + \doifsomethingXMLop{glyph-orientation-horizontal} + {\rotate[rotation=\XMLval{fo:reference-orientation}{\XMLop{glyph-orientation-horizontal}}{0}]} + {\XMLop{character}} + +\stopsetups + +%D fo:initial-property-set + +% \XMLattributeset{fo:aural}, +% color=, +% letter-spacing=, +% line-height=, +% text-transform=, +% word-spacing=, + +\defineXMLprocess + [fo:initial-property-set] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:relative-position}, + score-spaces=, + text-decoration=, + text-shadow=] + +%D fo:external-graphic + +\useMPlibrary[dum] + +% \XMLattributeset{fo:aural}, +% display-align=, +% height=, +% text-align=, + +\defineXMLenvironmentsave + [fo:external-graphic] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + block-progression-dimension=, + clip=, + content-height=, + content-type=, + content-width=, + dominant-baseline=, + height=, + inline-progression-dimension=, + keep-with-next=, + keep-with-previous=, + overflow=, + scaling=, + scaling-method=, + src=dummy, + width=] + {} + {\directsetup{fo:external-graphic:process}} + +\newdimen\FOgraphicwidth +\newdimen\FOgraphicheight + +\mapXMLvalue {external-graphic:align} {top} {\tbox} +\mapXMLvalue {external-graphic:align} {bottom} {\bbox} +\mapXMLvalue {external-graphic:align} {center} {\cbox} + +\startsetups fo:external-graphic:process + + \doifelsenothing{\XMLop{content-height}} + {\FOgraphicheight\zeropoint} + {\doifelse{\XMLop{content-height}}{scale-to-fit}% is this official ? + {\FOgraphicwidth\zeropoint} + {\doifelse{\XMLop{content-height}}{auto} + {\FOgraphicheight\zeropoint} + {\FOgraphicheight\lineheight + \setpercentdimen\FOgraphicheight{\XMLop{content-height}}}}} + + \doifelsenothing{\XMLop{content-width}} + {\FOgraphicwidth\zeropoint} + {\doifelse{\XMLop{content-width}}{scale-to-fit}% is this official ? + {\FOgraphicwidth\zeropoint} + {\doifelse{\XMLop{content-width}}{auto} + {\FOgraphicwidth\zeropoint} + {\FOgraphicwidth1em + \setpercentdimen\FOgraphicwidth {\XMLop{content-width}}}}} + + % leeg maken vars gaat ook goed, dan een \externalfigure + + % todo : height/width scale-to-fit: factor=... + + \setbox\scratchbox\hbox + {\setFOimagename{\XMLpar{fo:external-graphic}{src}{dummy}} + \ifdim\FOgraphicheight>\zeropoint + \ifdim\FOgraphicwidth>\zeropoint + \externalfigure[\FOimagename][height=\FOgraphicheight,width=\FOgraphicwidth] + \else + \externalfigure[\FOimagename][height=\FOgraphicheight] + \fi + \else + \ifdim\FOgraphicwidth>\zeropoint + \externalfigure[\FOimagename][width=\FOgraphicwidth] + \else + \externalfigure[\FOimagename] + \fi + \fi} + + \dontleavehmode \XMLval{external-graphic:align}{\XMLop{vertical-align}}{}{\box\scratchbox} + +\stopsetups + +%D fo:instream-foreign-object + +% like external-graphic, only no src + +% \XMLattributeset{fo:aural}, +% display-align=, +% line-height=, +% text-align=, + +\defineXMLprocess + [fo:instream-foreign-object] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + block-progression-dimension=, + clip=, + content-height=, + content-type=, + content-width=, + dominant-baseline=, + height=, + inline-progression-dimension=, + keep-with-next=, + keep-with-previous=, + overflow=, + scaling=, + scaling-method=, + width=] + +%D Element: fo:inline + +% \XMLattributeset{fo:aural}, +% line-height=, +% wrap-option=, +% color=, +% keep-together=, + +\defineXMLnestedenvironmentsave + [fo:inline] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + block-progression-dimension=, + dominant-baseline=, + height=, + inline-progression-dimension=, + keep-with-next=, + keep-with-previous=, + text-decoration=, + visibility=, + width=] + {\beginXMLelement} + {\directsetup{fo:inline:process}\endXMLelement} + +\defineXMLsingular + [fo:inline] + {} + +% baseline-shift: baseline sub super % dimen inherit + +\chardef\isolatedwordsmode=1 + +\newdimen\wordshiftamount + +\def\shiftedword{\raise\wordshiftamount\hbox} + +\long\def\shiftedwords#1{\processisolatedwords{#1}\shiftedword} +\long\def\normalwords #1{\processisolatedwords{#1}\hbox} +\long\def\highwords #1{\processisolatedwords{#1}\high} +\long\def\lowwords #1{\processisolatedwords{#1}\low} + +\mapXMLvalue {fo:baseline-shift} {baseline} {\normalwords} +\mapXMLvalue {fo:baseline-shift} {sub} {\lowwords} +\mapXMLvalue {fo:baseline-shift} {super} {\highwords} +\mapXMLvalue {fo:baseline-shift} {inherit} {\firstofoneargument} + +\startsetups fo:inline:process + + \directsetup{fo:position:start} + + \dontleavehmode + + \doFOreference{fo:inline} + + \begingroup + + \directsetup{fe:setup} + \directsetup{fo:space:start} + + \begingroup + + \directsetup{fo:hyphenation:setup} + \directsetup{fo:font:setup} + + \doifelsenothing{\XMLop{baseline-shift}} + {\XMLflushself} + {\doifXMLvalelse{fo:baseline-shift}{\XMLop{baseline-shift}} + {\XMLval{fo:baseline-shift}{\XMLop{baseline-shift}}{}{\XMLflushself}} + {\wordshiftamount\lineheight + \setpercentdimen\wordshiftamount{\XMLop{baseline-shift}} + \shiftedwords{\XMLflushself}}} + + \endgroup + + \directsetup{fo:space:end} + + \endgroup + + \directsetup{fo:position:stop} + +\stopsetups + +\startsetups fo:position:start + \begingroup + \directsetup{fo:position:\XMLop{position}:start} + \begingroup +\stopsetups + +\startsetups fo:position:stop + \endgroup + \directsetup{fo:position:\XMLop{position}:stop} + \endgroup +\stopsetups + +\startsetups fo:position:static:start +\stopsetups + +\startsetups fo:position:static:stop +\stopsetups + +\startsetups fo:position:fixed:start + \FOcontainerWW\paperwidth + \FOcontainerHH\paperheight + \def\FOlayername{regions} + \directsetup{fo:preset:layer} + \setlayer[regions]{\vbox \bgroup \setlocalhsize} +\stopsetups + +\startsetups fo:position:fixed:stop + \egroup +\stopsetups + +\enableparpositions % slows down but who uses fo anyway ... + +\startsetups fo:position:absolute:start + \setbox\FOpositionbox\hbox\bgroup +\stopsetups + +\startsetups fo:position:absolute:stop + \egroup + % evt uitstellen tot otr, zodat text/realfolio is solved + \edef\FOpartag{p:\number\parposcounter} + \edef\FOtxttag{text:\realfolio} + \FOcontainerWW\MPplus\FOpartag{1}{0pt} + \FOcontainerHH\zeropoint % todo: add anchors to each 'object' + \directsetup{fo:preset:position} + \setlayer + [xsl-region-body] + [preset=lefttop, + hoffset=\dimexpr(\MPx\FOtxttag-\MPx\FOpartag), + voffset=\dimexpr(\MPy\FOtxttag+\MPh\FOtxttag-\MPy\FOpartag-\MPh\FOpartag)] + {\iftracingFO \ruledhbox \bgroup \fi + \offset + [method=fixed, + leftoffset=\FOcontainerL, + rightoffset=\FOcontainerR, + topoffset=\FOcontainerT, + bottomoffset=\FOcontainerB] + {\box\FOpositionbox} + \iftracingFO \egroup \fi} +\stopsetups + +\newbox\FOpositionbox + +\startsetups fo:position:relative:start + \setbox\FOpositionbox\hbox\bgroup +\stopsetups + +\startsetups fo:position:relative:stop + \egroup + \FOcontainerWW\wd\FOpositionbox + \FOcontainerHH\dimexpr(\ht\FOpositionbox+\dp\FOpositionbox) + \directsetup{fo:preset:position} + \iftracingFO \ruledhbox \bgroup \fi + \offset + [method=fixed, + leftoffset=\FOcontainerL, + rightoffset=\FOcontainerR, + topoffset=\FOcontainerT, + bottomoffset=\FOcontainerB] + {\box\FOpositionbox} + \iftracingFO \egroup \fi +\stopsetups + +% + +\startsetups fo:preset:position + + \FOcontainerW\zeropoint \FOcontainerL\zeropoint \FOcontainerR\zeropoint + \FOcontainerH\zeropoint \FOcontainerT\zeropoint \FOcontainerB\zeropoint + + \doifnot{\XMLop{left}} {auto}{\FOcontainerL\FOcontainerWW\setpercentdimen\FOcontainerL{\XMLop{left}}} + \doifnot{\XMLop{right}} {auto}{\FOcontainerR\FOcontainerWW\setpercentdimen\FOcontainerR{\XMLop{right}}} + \doifnot{\XMLop{top}} {auto}{\FOcontainerT\FOcontainerHH\setpercentdimen\FOcontainerT{\XMLop{top}}} + \doifnot{\XMLop{bottom}}{auto}{\FOcontainerB\FOcontainerHH\setpercentdimen\FOcontainerB{\XMLop{bottom}}} + + \doifnot{\XMLop{width}} {auto}{\FOcontainerW\FOcontainerWW\setpercentdimen\FOcontainerW{\XMLop{width}}} + \doifnot{\XMLop{height}}{auto}{\FOcontainerH\FOcontainerHH\setpercentdimen\FOcontainerH{\XMLop{height}}} + +\stopsetups + +\startsetups fo:preset:layer + + \directsetup{fo:preset:position} + + \setuplayer + [\FOlayername] + [width=\FOcontainerWW, + height=\FOcontainerHH] + + \ifzeropt\FOcontainerW + \FOcontainerW\dimexpr(\FOcontainerWW-\FOcontainerL-\FOcontainerR) + \fi + \ifzeropt\FOcontainerH + \FOcontainerH\dimexpr(\FOcontainerHH-\FOcontainerT-\FOcontainerB) + \fi + + \ifzeropt\FOcontainerB + \ifzeropt\FOcontainerL + \setuplayer[\FOlayername][preset=righttop, x=\FOcontainerR,y=\FOcontainerT] + \else + \setuplayer[\FOlayername][preset=lefttop, x=\FOcontainerL,y=\FOcontainerT] + \fi + \else + \ifzeropt\FOcontainerL + \setuplayer[\FOlayername][preset=rightbottom,x=\FOcontainerR,y=\FOcontainerB] + \else + \setuplayer[\FOlayername][preset=leftbottom, x=\FOcontainerL,y=\FOcontainerB] + \fi + \fi + +\stopsetups + +%D Element: fo:inline-container + +% display-align=, +% line-height=, +% reference-orientation=, +% writing-mode=, +% keep-together=, + +\defineXMLenvironment + [fo:inline-container] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + block-progression-dimension=, + clip=, + dominant-baseline=, + height=, + inline-progression-dimension=, + keep-with-next=, + keep-with-previous=, + overflow=, + width=] + {\beginXMLelement\begingroup} + {\endgroup\endXMLelement} + +%D Element: fo:leader + +% also a kind of fake fill + +% \XMLattributeset{fo:aural}, +% color=, +% line-height=, +% word-spacing=, + +\defineXMLenvironmentsave + [fo:leader] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + \XMLattributeset{fo:leader-and-rule}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + dominant-baseline=, + % text-depth=, + % text-altitude=, + keep-with-next=, + keep-with-previous=, + letter-spacing=, + text-shadow=, + visibility=] + {\beginXMLelement} + {\directsetup{fo:leader:process}\endXMLelement} + +\mapXMLvalue {fo:leader-pattern} {space} {\hfill} +\mapXMLvalue {fo:leader-pattern} {dots} {.} +\mapXMLvalue {fo:leader-pattern} {rule} {\hrulefill} +\mapXMLvalue {fo:leader-pattern} {use-content} {\XMLflushself} + +% todo: speed up + +\startsetups fo:leader:process + + %tracebackXMLattribute{leader-pattern-width} + + \strut \leaders + %edefXMLinh \FOlepatwd {leader-pattern-width} + \hbox to \XMLinh{leader-pattern-width} + {\hss\XMLval{fo:leader-pattern}{\XMLinh{leader-pattern}}{\hfill}\hss} + \hfill \strut + +\stopsetups + +%D Element: fo:pagenumber + +% \XMLattributeset{fo:aural}, +% line-height=, +% wrap-option=, +% letter-spacing=, +% text-transform=, +% word-spacing=, + +\defineXMLsingular + [fo:page-number] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + dominant-baseline=, + keep-with-next=, + keep-with-previous=, + score-spaces=, +% text-altitude=, + text-decoration=, +% text-depth=, + text-shadow=, + visibility=] + {\directsetup{fo:page-number:process}} + +\newcount\FOpnrefcounter + +\startsetups fo:page-number:process + + \doifelsenothing{\XMLpar{fo:page-sequence}{format}{}} + {\pagenumber} + {\ifinotr + \globallet\FOpnrefnumber\folio + \else + \global\advance\FOpnrefcounter\plusone + \pagereference[pnref:\the\FOpnrefcounter] + \doifreferencefoundelse{pnref:\the\FOpnrefcounter} + {\globallet\FOpnrefnumber\currentfolioreference} + {\globallet\FOpnrefnumber\folio} + \fi + \expanded{\handletokens\XMLpar{fo:page-sequence}{format}{}}\with{\handleFOformat{\FOpnrefnumber}}} + +\stopsetups + +\defineconversion[1][\numbers] + +\long\def\handleFOformat#1#2% + {\defconvertedargument\ascii{#2}% + \doifconversiondefinedelse\ascii{\convertnumber\ascii{#1}}{#2}} + +%D Element: fo:pagenumber-citation + +% same as page-number + +% \XMLattributeset{fo:aural}, +% line-height=, +% wrap-option=, +% letter-spacing=, +% text-transform=, +% word-spacing=, + +\defineXMLsingular + [fo:page-number-citation] + [\XMLattributeset{fo:inherited}, + id=, + ref-id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:font}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + dominant-baseline=, + keep-with-next=, + keep-with-previous=, + score-spaces=, +% text-altitude=, + text-decoration=, +% text-depth=, + text-shadow=, + visibility=] + {\directsetup{fo:page-number-citation:process}} + +\startsetups fo:page-number-citation:process + + \doifreferencefoundelse{\XMLop{ref-id}} + {\globallet\FOpnrefnumber\currentfolioreference + \globallet\FOpnrefformat\currenttextreference} + {\gdef\FOpnrefnumber{?} + \gdef\FOpnrefformat{}} + + \doifelsenothing{\FOpnrefformat} + {\FOpnrefnumber} + {\expanded{\handletokens\FOpnrefformat}\with{\handleFOformat{\FOpnrefnumber}}} + +\stopsetups + +%D Element: fo:table-and-caption + +% \XMLattributeset{fo:aural}, +% text-align=, +% caption-side=, +% intrusion-displace=, +% keep-together=, + +\defineXMLenvironment + [fo:table-and-caption] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:relative-position}, + break-after=, + break-before=, + keep-with-next=, + keep-with-previous=] + {\beginXMLelement} + {\endXMLelement} + +%D Element: fo:table fo:table-caption fo:table-header fo:table-footer +%D to:table-column fo:table-body fo:table-row fo:table-cell + +% \XMLattributeset{fo:aural}, +% border-collapse=, +% border-separation=, +% intrusion-displace=, +% keep-together=, +% writing-mode=, + +\defineXMLenvironment + [fo:table] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:relative-position}, + block-progression-dimension=, + border-after-precedence=, + border-before-precedence=, + border-start-precedence=, + border-end-precedence=, + break-after=, + break-before=, + inline-progression-dimension=, + height=, + keep-with-next=, + keep-with-previous=, + table-layout=, + table-omit-footer-at-break=, + table-omit-header-at-break=, +% text-indent=0pt, % yes or no? + width=] + {\beginXMLelement + \bTABLE % [option=stretch] % + \newcounter\FOtablecolumn} + {\eTABLE + \endXMLelement} + +\newdimen\FOtableW +\newdimen\FOtableH + +\defineXMLsingular + [fo:table-column] + [\XMLattributeset{fo:inherited}, + \XMLattributeset{fo:border-padding-background}, % only background, not the rest, make subset + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + column-width=, + column-number=, + number-columns-repeated=, + number-columns-spanned=, + visibility=] + {\directsetup{fo:table-column:action}} + +% \XMLattributeset{fo:aural}, +% intrusion-displace=, +% keep-together=, + +\defineXMLprocess + [fo:table-caption] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + block-progression-dimension=, + height=, + inline-progression-dimension=, + width=] + +% \XMLattributeset{fo:aural}, + +\defineXMLnested + [fo:table-header] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + visibility=] + {\beginXMLelement\bTABLEhead} + {\eTABLEhead\endXMLelement} + +% \XMLattributeset{fo:aural}, + +\defineXMLnested + [fo:table-footer] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + visibility=] + {\beginXMLelement\bTABLEfoot} + {\eTABLEfoot\endXMLelement} + +% \XMLattributeset{fo:aural}, + +\defineXMLnested + [fo:table-body] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + visibility=] + {\beginXMLelement\bTABLEbody} + {\eTABLEbody\endXMLelement} + +% TODO: when stretch and when not + +% \XMLattributeset{fo:aural}, +% keep-together=, + +\defineXMLnested + [fo:table-row] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + break-after=, + break-before=, + height=, + keep-with-next=, + keep-with-previous=, + visibility=] + {\beginXMLelement + \directsetup{fo:table-row:start}% + \expanded{\bTR[\the\scratchtoks]}% + \beginXMLelement} + {\endXMLelement + \eTR + \directsetup{fo:table-row:stop} + \endXMLelement} + +\startsetups fo:table-row:start + + \inTABLErowtrue + + \scratchtoks\emptytoks + + \doifsomething{\XMLop{height}} + {\FOtableH\textheight + \setpercentdimen\FOtableH{\XMLop{height}} + \appendetoks + height=\the\FOtableH + \to \scratchtoks} + + \appendetoks + ,extras={\rescanXMLattributes{fo:table-row}} + \to\scratchtoks + +\stopsetups + +\startsetups fo:table-row:stop + + \inTABLErowfalse + +\stopsetups + +% \XMLattributeset{fo:aural}, +% display-align=, +% relative-align=, +% empty-cells=, + +\newif\ifinTABLErow +\newdimen\FOtablecellwidth +\newdimen\FOtablecellheight + +\defineXMLnested + [fo:table-cell] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:relative-position}, + border-after-precedence=, + border-before-precedence=, + border-end-precedence=, + border-start-precedence=, + column-number=, + ends-row=, + height=, + inline-progression-dimension=, + number-columns-spanned=1, + number-rows-spanned=1, + starts-row=, + width=] + {\directsetup{fo:table-cell:start}% + \expanded{\bTD[\the\scratchtoks]}% + \beginXMLelement} + {\endXMLelement + \eTD + \directsetup{fo:table-cell:stop}} + +\startsetups fo:table-column:action + + \doifelsenothing{\XMLop{column-number}} + {\increment\FOtablecolumn} + {\edef\FOtablecolumn{\XMLop{column-number}} + \expanded{\setupTABLE[column][\FOtablecolumn][n=\FOtablecolumn]}} + + \doifsomething{\XMLop{column-width}} + {%\setlocalhsize + %\FOtableW\localhsize + \analyzefunction{\XMLop{column-width}}% + % hm, we need to set localhsize earlier + \doifelse\functionname{proportional-column-width} + {\FOtableW\functionA\textwidth} + {\FOtableW\textwidth + \setpercentdimen\FOtableW{\XMLop{column-width}}}% + \expanded{\setupTABLE[column][\FOtablecolumn][width=\the\FOtableW]}} + + \doif{\XMLop{border-style}}{none} + {\expanded{\setupTABLE[column][\FOtablecolumn][frame=off]}} + + \doifelsenothing{\XMLop{display-align}} + {\doifsomething{\XMLop{text-align}} + {\expanded{\setupTABLE[column][\FOtablecolumn] + [align=\XMLpav{fo:align-key}{fo:table-column}{text-align}{normal}]}}} + {\doifsomething{\XMLop{text-align}} + {\expanded{\setupTABLE[column][\FOtablecolumn] + [align={\XMLpav{fo:display-align}{fo:table-column}{display-align}{high},\XMLpav{fo:align-key}{fo:table-column}{text-align}{normal}}]}} + {\expanded{\setupTABLE[column][\FOtablecolumn] + [align=\XMLpav{fo:display-align}{fo:table-column}{display-align}{high}]}}} + +\expanded{\setupTABLE[column][\FOtablecolumn][extras={\rescanXMLattributes{fo:table-column}}]} + +\stopsetups + +\startsetups fo:table-cell:start + + \doif{\XMLop{starts-row}}{true}{\ifinTABLErow\eTR\inTABLErowfalse\fi} + + \ifinTABLErow\else\bTR\inTABLErowtrue\fi + + \doifelsenothing{\XMLop{background-color}} + {\let\FoTableBG\empty} + {\checkhexcolor[\XMLop{background-color}] + \doifcolorelse{\XMLop{background-color}} + {\def\FoTableBG{color}} + {\setXMLpar{fo:table-cell}{background-color}{} + \let\FoTableBG\empty}} + +% \doifelse{\XMLpar{fo:table-cell}{width}{}}{} +% {\def\pFOtablewidth{fit}} +% {\FOtablecellwidth\textwidth % probably must be localhsize or frozen at an outer level +% \setpercentdimen\FOtablecellwidth{\XMLpar{fo:table-cell}{width}{0pt}}% +% \edef\pFOtablewidth{\the\FOtablecellwidth}}% + +% \doifelse{\XMLpar{fo:table-cell}{height}{}}{} +% {\def\pFOtableheight{fit}} +% {\FOtablecellheight\textheight % probably must be localhsize or frozen at an outer level +% \setpercentdimen\FOtablecellheight{\XMLpar{fo:table-cell}{height}{0pt}}% +% \edef\pFOtableheight{\the\FOtablecellheight}}% + + \scratchtoks\emptytoks \appendetoks +% style=\noexpand\directsetup{fo:font:setup}, % else not expanded + nx=\XMLop{number-columns-spanned}, + ny=\XMLop{number-rows-spanned}, + n=\XMLop{column-number}, + background=\FoTableBG + \to \scratchtoks + + \doifnot{\XMLop{border-style}}{none} + {\appendetoks + ,frame=on + \to\scratchtoks} + + \doifsomething{\XMLop{background-color}} + {\appendetoks + ,backgroundcolor=\XMLop{background-color} + \to \scratchtoks} + + % todo : padding + + \doifsomething{\XMLop{padding}} + {\appendetoks + ,offset=\XMLop{padding} + \to \scratchtoks} + + % todo: interference with presets in column (outer level) -> \setupcolumn[column] ...; + % misschien meerdere align switches + + \doifelsenothing{\XMLop{display-align}} + {\doifsomething{\XMLop{text-align}} + {\appendetoks + ,align=\XMLpav{fo:align-key}{fo:table-cell}{text-align}{normal} + \to \scratchtoks}} + {\doifsomething{\XMLop{text-align}} + {\appendetoks + ,align={\XMLpav{fo:display-align}{fo:table-cell}{display-align}{high},\XMLpav{fo:align-key}{fo:table-cell}{text-align}{normal}}, + \to \scratchtoks} + {\appendetoks + ,align=\XMLpav{fo:display-align}{fo:table-cell}{display-align}{high} + \to \scratchtoks}} + + \appendetoks + ,extras={\rescanXMLattributes{fo:table-cell}} + \to\scratchtoks + +\stopsetups + +% \startsetups fo:table-cell:setup + +% [\XMLpar{fo:table-cell}{text-indent}{}] + +% \edefXMLinhpar\xFOtextindent{fo:table-cell}{text-indent} + +% \doifsomething\xFOtextindent +% {\scratchdimen\hsize +% \setpercentdimen\scratchdimen\xFOtextindent +% \expanded{\setupindenting[\the\scratchdimen]}} + +% \stopsetups + +\startsetups fo:table-cell:stop + + \doif{\XMLop{ends-row}}{true}{\eTR\inTABLErowfalse} + +\stopsetups + +%D Element: fo:list-block fo:list-item fo:list-body fo:list-item-label + +% \XMLattributeset{fo:aural}, +% intrusion-displace=, +% keep-together=, +% provisional-distance-between-starts=24pt, +% provisional-label-separation=6pt, + +\defineXMLenvironment + [fo:list-block] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:relative-position}, + break-after=, + break-before=, + keep-with-next=, +% space-between-list-rows=, % ? mentioned in bradley +text-indent=0pt, % yes + keep-with-previous=] + {\beginXMLelement\directsetup{fo:list:start}} + {\directsetup{fo:list:stop}\endXMLelement} + +\startsetups fo:list:start + \endgraf + \begingroup + \directsetup{fe:setup} + \disablemode[fo:in-list] + % \forgetall, no! +% \directsetup{fo:break-and-space:before} + \directsetup{fo:indent:setup} + \begingroup +\stopsetups + +\startsetups fo:list:stop + \endgraf + \endgroup +% \directsetup{fo:break-and-space:after} + \endgroup +\stopsetups + +% \XMLattributeset{fo:aural}, +% relative-align=, +% intrusion-displace=, +% keep-together=, + +% The list model is plain stupid. Instead of just defining a few mechanism +% or using some kind of type attribute, a strange mechanism of functions is +% used. Why on the one hand introduce redundant attributes and on the other +% hand safe a few elements. A proper segmentation of the problem would have +% brought better solutions. + +\defineXMLenvironment + [fo:list-item] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-block}, + \XMLattributeset{fo:relative-position}, + break-after=, + break-before=, + keep-with-next=, + keep-with-previous=] + {\beginXMLelement\directsetup{fo:list-item:start}} + {\directsetup{fo:list-item:stop}\endXMLelement} + +% check what is needed + +\newdimen\FOlistitemlabelhsize \newdimen\FOlistitembodyhsize \newdimen\FOlistitemdistance +\newdimen\FOlistitemlabelleftskip \newdimen\FOlistitembodyleftskip +\newdimen\FOlistitemlabelrightskip \newdimen\FOlistitembodyrightskip + +\defineXMLnestedsave + [fo:list-item-body] + [\XMLattributeset{fo:inherited}, + id=, % keep-together=, + \XMLattributeset{fo:accessibility}] + +\defineXMLnestedsave + [fo:list-item-label] + [\XMLattributeset{fo:inherited}, + id=, % keep-together=, + \XMLattributeset{fo:accessibility}] + +\startsetups fo:list-item:start + + \bgroup + +% \startmode[fo:in-list] +% \doifsomething{\XMLpar{fo:list-block}{space-between-list-rows}{}} +% {\vskip\XMLpar{fo:list-block}{space-between-list-rows}{}} % todo ! ! ! ! +% \stopmode + + \enablemode[fo:in-list] + +\stopsetups + +% todo : relative-align in list item + +\newif\ifFOlabelend +\newif\ifFObodystart + +\startsetups fo:list-item:stop + + % 24pt en 6pt in fo:root instellen + + % \tracebackXMLattribute{provisional-distance-between-starts} + + \edefXMLinh \FOprodis {provisional-distance-between-starts} + \edefXMLinh \FOprolab {provisional-label-separation} + +% \edef\FOprodis{\XMLpar{fo}{provisional-distance-between-starts}{}} +% \edef\FOprolab{\XMLpar{fo}{provisional-label-separation}{}} + + \edef\FOprodis{\ifx\FOprodis\empty24pt\else\FOprodis\fi} + \edef\FOprolab{\ifx\FOprolab\empty 6pt\else\FOprolab\fi} + + \setlocalhsize + + \FOlistitemlabelleftskip \zeropoint + \FOlistitemlabelrightskip\zeropoint + \FOlistitembodyleftskip \zeropoint + \FOlistitembodyrightskip \zeropoint + + \doifelse{\XMLpar{fo:list-item-label}{end-indent} {}}{label-end()} \FOlabelendtrue \FOlabelendfalse + \doifelse{\XMLpar{fo:list-item-body} {start-indent}{}}{body-start()}\FObodystarttrue\FObodystartfalse + + \setpercentdimen\FOlistitemlabelleftskip {\XMLpar{fo:list-item-label}{start-indent}{0pt}} + \setpercentdimen\FOlistitembodyrightskip {\XMLpar{fo:list-item-body} {end-indent} {0pt}} + + % maybe i need to implement something configurable + + \ifFObodystart + \ifFOlabelend + \FOlistitemlabelrightskip\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOprodis+\FOprolab) + \FOlistitembodyleftskip\dimexpr(\FOlistitemlabelleftskip+\FOprodis) + \FOlistitemlabelhsize\dimexpr(\FOprodis-\FOprolab) + \else + \setpercentdimen\FOlistitemlabelrightskip{\XMLpar{fo:list-item-label}{end-indent}{0pt}} + \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) + \FOlistitembodyleftskip\dimexpr(\FOlistitemlabelleftskip+\FOlistitemlabelhsize+\FOprolab) + \fi + \FOlistitemdistance \dimexpr(\FOprolab) + \else + \setpercentdimen\FOlistitembodyleftskip{\XMLpar{fo:list-item-body}{start-indent}{0pt}} + \ifFOlabelend + \FOlistitemlabelrightskip\dimexpr(\localhsize-\FOlistitembodyleftskip+\FOprolab) + \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) + \FOlistitemdistance \dimexpr(\FOprolab) + \else + \setpercentdimen\FOlistitemlabelrightskip{\XMLpar{fo:list-item-label}{end-indent}{0pt}} + \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) + \FOlistitemdistance \dimexpr(\FOlistitembodyleftskip-\FOlistitemlabelleftskip-\FOlistitemlabelhsize) + \fi + \fi + + % is this fall back permitted ? + + \ifzeropt\FOlistitemlabelleftskip \ifzeropt\FOlistitemlabelrightskip + \FOlistitembodyleftskip\FOprodis + \FOlistitemdistance\FOprolab + \FOlistitemlabelhsize\dimexpr(\FOlistitembodyleftskip-\FOlistitemdistance) + \fi \fi + + % + + \FOlistitembodyhsize\localhsize + + \advance\FOlistitembodyhsize-\FOlistitembodyleftskip + \advance\FOlistitembodyhsize-\FOlistitembodyrightskip + + \doifelse{\XMLpar{fo:list-item}{display-align}{}}{center} + {\directsetup{fo:list-item:display}} + {\directsetup{fo:list-item:text}} + + \egroup + +\stopsetups + +% todo: textindent + +\startsetups fo:list-item:display + + \endgraf + + \advance\leftskip \FOlistitemlabelleftskip + \advance\rightskip\FOlistitembodyrightskip + + \dontleavehmode \valign\bgroup\forgetall\vss##\vss\cr + \iftracingFO\ruledvtop\else\vbox\fi{\hsize\FOlistitemlabelhsize\directsetup{fo:list-item-label:setup}\XMLflush{fo:list-item-label}}\cr + \iftracingFO\ruledvtop\else\vbox\fi{\hsize\FOlistitembodyhsize \directsetup{fo:list-item-body:setup}\XMLflush{fo:list-item-body}}\cr + \egroup + +% \dontleavehmode \placesidebyside % or maybe paired boxes (legends) +% {\ruledvtop{\forgetall\hsize\FOlistitemlabelhsize\XMLflush{fo:list-item-label}}} +% {\ruledvtop{\forgetall\hsize\FOlistitembodyhsize \XMLflush{fo:list-item-body}}} + + \endgraf + +\stopsetups + +\newtoks\savedeverypar \savedeverypar\everypar + +\startsetups fo:list-item:text + + \everypar\savedeverypar % \appendtoksonce\insertparagraphintro\to\everypar % hack, binnen footnote ... + + \advance\leftskip \FOlistitembodyleftskip + \advance\rightskip\FOlistitembodyrightskip + + \setupparagraphintro[first][\directsetup{fo:list-item-label:process}] + \setupparagraphintro[next] [\begstrut\resetpenalties\clubpenalties] + \directsetup{fo:list-item-body:setup} + \XMLflush{fo:list-item-body}\endstrut + +\stopsetups + +\startsetups fo:list-item-label:setups + + \edefXMLinhpar\xFOtextindent{fo:item-label}{text-indent} + + \doifsomething\xFOtextindent + {\scratchdimen\hsize + \setpercentdimen\scratchdimen\xFOtextindent + \expanded{\setupindenting[\the\scratchdimen]}} + +\stopsetups + +\startsetups fo:list-item-body:setups + + \edefXMLinh\xFOtextindent{fo:item-body}{text-indent} + + \doifsomething\xFOtextindent + {\scratchdimen\hsize + \setpercentdimen\scratchdimen\xFOtextindent + \expanded{\setupindenting[\the\scratchdimen]}} + +\stopsetups + +\newbox\FOitembox + +\startsetups fo:list-item-label:process + + \setbox \FOitembox \iftracingFO \ruledvtop \else \vtop \fi \bgroup + \forgetall + \postponenotes + \hsize\FOlistitemlabelhsize + \directsetup{fo:list-item-label:setup} + \XMLflush{fo:list-item-label} + \egroup + \getnoflines{\dimexpr(\ht\FOitembox+\dp\FOitembox)} + \setpenalties\clubpenalties\noflines\maxdimen + \strut\llap{\box\FOitembox\hskip\FOlistitemdistance} + +\stopsetups + +% \setlocalhsize \hsize\localhsize + +%D Element: fo:basic-link + +% \XMLattributeset{fo:aural}, +% keep-together=, +% line-height=, + +\defineXMLenvironmentsave + [fo:basic-link] + [\XMLattributeset{fo:inherited}, + id=, + \XMLattributeset{fo:accessibility}, + \XMLattributeset{fo:border-padding-background}, + \XMLattributeset{fo:margin-inline}, + \XMLattributeset{fo:relative-position}, + alignment-adjust=, + alignment-baseline=, + baseline-shift=, + destination-placement-offset=, + dominant-baseline=, + external-destination=, + indicate-destination=, + internal-destination=, + keep-with-next=, + keep-with-previous=, + show-destination=, + target-processing-context=, + target-presentation-context=, + target-stylesheet=] + {} + {\directsetup{fo:basic-link}} + +\startsetups fo:basic-link + + \goto{\XMLflushself}[unknown] + +\stopsetups + +%D Element: fo:multi-switch fo:multi-case fo:multi-toggle fo:multi-properties fo:multi-property-set + +\defineXMLprocess[fo:multi-switch] +\defineXMLprocess[fo:multi-case] +\defineXMLprocess[fo:multi-toggle] +\defineXMLprocess[fo:multi-properties] +\defineXMLprocess[fo:multi-property-set] + +%D Element: fo:float + +\defineXMLenvironmentsave + [fo:float] + [\XMLattributeset{fo:inherited}, + float=before, + clear=] + {} + {\directsetup{fo:float:process}} + +% clear: start end left right both none inherit +% float: before start end left right none + +\mapXMLvalue {fo:float-position} {before} {here} % todo +\mapXMLvalue {fo:float-position} {start} {here} % todo +\mapXMLvalue {fo:float-position} {end} {here} % todo +\mapXMLvalue {fo:float-position} {left} {left} +\mapXMLvalue {fo:float-position} {right} {right} +\mapXMLvalue {fo:float-position} {none} {here} % todo + +\startsetups fo:float:process + + \placefigure + [\XMLval{fo:float-position}{\XMLop{float}},none] + {} + {\XMLflushself} + +\stopsetups + +%D Element: fo:footnote fo:footnote-body + +% Let's assume that 'whatever' contains the number or footnote marker. +% +% whatevernote + +% todo xsl-footnote area + +\defineXMLprocess + [fo:footnote] + [\XMLattributeset{fo:accessibility}] + +\defineXMLargument + [fo:footnote-body] + [\XMLattributeset{fo:accessibility}] + {\footnote[-]} + +%D Element: fo:wrapper + +\defineXMLenvironment % todo: all inheritable + [fo:wrapper] + [\XMLattributeset{fo:inherited}, + \XMLattributeset{fe:tracing}, + \XMLattributeset{fo:fonts}, + \XMLattributeset{fo:hyphenation}] + {\beginXMLelement\begingroup\directsetup{fo:wrapper}} + {\endgroup\endXMLelement} + +\startsetups fo:wrapper + + \directsetup{fe:setup} + \directsetup{fo:hyphenation:setup} + \directsetup{fo:font:setup} + +\stopsetups + +%D Element: fo:marker fo:retrieve-marker + +% In order to support 'retrieve-boundary' (page, page-sequence, +% document) I need to extend the context mark handler. + +% This object will probably interfere with a too spacy layout since +% it is unaware if its surrounding. + +\defineXMLenvironmentsave + [fo:marker] + [marker-class-name=unknown] + {} + {\directsetup{fo:marker:process}} + +\startsetups fo:marker:process + + \doifelsemarking{fo:\XMLop{marker-class-name}} + {} {\definerawmarking[fo:\XMLop{marker-class-name}]} + + \expanded{\marking[fo:\XMLop{marker-class-name}]{\XMLflushself}} + +\stopsetups + +\defineXMLcommand + [fo:retrieve-marker] + [retrieve-class-name=unknown, + retrieve-position=first-starting-within-page, + retrieve-boundary=] + {\directsetup{fo:retrieve-marker:process}} + +\mapXMLvalue {fo:marker-position} {first-starting-within-page} {first} % first mark +\mapXMLvalue {fo:marker-position} {first-including-carryover} {previous} % top mark +\mapXMLvalue {fo:marker-position} {last-starting-within-page} {first} % dunno +\mapXMLvalue {fo:marker-position} {last-ending-within-page} {last} % bot mark + +\startsetups fo:retrieve-marker:process + + \expanded{\getmarking + [fo:\XMLop{retrieve-class-name}] + [\XMLval{fo:marker-position}{\XMLop{retrieve-position}}{first}]} + +\stopsetups + +%D Auxiliary macros + +\unprotect + +\long\def\noFOchecks#1\od{} + +\def\FOassignskip#1#2#3% + {\edef\!!stringa{\XMLpar{#1}{#2}\empty}% + \edef\!!stringb{\XMLpar{#1}{#2.optimum}\empty}% + \edef\!!stringc{\XMLpar{#1}{#2.minimum}\empty}% + \edef\!!stringd{\XMLpar{#1}{#2.maximum}\empty}% + \dimen0=\ifx\!!stringa\empty\zeropoint\else\!!stringa\fi + \dimen2=\ifx\!!stringb\empty\dimen0 \else\!!stringb\fi + \dimen4=\dimexpr(\ifx\!!stringd\empty\dimen0 \else\!!stringd\fi-\dimen2)\relax + \dimen6=\dimexpr(\ifx\!!stringc\empty\dimen0 \else\!!stringc\fi-\dimen2)\relax + #3=\dimen2 \ifzeropt\dimen4 \else\!!plus\dimen4 \fi\ifzeropt\dimen6 \else\!!minus\dimen6 \fi\relax} + +\mapXMLvalue{fo:space:conditionality} {retain} {\let\next\retainedskip } +\mapXMLvalue{fo:space:conditionality} {discard} {\let\next\discardedskip} +\mapXMLvalue{fo:space:conditionality} {} {\let\next\discardedskip} + +\mapXMLvalue{fo:space:precedence} {force} {\let\next\forcedskip} + +\def\FOdoskip#1#2% + {\begingroup + \iftracingFO\showskips\fi + \FOassignskip{#1}{#2}\scratchskip + \XMLval{fo:space:conditionality}{\XMLpar{#1}{#2.conditionality}\empty}\empty + \XMLval{fo:space:precedence}{\XMLpar{#1}{#2.precedence}\empty}\empty + \ifdim\scratchskip=\zeropoint + \ifdim\gluestretch\scratchskip=\zeropoint + \ifdim\glueshrink\scratchskip=\zeropoint + \let\next\gobbleoneargument + \fi + \fi + \fi + \next\scratchskip + \endgroup} + +\def\doFObeforeskip#1{\FOdoskip{#1}{space-before}} +\def\doFOafterskip #1{\FOdoskip{#1}{space-after}} + +\def\FOassignspace#1#2#3% + {\edef\!!stringa{\XMLpar{#1}{#2}\empty}% + \ifx\!!stringa\empty + #3=\zeropoint + \else + #3=1em% ? + \setpercentdimen#3\!!stringa + \fi + \relax} + +\def\FOdospace#1#2% + {\begingroup + \iftracingFO\showskips\fi + \FOassignspace{#1}{#2}\scratchskip + \ifdim\scratchskip=\zeropoint \else + \hskip\scratchskip + \fi + \endgroup} + +\def\doFOstartspace#1{\FOdospace{#1}{space-start}} +\def\doFOendspace #1{\FOdospace{#1}{space-end}} + +\def\checkFOborder#1#2% + {\edef\FOattribute{\XMLpar{#1}{border-#2}\empty}% + \ifx\FOattribute\empty\else + \edef\FOtag{#1}% + \edef\FOatt{border-#2}% + \expanded{\docheckFOborder\FOattribute\space\relax\space\relax}\od + \fi} + +\def\docheckFOborder#1#2 #3% + {\ifx#1\relax + \expandafter\noFOchecks + \else + \doifhexcolorelse{#1#2} + {\setXMLpar\FOtag{\FOatt-color}{#1#2}} + {\doifelsenothing{\XMLval{fo:border-style}{#1#2}\empty} + {\doifcolorelse{#1#2} + {\setXMLpar\FOtag{\FOatt-color}{#1#2}} + {\setXMLpar\FOtag{\FOatt-width}{#1#2}}} + {\setXMLpar\FOtag{\FOatt-style}{#1#2}}}% + \expandafter\docheckFOborder + \fi#3} + +\def\checkFOposition#1#2% + {\edef\FOattribute{\XMLpar{#1}{#2-position}\empty}% + \ifx\FOattribute\empty\else + \edef\FOtag{#1}% + \edef\FOatt{#2-position}% + \scratchcounter\zerocount + \expanded{\docheckFOposition\FOattribute\space\relax\space\relax}\od + \fi} + +\def\docheckFOposition#1#2 #3% + {\ifx#1\relax + \expandafter\noFOchecks + \else + \advance\scratchcounter\plusone + \ifcase\scratchcounter + \or + \setXMLpar\FOtag{\FOatt-vertical}{#1#2}% + \or + \setXMLpar\FOtag{\FOatt-horizontal}{#1#2}% + \fi + \expandafter\docheckFOposition + \fi#3} + +\def\checkFOpadding{\def\FOatt{padding}\checkFOquadruple} +\def\checkFOmargin {\def\FOatt{margin}\checkFOquadruple} + +\def\checkFOquadruple#1% + {\edef\FOattribute{\XMLpar{#1}\FOatt\empty}% + \ifx\FOattribute\empty\else + \edef\FOtag{#1}% + \scratchcounter\zerocount + \expanded{\docheckFOquadruple\FOattribute\space\relax\space\relax}\od + \ifcase\scratchcounter + \let\FOattributeT\FOattribute + \let\FOattributeR\FOattribute + \let\FOattributeB\FOattribute + \let\FOattributeL\FOattribute + \or % (tblr) + \let\FOattributeT\FOattribute + \let\FOattributeR\FOattribute + \let\FOattributeB\FOattribute + \let\FOattributeL\FOattribute + \or % (tb)(lr) + \let\FOattributeB\FOattributeT + \let\FOattributeL\FOattributeR + \or % (t)(lr)(b) + \let\FOattributeL\FOattributeR + \or % (t)(r)(b)(l) + % already ok + \fi + \letXMLpar\FOtag{\FOatt-top}\FOattributeT + \letXMLpar\FOtag{\FOatt-right}\FOattributeR + \letXMLpar\FOtag{\FOatt-bottom}\FOattributeB + \letXMLpar\FOtag{\FOatt-left}\FOattributeL + \fi} + +\def\docheckFOquadruple#1#2 #3% + {\ifx#1\relax + \expandafter\noFOchecks + \else + \advance\scratchcounter\plusone + \ifcase\scratchcounter + \or + \edef\FOattributeT{#1#2}% + \or + \edef\FOattributeR{#1#2}% + \or + \edef\FOattributeB{#1#2}% + \or + \edef\FOattributeL{#1#2}% + \fi + \expandafter\docheckFOquadruple + \fi#3} + +% \def\setFOimagename#1% +% {\edef\FOimagename{#1}% +% \aftersplitstring \FOimagename\at url('\to\xFOimagename +% \ifx\xFOimagename\empty \else +% \beforesplitstring\xFOimagename\at ')\to\FOimagename +% \fi +% \aftersplitstring \FOimagename\at url("\to\xFOimagename +% \ifx\xFOimagename\empty \else +% \beforesplitstring\xFOimagename\at ")\to\FOimagename +% \fi} +% +% let's overkill: + +\def\setFOimagename#1% + {\analyzefunction{#1}% + \doifelse\functionname{url} + {\edef\FOimagename{\@EA\unstringed\functionA}} + {\ifx\functionname\empty + \def\FOimagename{#1}% + \else + \def\FOimagename{dummy}% + \fi}} + +% font + +\mapXMLvalue {fo:weight} {normal} {} +\mapXMLvalue {fo:weight} {bold} {bold} +\mapXMLvalue {fo:weight} {bolder} {bold} +\mapXMLvalue {fo:weight} {lighter} {normal} +\mapXMLvalue {fo:weight} {100} {normal} +\mapXMLvalue {fo:weight} {200} {normal} +\mapXMLvalue {fo:weight} {300} {normal} +\mapXMLvalue {fo:weight} {400} {normal} +\mapXMLvalue {fo:weight} {500} {normal} +\mapXMLvalue {fo:weight} {600} {normal} +\mapXMLvalue {fo:weight} {700} {normal} +\mapXMLvalue {fo:weight} {800} {normal} +\mapXMLvalue {fo:weight} {900} {normal} + +\mapXMLvalue {fo:variant} {normal} {} +\mapXMLvalue {fo:variant} {small-caps} {small-caps} + +\mapXMLvalue {fo:style} {normal} {normal} +\mapXMLvalue {fo:style} {italic} {italic} +\mapXMLvalue {fo:style} {oblique} {oblique} +\mapXMLvalue {fo:style} {backslant} {normal} + +% we can get crap like: 10pt/1.5 bold "Times Roman" ; i'm really puzzled why an +% otherwise rather verbose coding occasionally packs attributes; a design flaw + +\newtoks\FOfonttoks + +\def\checkFOfontSS#1'{} +\def\checkFOfontDD#1"{} +\def\checkFOfontII#1 {} + +\bgroup +\catcode`\'=\active +\catcode`\"=\active +\catcode`\/=\active +\gdef\setcheckFOfontX + {\catcode`\'=\active + \catcode`\"=\active + \catcode`\/=\active + \def'##1'{\global\FOfonttoks\expandafter{\the\FOfonttoks\def\FOfontfamily{##1}}}% + \def"##1"{\global\FOfonttoks\expandafter{\the\FOfonttoks\def\FOfontfamily{##1}}}% + \def/##1 {}}% todo linespacing +\gdef\setcheckFOfontXX + {\catcode`\'=\active + \catcode`\"=\active + \catcode`\/=\active + \def'##1'{}% + \def"##1"{}% + \def/##1 {}}% todo linespacing +\egroup + +\globallet\xFOattribute\empty + +\def\checkFOfont#1% + {\FOfonttoks\emptytoks + \bgroup + \catcode`\\=\@@escape + \catcode`\{=\@@begingroup + \catcode`\}=\@@endgroup +% \catcode`\:=\@@letter +% \catcode`\-=\@@letter + \setcheckFOfontX + \xdef\xFOattribute{#1 }% + \setbox\scratchbox\hbox{\scantokens\@EA{\xFOattribute}}% + \setcheckFOfontXX + \scantokens\@EA{\@EA\xdef\@EA\xFOattribute\@EA{\xFOattribute}}% + \egroup + \the\FOfonttoks + \ifx\xFOattribute\empty\else + \expanded{\docheckFOfont\xFOattribute\space\relax\space\relax}\od + \fi + \directsetup{fo:font:family:check}} + +\def\docheckFOfont#1#2 #3% + {\ifx#1\relax + \expandafter\noFOchecks + \else + \directsetup{fo:fonts:reset}% + \doifelsefontsynonym{#1#2} + {\def\FOfontfamily{#1#2}} + {\doifelsenothing{\XMLval{fo:weight}{#1#2}{}} + {\doifelsenothing{\XMLval{fo:variant}{#1#2}{}} + {\doifelsenothing{\XMLval{fo:style}{#1#2}{}} + {\setpercentdimen\dFOfontsize{#1#2}} + {\edef\FOfontstyle{\XMLval{fo:style}{#1#2}{}}}} + {\edef\FOfontvariant{\XMLval{fo:variant}{#1#2}{}}}} + {\edef\FOfontweight{\XMLval{fo:weight}{#1#2}{}}}}% + \expandafter\docheckFOfont + \fi#3} + +\protect + +\newtoks\FOreferences + +\def\setFOreference#1% + {\doifsomething{\XMLpar{#1}{id}{}} + {\expanded{\appendtoks + \noexpand\reference[\XMLpar{#1}{id}{}]{\XMLpar{fo:page-sequence}{format}{}}}% + \to\FOreferences}} + +\def\flushFOreferences + {\the\FOreferences + \global\FOreferences\emptytoks} + +\def\doFOreference#1% + {\doifsomething{\XMLpar{#1}{id}{}} + {\expanded{\reference[\XMLpar{#1}{id}{}]{\XMLpar{fo:page-sequence}{format}{}}}}} + +\appendtoks \flushFOreferences \to \everypar +\appendtoks \flushFOreferences \to \neverypar % check ! + +%D Graphics: static frames + +\startMPinclusions + input mp-fobg.mp ; +\stopMPinclusions + +\def\unknownMPcolor{FoNoColor} + +% todo: combine into one en alleen tweede run, immers toch geen invloed; is +% aangezien de referentiepunten vast liggen + +\def\FoRegionWidth#1% + {\XMLpav + {fo:border-width} + {fo:region-\MPvar{location}} + {border-#1-width} + {FoMedium}} + +\def\FoRegionStyle#1% + {\XMLpav + {fo:border-style} + {fo:region-\MPvar{location}} + {border-#1-style} + {FoNone}} + +\def\FoRegionColor#1% + {\MPcolor{\XMLpar + {fo:region-\MPvar{location}} + {border-#1-color} + {black}}} + +\def\FoRegionBackgroundColor + {\MPcolor{\XMLpar + {fo:region-\MPvar{location}} + {background-color} + {FoNoColor}}} + +% todo: when connected and same color : one draw + +\startuseMPgraphic{region-do} + FoBackgroundColor := \FoRegionBackgroundColor ; + FoLineColor[FoTop] := \FoRegionColor{top} ; + FoLineColor[FoBottom] := \FoRegionColor{bottom} ; + FoLineColor[FoLeft] := \FoRegionColor{left} ; + FoLineColor[FoRight] := \FoRegionColor{right} ; + FoLineStyle[FoTop] := \FoRegionStyle{top} ; + FoLineStyle[FoBottom] := \FoRegionStyle{bottom} ; + FoLineStyle[FoLeft] := \FoRegionStyle{left} ; + FoLineStyle[FoRight] := \FoRegionStyle{right} ; + FoLineWidth[FoTop] := \FoRegionWidth{top} ; + FoLineWidth[FoBottom] := \FoRegionWidth{bottom} ; + FoLineWidth[FoLeft] := \FoRegionWidth{left} ; + FoLineWidth[FoRight] := \FoRegionWidth{right} ; + if FoBackgroundColor <> FoNoColor : + fill OverlayBox + withcolor FoBackgroundColor ; + fi ; + path OverlayFrameBox ; + interim linecap := butt ; + OverlayFrameBox := OverlayBox + topenlarged -.5FoLineWidth[FoTop] + bottomenlarged -.5FoLineWidth[FoBottom] + leftenlarged -.5FoLineWidth[FoLeft] + rightenlarged -.5FoLineWidth[FoRight] ; + DrawFoFrame(FoTop, topboundary OverlayFrameBox) ; + DrawFoFrame(FoBottom, bottomboundary OverlayFrameBox) ; + DrawFoFrame(FoLeft, leftboundary OverlayFrameBox) ; + DrawFoFrame(FoRight, rightboundary OverlayFrameBox) ; +\stopuseMPgraphic + +\startuseMPgraphic{region-body} \includeMPgraphic{region-do} \stopuseMPgraphic +\startuseMPgraphic{region-before} \includeMPgraphic{region-do} \stopuseMPgraphic +\startuseMPgraphic{region-after} \includeMPgraphic{region-do} \stopuseMPgraphic +\startuseMPgraphic{region-start} \includeMPgraphic{region-do} \stopuseMPgraphic +\startuseMPgraphic{region-end} \includeMPgraphic{region-do} \stopuseMPgraphic + +\startnotmode[fo-no-bg] + +\defineoverlay[region-body-graphic] [\useMPgraphic{region-body}{location=body}] +\defineoverlay[region-before-graphic][\useMPgraphic{region-before}{location=before}] +\defineoverlay[region-after-graphic] [\useMPgraphic{region-after}{location=after}] +\defineoverlay[region-start-graphic] [\useMPgraphic{region-start}{location=start}] +\defineoverlay[region-end-graphic] [\useMPgraphic{region-end}{location=end}] + +\stopnotmode + +% more efficient: todo: relocate and move to page background + +% \def\FoRegionWidth#1#2% +% {\XMLpav +% {fo:border-width} +% {fo:region-#2} +% {border-#1-width} +% {FoMedium}} + +% \def\FoRegionStyle#1#2% +% {\XMLpav +% {fo:border-style} +% {fo:region-#2} +% {border-#1-style} +% {FoNone}} + +% \def\FoRegionColor#1#2% +% {\MPcolor{\XMLpar +% {fo:region-#2} +% {border-#1-color} +% {black}}} + +% \def\FoRegionBackgroundColor#1% +% {\MPcolor{\XMLpar +% {fo:region-#1} +% {background-color} +% {FoNoColor}}} + +% \def\combinedFOgraphic#1% +% {FoBackgroundColor := \FoRegionBackgroundColor{#1} ; +% FoLineColor[FoTop] := \FoRegionColor{top}{#1} ; +% FoLineColor[FoBottom] := \FoRegionColor{bottom}{#1} ; +% FoLineColor[FoLeft] := \FoRegionColor{left}{#1} ; +% FoLineColor[FoRight] := \FoRegionColor{right}{#1} ; +% FoLineStyle[FoTop] := \FoRegionStyle{top}{#1} ; +% FoLineStyle[FoBottom] := \FoRegionStyle{bottom}{#1} ; +% FoLineStyle[FoLeft] := \FoRegionStyle{left}{#1} ; +% FoLineStyle[FoRight] := \FoRegionStyle{right}{#1} ; +% FoLineWidth[FoTop] := \FoRegionWidth{top}{#1} ; +% FoLineWidth[FoBottom] := \FoRegionWidth{bottom}{#1} ; +% FoLineWidth[FoLeft] := \FoRegionWidth{left}{#1} ; +% FoLineWidth[FoRight] := \FoRegionWidth{right}{#1} ; +% if FoBackgroundColor <> FoNoColor : +% fill OverlayBox +% withcolor FoBackgroundColor ; +% fi ; +% path OverlayFrameBox ; +% interim linecap := butt ; +% OverlayFrameBox := OverlayBox +% topenlarged -.5FoLineWidth[FoTop] +% bottomenlarged -.5FoLineWidth[FoBottom] +% leftenlarged -.5FoLineWidth[FoLeft] +% rightenlarged -.5FoLineWidth[FoRight] ; +% DrawFoFrame(FoTop, topboundary OverlayFrameBox) ; +% DrawFoFrame(FoBottom, bottomboundary OverlayFrameBox) ; +% DrawFoFrame(FoLeft, leftboundary OverlayFrameBox) ; +% DrawFoFrame(FoRight, rightboundary OverlayFrameBox) ;} + +% \startuseMPgraphic{region-body} +% \combinedFOgraphic{before} +% \combinedFOgraphic{body} +% \combinedFOgraphic{after} +% \combinedFOgraphic{start} +% \combinedFOgraphic{end} +% \stopuseMPgraphic + +% \defineoverlay[region-body-graphic] [\useMPgraphic{region-body}{location=body}] +% \defineoverlay[region-before-graphic][] +% \defineoverlay[region-after-graphic] [] +% \defineoverlay[region-start-graphic] [] +% \defineoverlay[region-end-graphic] [] + +\stopXMLcompiling + +\endinput + +% we can follow two approaches: set the attributes global, using +% +% \defineXML...[tag][prefix][empty] +% +% in that case we trust the fo-file to be correct, i.e. the xslt style +% sheets should not put attributes in the wrong places; however, we need +% to do that with care, since for instance the attributes of some objects +% (regions) are used mixed +% +% \defineXMLprocess [fo:root] [XMLFO] [test=unset] +% +% \defineXMLenvironment [fo:block-container] [XMLFO] +% {\begingroup} +% {\endgroup} +% +% \defineXMLenvironment [fo:block] [XMLFO] +% {\begingroup\getXMLparameters[XMLFO]\begingroup} +% {\endgroup\XMLFOtest\endgraf\endgroup} +% +% \startXMLdata +% +% second: +% unset: +% nested:outer: +% last: +% +% \stopXMLdata +% +% the other approach is to set the attributes explicitly for each +% element, which is slower but more robust +% +% A mix is: +% +% \defineXMLenvironment +% [fo:root] +% [test=unset] +% {\beginXMLelement} +% {\endXMLelement} +% +% \defineXMLenvironment +% [fo:block-container] +% [test=\XMLpar\XMLpureparent{test}{}] +% {\beginXMLelement} +% {\endXMLelement} +% +% \defineXMLenvironment +% [fo:block] +% [test=\XMLpar\XMLpureparent{test}{}] +% {\beginXMLelement +% \begingroup} +% {\endgroup +% \XMLpar{fo:block}{test}{} +% \endXMLelement} +% +% \startXMLdata +% +% second: +% unset: +% nested:outer: +% last: +% +% \stopXMLdata diff --git a/tex/context/base/x-fo.tex b/tex/context/base/x-fo.tex deleted file mode 100644 index b2b0b59f9..000000000 --- a/tex/context/base/x-fo.tex +++ /dev/null @@ -1,4059 +0,0 @@ -%D \module -%D [ file=x-fo, -%D version=2004.03.12, % based on earlier experiments -%D title=\FOXET, -%D subtitle=Formatting Objects, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -% \showframe - -% This is a first implementation, maybe I will write another one with mixed -% element indifferent vars and something 'when set, act upon it, and forget', -% for instance: in each element check if font set, if so, change font and -% reset font attributes. I'm not sure if this is wise. - -% todo: global assignment in order to limit restore -% todo: combine mp graphics (see end) saves 30% -% todo: using contants and variables (for internal use) - -% todo: language at more levels - -% beware: aftergroup vs egroup/endgroup - -\useXMLfilter[prs,run] - -% \input xtag-run - -\unprotect - -% syst-new.tex - -\long\def\unstringed#1% " ' space - {\csname\ifcsname @u@s@#1\endcsname @u@s@#1\else\s!empty\fi\endcsname#1} - -\long\setvalue{@u@s@"}#1#2"{#2} -\long\setvalue{@u@s@'}#1#2'{#2} -\long\setvalue{@u@s@ }#1#2 {#2} - -% xtag-ini - -\def\letXMLpar #1#2{\@EA \let\csname\@@XMLvariable:#1:#2\endcsname} -\def\setXMLpar #1#2{\@EA \def\csname\@@XMLvariable:#1:#2\endcsname} -\def\setXMLepar#1#2{\@EA\edef\csname\@@XMLvariable:#1:#2\endcsname} - -\protect - -%D Most time went into figuring out the specifications, especially -%D because there are no examples included. Samples that circulate on the -%D web are often border cases and torture test and don't have much to do -%D with real live. Another complication lays in the inheritance model: -%D some of the attributes are inherited. This also leaves some room for -%D interpretation, for instance do values that are used at a certain -%D point migrate downwards or not. -%D -%D The \CONTEXT\ \XML handler can deal with attributes in several ways -%D and for this purpose I have played with a few experimental mechanisms -%D just to end up with the existing begin/end mechanism combined with -%D a recursive attribute resolver which means that one has to implicitly -%D ask for an inherited attributes. This approach is probably one of the -%D most efficient ways of dealing with formatting objects in \CONTEXT, -%D unless of course I start adding rather specific support to the kernel. -%D -%D This module is rather experimental. More information about its usage -%D can be found in the \FOXET\ manual. - -%D Since we're not dealing with the fine points of typesetting here, we -%D can safely ignore \TEX's warnings about overful or underful boxes. - -\dontcomplain - -%D We will use fonts that have the characters in the normal (ascii) -%D slots. We will also use the stupid verbatim handler. - -\chardef\XMLtokensreduction = 2 -\chardef\XMLcdatamethod = 2 - -%D For the purpose of testing. - -\startmode[fo-verbose] - \def\writeFOstatus{\writestatus{XML-FO}} -\stopmode - -\startnotmode[fo-verbose] - \let\writeFOstatus\gobbleoneargument -\stopnotmode - -%D For the moment we stick to utf-8. - -\useXMLfilter[utf] - -%D This will be sorted out later (esp in relation to mathml). - -\setupbodyfont[pos,10pt] - -%D There are a couple of predefined colors. Don't ask me why, but -%D formatting objects are not a fresh start but a mix of existing -%D technologies. Color support is poluted by cascading stylesheets. -%D -%D Because hexadecimal color specifications are not enabled by -%D default, this feature has to be enables by loading the appropriate -%D color module. Here we define colors in \RGB\ values because we -%D don't want to loose accuracy. - -\setupcolors[state=start] \setupcolor[hex] - -\definecolor [black] [s=0] % [h=000000] -\definecolor [gray] [s=.5] % [h=808080] -\definecolor [silver] [s=.75] % [h=C0C0C0] -\definecolor [white] [s=1] % [h=FFFFFF] -\definecolor [maroon] [r=.5] % [h=800000] -\definecolor [red] [r=1] % [h=FF0000] -\definecolor [purple] [r=.5,b=.5] % [h=800080] -\definecolor [fuchsia] [r=1,b=1] % [h=FF00FF] -\definecolor [green] [g=.5] % [h=008000] -\definecolor [lime] [g=1] % [h=00FF00] -\definecolor [olive] [r=.5,g=.5] % [h=808000] -\definecolor [yellow] [r=1,g=1] % [h=FFFF00] -\definecolor [navy] [r=1,g=1] % [h=000080] -\definecolor [blue] [b=1] % [h=0000FF] -\definecolor [teal] [g=.5,b=.5] % [h=008080] -\definecolor [aqua] [g=1,b=1] % [h=00FFFF] - -%D The layout is rather basic. Of the 25 available areas we -%D only use the text area. Maybe some day I will plug in a -%D more dedicated page builder. - -\setuplayout - [backspace=0pt, - topspace=0pt, - header=0pt, - footer=0pt, - width=middle, - height=middle, - % marking=on, - location=middle] - -\setuppagenumbering - [alternative={doublesided,singlesided}, % sic - location=] - -\setuptolerance - [verytolerant,stretch] - -%D We will position the regions using layers. - -\definelayer[regions][width=\paperwidth,height=\paperheight] - -\definelayer[xsl-region-before] -\definelayer[xsl-region-after] -\definelayer[xsl-region-start] -\definelayer[xsl-region-end] -\definelayer[xsl-region-body] - -\setupbackgrounds[page][background=regions] - -%D We now enter the part of this module where the action takes -%D place. As usual we provide some tracing options. - -\newif\iftracingFO \readsysfile{page-run}\donothing\donothing - -%D We will organize the attribute definitions in a similar fashion as in -%D the specification. Unfortunately there are more sets defined in there -%D than are actually used, so the definitions later on will look a bit -%D messy. -%D -%D Quite some attributes can be inherited, which means that they can -%D end up in all elements and influence those way down the tree. - -\defineXMLattributeset - [fo:inherited] - -%D The properties: - -% \defineXMLattributeset -% [fe:tracing] -% [tracing=] - -\defineXMLattributeset - [fo:accessibility] - [source-document=none, - role=none] - -\defineXMLattributeset - [fo:absolute-position] - [absolute-position=auto, - top=auto, - right=auto, - bottom=auto, - left=auto] - -% \defineXMLattributeset -% [fo:aural] -% [azitmuth=, -% cue-after=, -% cue-before=, -% elevation=, -% pause-after=, -% pause-before=, -% pitch=, -% pitch-range=, -% play-during=, -% richness=, -% speak=, -% speak-header=, -% speak-numeral=, -% speak-punctuation=, -% speech-rate=, -% stress=, -% voice-family=, -% volume=] - -\defineXMLattributeset - [fo:border-padding-background] - [background-attachment=scroll, - background-color=transparent, - background-image=none, - background-repeat=repeat, - background-position-horizontal=left, - background-position-vertical=top, - border-color=transparent, - border-style=none, - border-width=medium, - background-position=, - border-top=, - border-bottom=, - border-left=, - border-right=, - border-before-color=\XMLop{border-color}, - border-before-style=\XMLop{border-style}, - border-before-width=\XMLop{border-width}, - border-after-color=\XMLop{border-color}, - border-after-style=\XMLop{border-style}, - border-after-width=\XMLop{border-width}, - border-start-color=\XMLop{border-color}, - border-start-style=\XMLop{border-style}, - border-start-width=\XMLop{border-width}, - border-end-color=\XMLop{border-color}, - border-end-style=\XMLop{border-style}, - border-end-width=\XMLop{border-width}, - border-top-color=\XMLop{border-before-color}, - border-top-style=\XMLop{border-before-style}, - border-top-width=\XMLop{border-before-width}, - border-bottom-color=\XMLop{border-after-color}, - border-bottom-style=\XMLop{border-after-style}, - border-bottom-width=\XMLop{border-after-width}, - border-left-color=\XMLop{border-start-color}, - border-left-style=\XMLop{border-start-style}, - border-left-width=\XMLop{border-start-width}, - border-right-color=\XMLop{border-end-color}, - border-right-style=\XMLop{border-end-style}, - border-right-width=\XMLop{border-end-width}, - padding=,% 0pt, - padding-before=0pt,%\XMLop{padding}, - padding-after=0pt,%\XMLop{padding}, - padding-start=0pt,%\XMLop{padding}, - padding-end=0pt,%\XMLop{padding}, - padding-top=\XMLop{padding-before}, - padding-bottom=\XMLop{padding-after}, - padding-left=\XMLop{padding-start}, - padding-right=\XMLop{padding-end}] - -\extendXMLattributeset - [fo:border-padding-background] - [fe:background-height=, - fe:background-width=] - -\defineXMLattributeset - [fo:font] - [] - -\extendXMLattributeset - [fo:inherited] - [font=, - font-family=,% Times, - font-selection-strategy=, - font-size=,% 12pt, - font-size-adjust=, % 1, - font-style=, % normal, - font-variant=, % normal, - font-weight=] % normal] - -\defineXMLattributeset - [fo:hyphenation] - [] - -\extendXMLattributeset - [fo:inherited] - [country=, - language=, - script=, - hyphenate=, - hyphenation-character=, - hyphenation-push-character-count=, - hyphenation-remain-character-count=] - -\defineXMLattributeset - [fo:margin-block] - [margin=, % 0pt, - margin-top=0pt,% \XMLop{margin}, - margin-bottom=0pt,% \XMLop{margin}, - margin-left=0pt,% \XMLop{margin}, - margin-right=0pt,% \XMLop{margin}, - space-before=0pt, - space-after=0pt, - space-before.precedence=, - space-before.conditionality=, - space-before.minimum=, - space-before.optimum=, - space-before.maximum=, - space-after.precedence=, - space-after.conditionality=, - space-after.minimum=, - space-after.optimum=, - space-after.maximum=] - -\extendXMLattributeset - [fo:inherited] - [start-indent=, - end-indent=] - -\defineXMLattributeset - [fo:margin-inline] - [space-start=, - space-end=] - -\defineXMLattributeset - [fo:relative-position] - [relative-position=, - top=auto, - right=auto, - bottom=auto, - left=auto] - -\defineXMLattributeset - [fo:area-alignment] - [alignment-adjust=, - alignment-baseline=, - baseline-shift=, - dominant-baseline=] - -\extendXMLattributeset - [fo:inherited] - [display-align=, - relative-align=] - -\defineXMLattributeset - [fo:area-dimension] - [block-progression-dimension=, - inline-progression-dimension=, - content-height=, - content-width=, - height=, - width=, - max-height=, - max-width=, - min-height=, - min-width=, - scaling=, - scaling-method=] - -\defineXMLattributeset - [fo:block-and-line] - [] - -\extendXMLattributeset - [fo:inherited] - [hyphenation-keep=, - hyphenation-ladder-count=, - last-line-end-indent=, - line-height=, - line-height-shift-adjustment=, - line-stacking-strategy=, - linefeed-treatment=, - white-space-treatment=, - text-align=, - text-align-last=, - text-indent=, - white-space-collapse=, - wrap-option=] - -\defineXMLattributeset - [fo:character] - [character=, - suppress-at-line-break=, - text-decoration=, - text-shadow=, - treat-as-word-space=] - -\extendXMLattributeset - [fo:inherited] - [letter-spacing=, - text-transform=, - word-spacing=] - -\defineXMLattributeset - [fo:color] - [color-profile-name=, - rendering-intent=] - -\extendXMLattributeset - [fo:inherited] - [color=] - -\defineXMLattributeset - [fo:float] - [clear=, - float=] - -\extendXMLattributeset - [fo:inherited] - [intrusion-displace=] - -\defineXMLattributeset - [fo:keeps-and-breaks] - [break-after=, - break-before=, - keep-with-next.within-line=, - keep-with-next.within-column=, - keep-with-next.within-page=, - keep-with-previous.within-line=, - keep-with-previous.within-column=, - keep-with-previous.within-page=] - -\extendXMLattributeset - [fo:inherited] - [keep-together.within-line=, - keep-together.within-column=, - keep-together.within-page=, - orphans=, - widows=] - -\defineXMLattributeset - [fo:layout] - [clip=, - overflow= - span=] - -\extendXMLattributeset - [fo:inherited] - [reference-orientation=] - -\defineXMLattributeset - [fo:leader-and-rule] - [] - -\extendXMLattributeset - [fo:inherited] - [leader-alignment=, - leader-pattern=, - leader-pattern-width=, - leader-pattern-width=, - leader-length=, - rule-style=, - rule-thickness=] - -\defineXMLattributeset - [fo:dynamic-effects] - [active-state=, - case-name=, - case-title=, - destination-placement-offset=, - external-destination=, - indicate-destination=, - internal-destination=, - show-destination=, - starting-state=, - switch-to=, - target-presentation-context=, - target-processing-context=, - target-stylesheet=] - -\extendXMLattributeset - [fo:inherited] - [auto-restore=] - -\defineXMLattributeset - [fo:markers] - [marker-class-name=, - retrieve-class-name=, - retrieve-position=, - retrieve-boundary=] - -\defineXMLattributeset - [fo:number-to-string] - [country=, - language=, - format=, - grouping-separator=, - grouping-size=, - letter-value=] - -% \defineXMLattributeset -% [fo:pagination-and-layout] -% [black-or-not-blank=, -% column-count=1, -% column-gap=12pt, -% extent=, -% flow-name=, -% force-page-count=, -% initial-page-number=, -% master-name=, -% master-reference=, -% maximum-repeats=, -% media-usage=, -% odd-or-even=, -% page-height=, -% page-position=, -% page-width=, -% precedence=, -% region-name=] - -\defineXMLattributeset - [fo:table] - [border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - column-number=, - column-width=, - ends-row=, - number-columns-repeated=, - number-columns-spanned=, - number-rows-spanned=, - starts-row=, - table-layout=, - table-omit-footer-at-break=, - table-omit-header-at-break=] - -\extendXMLattributeset - [fo:inherited] - [border-collapse=, - border-separation=, - caption-side=, - empty-cells=] - -\defineXMLattributeset - [fo:writing-mode] - [%text-altitude=, - %text-depth=, - unicode-bidi=] - -\extendXMLattributeset % for practical reasons we inherit along the whole chain - [fo:inherited] % unless we implement relax skipping - [text-altitude=, - text-depth=] - -\extendXMLattributeset - [fo:inherited] - [direction=, - glyph-orientation-horizontal=, - glyph-orientation-vertical=, - writing-mode=] - -\defineXMLattributeset - [fo:list-block] - [] - -\extendXMLattributeset - [fo:inherited] - [provisional-label-separation=, - provisional-distance-between-starts=] - -% \starttext -% \setuplayout[topspace=1cm,height=middle,header=0pt,footer=0pt] -% \setupbodyfont[small,tt] -% \expanded{\processcommalist[\XMLattributeset{fo:inherited}]}\endgraf -% \stoptext - -% content-type -% id - -% ref-id -% score-spaces % inherited -% src -% visibility % inherited -% z-index - -% shorthands: -% -% background -% background-position -% border -% border-bottom -% border-left -% border-top -% border-right -% border-style -% border-color -% border-spacing % inherited -% border-width -% cue -% font % inherited -% margin -% padding -% page-break-after -% page-break-before -% page-break-inside % inherited -% pause -% position -% size -% vertical-align -% white-space % inherited - -%D We will speed up the process of setting up attributes by compiling the -%D definitions. Sometimes we need to access attributes explicitly by -%D element (for instance when handling regions). We also need to deal -%D with nested elements (for instance blocks) or a sequence of similar -%D ones, while we may not always want to use grouping. As a result, the -%D next series of definitions and macros are quite ugly. The begin|/|end -%D is needed in order to comfortably fetch attribute values from -%D ancestors. - -\startXMLcompiling[inherit] - -%D Element: fo:root - -%D todo: set defaults here - -\defineXMLenvironment - [fo:root] - [\XMLattributeset{fo:inherited}, -leader-pattern=spaces, -leader-pattern-width=12pt, - media-usage=] - {\directsetup{fo:root:start}} - {\directsetup{fo:root:stop}} - -\startsetups fo:root:start - \starttext \beginXMLelement \startXMLignore - \doifsomething{\XMLop{language}}{\mainlanguage[\XMLop{language}]}% todo, everywhere -\stopsetups - -\startsetups fo:root:stop - \stopXMLignore \endXMLelement \stoptext -\stopsetups - -%D Element: fo:declarations - -\defineXMLprocess - [fo:declarations] - -%D Element: fo:color-profile - -\defineXMLignore - [fo:color-profile] - [src=, - color-profile-name=, - rendering-intent=] - -%D Element: fo:page-sequence - -% master-name and master-reference are often mixed up in examples - -\defineXMLenvironment - [fo:page-sequence] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:number-to-string}, - initial-page-number=auto, - master-reference=any, - force-page-count=auto] - {\beginXMLelement\directsetup{fo:page-sequence:start}} - {\directsetup{fo:page-sequence:stop}\endXMLelement} - -\mapXMLvalue {fo:page-initial} {auto} {\relax} -\mapXMLvalue {fo:page-initial} {auto-odd} {\ifodd\pageno \expanded{\setuppagenumber[number=\the\dimexpr(\pageno+1)]}\fi} -\mapXMLvalue {fo:page-initial} {auto-even} {\ifodd\pageno\else\expanded{\setuppagenumber[number=\the\dimexpr(\pageno+1)]}\fi} - -% todo: blokkeer left/right/etc in geval van blank - -\mapXMLvalue {fo:page-start} {auto} {\page} -\mapXMLvalue {fo:page-start} {even} {\page\setuplayout[blank]\page[even]} -\mapXMLvalue {fo:page-start} {odd} {\page\setuplayout[blank]\page[odd]} -\mapXMLvalue {fo:page-end} {end-on-even} {\page\setuplayout[blank]\page[even]} -\mapXMLvalue {fo:page-end} {end-on-odd} {\page\setuplayout[blank]\page[odd]} -\mapXMLvalue {fo:page-start} {no-force} {\page} - -\startsetups fo:page-sequence:start - - % we're still in the previous page-sequence - - \XMLval{fo:page-start}{\XMLop{force-page-count}}{\page} \begingroup - - \directsetup{fe:setup} - - \iftracingFO \showframe[text] \fi - - \xdef\SavedPageNumber{\the\realpageno} - - % now we enter the new page-sequence - - % todo: check on number - - \doifXMLvalelse{fo:page-initial}{\XMLop{initial-page-number}} - {\XMLval{fo:page-initial}{\XMLop{initial-page-number}}{}} - {\doifnot{\XMLop{initial-page-number}}{auto} - {\expanded{\setuppagenumber[number=\XMLop{initial-page-number}]}}} - - \doifsomething{\XMLpar{fo:page-sequence}{master-reference}{}} - {\doifelseXMLelement{fo:page-sequence-master:\XMLpar{fo:page-sequence}{master-reference}{}} - {%[starting page sequence master: \XMLpar{fo:page-sequence}{master-reference}{}]\endgraf - \flushXMLelement{fo:page-sequence-master:\XMLpar{fo:page-sequence}{master-reference}{}}} - {%[starting simple page master: \XMLpar{fo:page-sequence}{master-reference}{any}]\endgraf - \flushXMLelement{fo:simple-page-master:\XMLpar{fo:page-sequence}{master-reference}{any}}}} - - \doif{\XMLpar{fo:simple-page-master-do}{fe:option}{}}{fit} - {\directsetup{fe:page:option:fit:start}} - - \doifnot{\XMLpar{fo:region-body}{column-count}{1}}{1} - {\directsetup{fo:columns:start}} - -\stopsetups - -\startsetups fo:page-sequence:stop - - \doifnot{\XMLpar{fo:region-body}{column-count}{1}}{1} - {\directsetup{fo:columns:stop}} - - \doif{\XMLpar{fo:simple-page-master-do}{fe:option}{}}{fit} - {\directsetup{fe:page:option:fit:stop}} - - % \XMLval{fo:page-end}{\XMLop{force-page-count}}{\page} \endgroup - - \ifnum\SavedPageNumber=\realpageno - - \ifdim\pagetotal<.5\textheight \null \vfill \fi % force a page with only containers - - \fi - - \XMLval{fo:page-end}{\XMLpar{fo:page-sequence}{force-page-count}{}}{\page} \endgroup - -\stopsetups - -\newdimen\FOcolumngap - -\startsetups fo:columns:start - - \FOcolumngap\textwidth - - \setpercentdimen\FOcolumngap{\XMLpar{fo:region-body}{column-gap}{12pt}} - - % we need to freeze the lineheight here - - \expanded{\definecolumnset - [fo:set] - [n=\XMLpar{fo:region-body}{column-count}{1}, - distance=\FOcolumngap]} - - \expanded{\definecolumnsetspan - [fo:set] - [n=\XMLpar{fo:region-body}{column-count}{1}]} - - \directsetup{fo:font:setup} % else problems - - \directsetup{fo:line-height:setup} - -% \parseXMLattributes{fo:flow}{line-height='normal'} - - \startcolumnset[fo:set] - - % \startcolumns[\XMLpar{fo:region-body}{column-count}{1}] - -\stopsetups - -\startsetups fo:columns:stop - - % \stopcolumns - - \stopcolumnset - -\stopsetups - -%D Element: fo:layout-master-set - -\defineXMLprocess - [fo:layout-master-set] - -%D Element: fo:page-sequence-master - -\defineXMLenvironmentsave - [fo:page-sequence-master] - [\XMLattributeset{fo:inherited}, - master-name=any] - {} - {%[saved page sequence master: \XMLop{master-name}]\endgraf - \gsaveXMLdatainelement - {fo:page-sequence-master:\XMLop{master-name}} - {fo:page-sequence-master-do} - {fo:page-sequence-master}} - -\defineXMLprocess - [fo:page-sequence-master-do] - [\XMLattributeset{fo:inherited}] - -%D Element: fo:single-page-master-reference - -% makeup - one page - -\defineXMLcommand - [fo:single-page-master-reference] - [master-reference=any] - {\flushXMLelement{fo:simple-page-master:\XMLop{master-reference}}} - -%D Element: fo:repeatable-page-master-reference - -\defineXMLcommand - [fo:repeatable-page-master-reference] - [master-reference=any, - maximum-repeats=] - {\flushXMLelement{fo:simple-page-master:\XMLop{master-reference}}} - -%D Element: fo:repeatable-page-master-alternatives - -\defineXMLprocess - [fo:repeatable-page-master-alternatives] - [maximum-repeats=] - -%D Element: fo:conditional-page-master-reference - -% page-position : first last rest any -% odd-or-even : odd even any -% blank-or-not-blank : blank not-blank - -% The page-position default is needed (else possible loops) - -\defineXMLcommand - [fo:conditional-page-master-reference] - [master-reference=any, - page-position=\XMLpar{fo:conditional-page-master-reference}{master-reference}{any}, - blank-or-not-blank=, - odd-or-even=] - {\flushXMLelement{fo:simple-page-master:\XMLpar{fo:conditional-page-master-reference}{master-reference}{}}} - -%D Element: fo:simple-page-master - -% first-page left-page right-page blank-page - -% default dimensions - -\defineXMLenvironmentsave - [fo:simple-page-master] - [master-name=any] - {} - {%[saved simple page master: \XMLop{master-name}]\endgraf - \gsaveXMLdatainelement - {fo:simple-page-master:\XMLop{master-name}} - {fo:simple-page-master-do} - {fo:simple-page-master}} - -% reference-orientation=0deg, -% writing-mode= - -\defineXMLenvironment - [fo:simple-page-master-do] - [\XMLattributeset{fo:inherited}, % added - \XMLattributeset{fo:margin-block}, - page-height=29.7cm, - page-width=21cm] - {\directsetup{fo:simple-page-master:start}} - {\directsetup{fo:simple-page-master:stop}} - -% not needed any more: - -\mapXMLvalue {fo:reference-orientation} {0deg} {0} -\mapXMLvalue {fo:reference-orientation} {90deg} {90} -\mapXMLvalue {fo:reference-orientation} {180deg} {180} -\mapXMLvalue {fo:reference-orientation} {270deg} {270} -\mapXMLvalue {fo:reference-orientation} {-90deg} {270} -\mapXMLvalue {fo:reference-orientation} {-180deg} {180} -\mapXMLvalue {fo:reference-orientation} {-270deg} {90} - -\startsetups fo:simple-page-master:start - - % nothing - -\stopsetups - -% can be low level tex - -\startsetups fo:simple-page-master:stop - - \writeFOstatus{defining papersize '\directsetup{fo:layout:kind}'} - - \expanded - {\definepapersize - [\directsetup{fo:layout:kind}] - [width=\XMLop{page-width}, - height=\XMLop{page-height}]} - - \checkFOpadding {fo:region-body} - \checkFOmargin {fo:region-body} - \checkFOmargin {fo:simple-page-master-do} - - \writeFOstatus{defining layout '\directsetup{fo:layout:kind}'} - - \FOscratchMT\paperheight \setpercentdimen\FOscratchMT{\XMLpar{fo:simple-page-master-do}{margin-top} \zeropoint} - \FOscratchMB\paperheight \setpercentdimen\FOscratchMB{\XMLpar{fo:simple-page-master-do}{margin-bottom}\zeropoint} - \FOscratchML\paperwidth \setpercentdimen\FOscratchML{\XMLpar{fo:simple-page-master-do}{margin-left} \zeropoint} - \FOscratchMR\paperwidth \setpercentdimen\FOscratchMR{\XMLpar{fo:simple-page-master-do}{margin-right} \zeropoint} - - \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-body}{margin-top} \zeropoint} - \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-body}{margin-bottom}\zeropoint} - \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-body}{margin-left} \zeropoint} - \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-body}{margin-right} \zeropoint} - - \FOscratchPB\paperheight \setpercentdimen\FOscratchPB{\XMLpar{fo:region-body}{padding-top} \zeropoint} - \FOscratchPA\paperheight \setpercentdimen\FOscratchPA{\XMLpar{fo:region-body}{padding-bottom}\zeropoint} - \FOscratchPS\paperwidth \setpercentdimen\FOscratchPS{\XMLpar{fo:region-body}{padding-left} \zeropoint} - \FOscratchPE\paperwidth \setpercentdimen\FOscratchPE{\XMLpar{fo:region-body}{padding-right} \zeropoint} - - \expanded - {\definelayout - [\directsetup{fo:layout:kind}] - [ page={\directsetup{fo:layout:kind},\XMLval{fo:reference-orientation}{\XMLop{reference-orientation}}{}}, - paper=\directsetup{fo:layout:kind}, - backspace=\the\dimexpr(\FOscratchML+\FOscratchPS+\FOscratchRS), - cutspace=\the\dimexpr(\FOscratchMR+\FOscratchPE+\FOscratchRE), - topspace=\the\dimexpr(\FOscratchMT+\FOscratchPB+\FOscratchRB), - bottomspace=\the\dimexpr(\FOscratchMB+\FOscratchPA+\FOscratchRA)]} - - \expanded{\setuplayout[\directsetup{fo:layout:kind}]} - - % this is a nasty bit of code: this local setup stores some data that - % needs to be used later - - \startexpanded - \noexpand \startlocalsetups[layout:\directsetup{fo:layout:kind}] - \noexpand \writeFOstatus{processing simple page master '\XMLpar{fo:simple-page-master-do}{master-name}{any}'} - \noexpand \resetsetups[fo:simple-page-master:start] - \noexpand \resetsetups[fo:simple-page-master:stop] - \noexpand \flushXMLelement{fo:simple-page-master:\XMLpar{fo:simple-page-master-do}{master-name}{any}} - \noexpand \stoplocalsetups - \stopexpanded - -\stopsetups - -% \defineXMLcommand[fo:simple-page-master-do-do] -% {\writeFOstatus{setting up master \XMLop{master-name} in page body}} - -%D Element: fo:region-body - -% display-align=, -% reference-orientation=, -% writing-mode=, - -\defineXMLcommand % or process - [fo:region-body] - [\XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - fe:z-order=above, - clip=, - column-count=1, - column-gap=12pt, - overflow=, - region-name=] - {\directsetup{fo:region-body:process}} - -\startsetups fo:region-body:process - \writeFOstatus{refreshing region-body parameters} -\stopsetups - -% todo: naar realfolio handelen ipv folio - -\mapXMLvalue {fo:odd-or-even} {odd} {odd} -\mapXMLvalue {fo:odd-or-even} {even} {even} - -\mapXMLvalue {fo:page-position} {any} {rest} % todo -\mapXMLvalue {fo:page-position} {first} {current} -\mapXMLvalue {fo:page-position} {last} {last} % todo -\mapXMLvalue {fo:page-position} {rest} {rest} % todo - -%mapXMLvalue {fo:blank-or-not-blank} {any} {} % todo -%mapXMLvalue {fo:blank-or-not-blank} {not-blank} {} % todo -%mapXMLvalue {fo:blank-or-not-blank} {blank} {} % todo - -% check this one esp default value - -\startsetups fo:layout:kind - - \XMLpav - {fo:odd-or-even} - {fo:conditional-page-master-reference} - {odd-or-even} - {\XMLpav - {fo:page-position} - {fo:conditional-page-master-reference} - {page-position} - {\XMLpar{fo:page-sequence-master}{master-reference}{any}}} - -\stopsetups - -% common border things - -% clip -% display-align -% extent -% overflow -% precedence -% region-name -% reference-orientation -% writing-mode - -%D Element: fo:region-before fo:region-after fo:region-start fo:region-end - -% border-before-color : | inherit -% border-before-style : | inherit -% border-before-width.length|conditional : | | inherit -% -% style: none hidden dotted dashed solid double groove ridge inset outset -% width: thin medium thick length - -\mapXMLvalue {fo:display-align} {auto} {before} % todo: related to relative-align -\mapXMLvalue {fo:display-align} {before} {high} -\mapXMLvalue {fo:display-align} {after} {low} -\mapXMLvalue {fo:display-align} {center} {lohi} - -% display-align=, -% reference-orientation=, -% writing-mode=, - -\defineXMLcommand % will become process when stable - [fo:region-before] - [\XMLattributeset{fo:border-padding-background}, - clip=, - extent=, - overflow=, - precedence=, - region-name=] - {\directsetup{fo:region-before:process}} - -\startsetups fo:region-before:process - \writeFOstatus{refreshing region-before parameters} -\stopsetups - -\defineXMLprocess - [fo:region-after] - [\XMLattributeset{fo:border-padding-background}, - clip=, - extent=, - overflow=, - precedence=, - region-name=] - -\defineXMLprocess - [fo:region-start] - [\XMLattributeset{fo:border-padding-background}, - clip=, - extent=, - overflow=, - region-name=] - -\defineXMLprocess - [fo:region-end] - [\XMLattributeset{fo:border-padding-background}, - clip=, - extent=, - overflow=, - region-name=] - -\mapXMLvalue {fo:border-style} {none} {0} -\mapXMLvalue {fo:border-style} {hidden} {1} -\mapXMLvalue {fo:border-style} {dotted} {2} -\mapXMLvalue {fo:border-style} {dashed} {3} -\mapXMLvalue {fo:border-style} {solid} {4} -\mapXMLvalue {fo:border-style} {double} {5} -\mapXMLvalue {fo:border-style} {groove} {6} -\mapXMLvalue {fo:border-style} {ridge} {7} -\mapXMLvalue {fo:border-style} {inset} {8} -\mapXMLvalue {fo:border-style} {outset} {9} - -\mapXMLvalue {fo:border-width} {thin} {.25pt} -\mapXMLvalue {fo:border-width} {medium} {.5pt} -\mapXMLvalue {fo:border-width} {thick} {1pt} - -\startsetups fo:regions:check - - \startprocesscommalist[body,before,after,start,end] - - \checkFOborder{fo:region-\currentcommalistitem}{bottom} - \checkFOborder{fo:region-\currentcommalistitem}{top} - \checkFOborder{fo:region-\currentcommalistitem}{left} - \checkFOborder{fo:region-\currentcommalistitem}{right} - - \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-bottom-color}{}] - \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-top-color}{}] - \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-left-color}{}] - \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{border-right-color}{}] - \checkhexcolor[\XMLpar{fo:region-\currentcommalistitem}{background-color}{}] - - \checkFOposition{fo:region-\currentcommalistitem}{background} - \checkFOpadding {fo:region-\currentcommalistitem} - \checkFOmargin {fo:region-\currentcommalistitem} - - \stopprocesscommalist - -\stopsetups - -%D Element: fo:flow - -\defineXMLenvironment - [fo:flow] - [\XMLattributeset{fo:inherited}, - flow-name=unknown] - {\beginXMLelement\directsetup{fo:flow:start}} - {\directsetup{fo:flow:stop}\endXMLelement} - -\startsetups fo:flow:start - \begingroup -\stopsetups - -\startsetups fo:flow:stop - \endgroup -\stopsetups - -%D Element: fo:static-content - -% \beginXMLelement \endXMLelement - maybe save with attributes - -\defineXMLenvironmentsave - [fo:static-content] - [flow-name=unknown] - {} - {\directsetup{fo:static-content:process}} - -\startsetups fo:static-content:process - - \gsaveXMLdata{fo:static-content:\XMLop{flow-name}}{fo:static-content} - -\stopsetups - -\newdimen\FOscratchML \newdimen\FOscratchMR \newdimen\FOscratchMT \newdimen\FOscratchMB -\newdimen\FOscratchPB \newdimen\FOscratchPA \newdimen\FOscratchPS \newdimen\FOscratchPE -\newdimen\FOscratchRB \newdimen\FOscratchRA \newdimen\FOscratchRS \newdimen\FOscratchRE - -\mapXMLvalue {fo:background-repeat} {no-repeat} {0} -\mapXMLvalue {fo:background-repeat} {repeat} {1} -\mapXMLvalue {fo:background-repeat} {repeat-x} {2} -\mapXMLvalue {fo:background-repeat} {repeat-y} {3} - -\expanded {\mapXMLvalue {fo:background-location} {left} {0\letterpercent}} -\expanded {\mapXMLvalue {fo:background-location} {right} {100\letterpercent}} -\expanded {\mapXMLvalue {fo:background-location} {top} {0\letterpercent}} -\expanded {\mapXMLvalue {fo:background-location} {bottom} {100\letterpercent}} -\expanded {\mapXMLvalue {fo:background-location} {center} {50\letterpercent}} - -\newdimen\FObgpositionH -\newdimen\FObgpositionV - -\def\FObackgroundimage#1#2#3% - {\doifnot{\XMLpar{fo:#1}{background-image}{none}}{none} - {\setFOimagename{\XMLpar{fo:#1}{background-image}{dummy}}% - \FObgpositionH#2% - \setpercentdimen\FObgpositionH{\XMLpav - {fo:background-location} - {fo:#1} - {background-position-horizontal} - {\XMLpar{fo:#1}{background-position-horizontal}{}}}% - \ifpercentdimendone - \skip0\zeropoint plus \FObgpositionH - \skip2\zeropoint plus \dimexpr(#2-\FObgpositionH)% - \else - \skip0\FObgpositionH - \skip2\zeropoint plus 1fill\relax - \fi - \FObgpositionV#3% - \setpercentdimen\FObgpositionV{\XMLpav - {fo:background-location}{fo:#1}{background-position-vertical} - {\XMLpar{fo:#1}{background-position-vertical}{}}}% - \ifpercentdimendone - \skip4\zeropoint plus \FObgpositionV - \skip6\zeropoint plus \dimexpr(#3-\FObgpositionV)% - \else - \skip4\FObgpositionV - \skip6\zeropoint plus 1fill\relax - \fi - \vbox to #3 \bgroup - \vskip\skip4\relax - \hbox to #2 \bgroup - \hskip\skip0\relax - \backgroundimage - {\XMLpav{fo:background-repeat}{fo:#1}{background-repeat}{}}{#2}{#3}% - {\externalfigure - [\FOimagename] - [width=\XMLpar{fo:#1}{fe:background-width}{}, - height=\XMLpar{fo:#1}{fe:background-height}{}]}% - \hskip\skip2\relax - \egroup - \vskip\skip6\relax - \egroup}} - -\def\checkFOclipping#1% - {\doifsomething{\XMLpar{#1}{clip}{}} - {\analyzefunction{\XMLpar{#1}{clip}{}}% - \doif\functionname{rect} - {\def\postprocessframebox##1% - {\edef\next{\dimen0=\the\wd##1\dimen2=\the\ht##1\dimen4=\the\dp##1}% - \setbox##1\hbox - {\clip % expanded? - [topoffset=-\functionA, - bottomoffset=-\functionC, - leftoffset=-\functionD, - rightoffset=-\functionB] - {\box##1}}% - \next}}}} - -\def\clipFOarea#1% - {\doifsomething{\XMLpar{#1}{clip}{}}% - {\analyzefunction{\XMLpar{#1}{clip}{}}% - \doif\functionname{rect} - {\setbox\scratchbox\hbox{\foregroundbox}% - \edef\next{\dimen0=\the\wd\scratchbox\dimen2=\the\ht\scratchbox\dimen4=\the\dp\scratchbox}% - \setbox\scratchbox\hbox - {\clip % expanded? - [topoffset=-\functionA, - bottomoffset=-\functionC, - leftoffset=-\functionD, - rightoffset=-\functionB] - {\box\scratchbox}}% - \next - \box\scratchbox}}} - -\defineoverlay - [text] - [\clipFOarea{fo:region-body}] - -\setupbackgrounds - [text] - [background=text] - -\def\FOregionbuilder#1#2#3#4#5#6% #1=location #2=preset #3=x #4=y #5=width #6=height - {\writeFOstatus{building region #1}% - \defineoverlay - [image] - [{\framed - [frame=off, - orientation=\XMLpav{fo:reference-orientation}{fo:#1}{reference-orientation}{0}, - offset=overlay, - height=\overlayheight, - width=\overlaywidth] - {\FObackgroundimage{#1}\hsize\vsize}}]% - \setlayerframed - [regions] - [preset=#2,x=\dimexpr(#3),y=\dimexpr(#4)] - [frame=off, - offset=overlay,background={#1-graphic,image,xsl-#1}, - width=\dimexpr(#5),height=\dimexpr(#6)] - {\lrtbbox - {\XMLpar{fo:#1}{padding-left}\zeropoint}% - {\XMLpar{fo:#1}{padding-right}\zeropoint}% - {\XMLpar{fo:#1}{padding-top}\zeropoint}% - {\XMLpar{fo:#1}{padding-bottom}\zeropoint}% - {\checkFOclipping{fo:#1}% - \framed - [frame=off, - offset=overlay, - orientation=\XMLpav{fo:reference-orientation}{fo:#1}{reference-orientation}{0}, - align={\XMLpav{fo:display-align}{fo:#1}{display-align}{high},\XMLpav{fo:align-key}{fo:#1}{text-align}{normal}}, - width=\hsize,height=\vsize] - {\doFObeforeskip{fo:#1}% - \flushXMLelement{fo:static-content:\XMLpar{fo:#1}{region-name}{xsl-#1}}}% - \doFOafterskip{fo:#1}}}} - -\startsetups fo:regions:process - - \directsetup{fo:regions:check} - - \checkFOmargin{fo:simple-page-master-do} - - \FOscratchMT\paperheight \setpercentdimen\FOscratchMT{\XMLpar{fo:simple-page-master-do}{margin-top} \zeropoint} - \FOscratchMB\paperheight \setpercentdimen\FOscratchMB{\XMLpar{fo:simple-page-master-do}{margin-bottom}\zeropoint} - \FOscratchML\paperwidth \setpercentdimen\FOscratchML{\XMLpar{fo:simple-page-master-do}{margin-left} \zeropoint} - \FOscratchMR\paperwidth \setpercentdimen\FOscratchMR{\XMLpar{fo:simple-page-master-do}{margin-right} \zeropoint} - - \doif{\XMLpar{fo:region-body}{fe:z-order}{above}}{below}{\directsetup{fo:regions:process:body}} - - \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-before}{extent}\zeropoint} - \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-after} {extent}\zeropoint} - \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-start} {extent}\zeropoint} - \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-end} {extent}\zeropoint} - - \doifelse{\XMLpar{fo:region-before}{precedence}{false}}{true} - {\doifelse{\XMLpar{fo:region-after}{precedence}{false}}{true} - {\directsetup{fo:regions:process:true:true}} - {\directsetup{fo:regions:process:true:false}}} - {\doifelse{\XMLpar{fo:region-after}{precedence}{false}}{true} - {\directsetup{fo:regions:process:false:true}} - {\directsetup{fo:regions:process:false:false}}} - - \doif{\XMLpar{fo:region-body}{fe:z-order}{above}}{above}{\directsetup{fo:regions:process:body}} - -\stopsetups - -\newdimen\FOscratchEB -\newdimen\FOscratchEA - -\chardef\FOregionmode\zerocount - -\startmode[fo-pt] - \chardef\FOregionmode\plusone % fotex mode -) -\stopmode - -\startsetups fo:regions:modes - - \ifcase\FOregionmode - \FOscratchEB\zeropoint - \FOscratchEA\zeropoint - \or - \FOscratchEB\paperheight \setpercentdimen\FOscratchEB{\XMLpar{fo:region-before}{extent}\zeropoint} - \FOscratchEA\paperheight \setpercentdimen\FOscratchEA{\XMLpar{fo:region-after} {extent}\zeropoint} - \else - \FOscratchEB\zeropoint - \FOscratchEA\zeropoint - \fi - -\stopsetups - -\startsetups fo:regions:process:body - - \bgroup - - \FOscratchRB\paperheight \setpercentdimen\FOscratchRB{\XMLpar{fo:region-body}{margin-top} \zeropoint} - \FOscratchRA\paperheight \setpercentdimen\FOscratchRA{\XMLpar{fo:region-body}{margin-bottom}\zeropoint} - \FOscratchRS\paperwidth \setpercentdimen\FOscratchRS{\XMLpar{fo:region-body}{margin-left} \zeropoint} - \FOscratchRE\paperwidth \setpercentdimen\FOscratchRE{\XMLpar{fo:region-body}{margin-right} \zeropoint} - - \FOregionbuilder - {region-body} - {lefttop} - {\FOscratchML+\FOscratchRS} - {\FOscratchMT+\FOscratchRA} - {\paperwidth -\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE} - {\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB-\FOscratchRA} - - \egroup - -\stopsetups - -\startsetups fo:regions:process:true:true - - \directsetup{fo:regions:modes} - - \ifdim\FOscratchRB>\zeropoint \FOregionbuilder - {region-before}{lefttop} - {\FOscratchML}{\FOscratchMT-\FOscratchEB} - {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRB} - \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder - {region-after}{leftbottom} - {\FOscratchML}{\FOscratchMB-\FOscratchEA} - {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRA} - \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder - {region-start}{lefttop} - {\FOscratchML}{\FOscratchMT+\FOscratchRB} - {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRA-\FOscratchRB} - \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder - {region-end}{righttop} - {\FOscratchMR}{\FOscratchMT+\FOscratchRA} - {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRA-\FOscratchRB} - \fi - -\stopsetups - -\startsetups fo:regions:process:false:true - - \directsetup{fo:regions:modes} - - \ifdim\FOscratchRB>\zeropoint \FOregionbuilder - {region-before}{lefttop} - {\FOscratchML+\FOscratchRS}{\FOscratchMT-\FOscratchEB} - {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRB} - \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder - {region-after}{leftbottom} - {\FOscratchML}{\FOscratchMB-\FOscratchEA} - {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRA} - \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder - {region-start}{lefttop} - {\FOscratchML}{\FOscratchMT} - {\FOscratchRS}{\paperheight-\FOscratchMB-\FOscratchRA-\FOscratchRB} - \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder - {region-end}{righttop} - {\FOscratchMR}{\FOscratchMT} - {\FOscratchRE}{\paperheight-\FOscratchMB-\FOscratchRA-\FOscratchRB} - \fi - -\stopsetups - -\startsetups fo:regions:process:true:false - - \directsetup{fo:regions:modes} - - \ifdim\FOscratchRB>\zeropoint \FOregionbuilder - {region-before}{lefttop} - {\FOscratchML}{\FOscratchMT-\FOscratchEB} - {\paperwidth-\FOscratchML-\FOscratchMR}{\FOscratchRB} - \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder - {region-after}{leftbottom} - {\FOscratchML+\FOscratchRS}{\FOscratchMB-\FOscratchEA} - {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRA} - \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder - {region-start}{lefttop} - {\FOscratchML}{\FOscratchMT+\FOscratchRB} - {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB} - \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder - {region-end}{righttop} - {\FOscratchMR}{\FOscratchMT+\FOscratchRA} - {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB-\FOscratchRB} - \fi - -\stopsetups - -\startsetups fo:regions:process:false:false - - \directsetup{fo:regions:modes} - - \ifdim\FOscratchRB>\zeropoint \FOregionbuilder - {region-before}{lefttop} - {\FOscratchML+\FOscratchRS}{\FOscratchMT-\FOscratchEB} - {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRB} - \fi \ifdim\FOscratchRA>\zeropoint \FOregionbuilder - {region-after}{leftbottom} - {\FOscratchML+\FOscratchRS}{\FOscratchMB-\FOscratchEA} - {\paperwidth-\FOscratchML-\FOscratchMR-\FOscratchRS-\FOscratchRE}{\FOscratchRA} - \fi \ifdim\FOscratchRS>\zeropoint \FOregionbuilder - {region-start}{lefttop} - {\FOscratchML}{\FOscratchMT} - {\FOscratchRS}{\paperheight-\FOscratchMT-\FOscratchMB} - \fi \ifdim\FOscratchRE>\zeropoint \FOregionbuilder - {region-end}{righttop} - {\FOscratchMR}{\FOscratchMT} - {\FOscratchRE}{\paperheight-\FOscratchMT-\FOscratchMB} - \fi - -\stopsetups - -\startsetups fo:before:each:page - - \writeFOstatus{setting up layout \currentlayout} - \directsetup{layout:\currentlayout} - \directsetup{fo:regions:process} - -\stopsetups - -\prependtoks - \directsetup{fo:before:each:page}% -\to \everybeforepagebody - -%D Element: fo:title - -% \XMLattributeset{fo:aural}, -% color=, -% line-height=, - -\defineXMLignore - [fo:title] - [\XMLattributeset{fo:inherited},\XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:margin-inline}, - visibility=] - -%D Element: fo:block - -\defineXMLenvironment - [fo:block] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:hyphenation}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:relative-position}, - \XMLattributeset{fo:keeps-and-breaks}, -% text-depth=, -% text-altitude=, - span=, - visibility=] - {\beginXMLelement\directsetup{fo:block:start}} - {\directsetup{fo:block:stop}\endXMLelement} - -\startsetups fo:block:start - - \endgraf - - \writeFOstatus{fo:block in line \the\inputlineno} - -\doif{\XMLpar{fo:block}{span}{}}{all}{\ifinsidecolumns \startcolumnsetspan[fo:set] \fi} - - \begingroup - - \directsetup{fe:setup} - - \directsetup{fo:break-and-space:before} - - \begingroup - - \setFOreference{fo:block} - - \increment\FOblocklevel - - \directsetup{fo:font:setup} - - % \setupinterlinespace % no, interferes with columnset and lineheight - - \directsetup{fo:line-height:setup} - - \directsetup{fo:indent:setup}% hier ? - - \doifsomething{\XMLop{background-color}} - {\checkhexcolor[\XMLop{background-color}] - \doifcolorelse{\XMLop{background-color}} - \donothing - {\setXMLpar{fo:block}{background-color}{}}} - - \doifsomething{\XMLop{color}} - {\checkhexcolor[\XMLop{color}] - \doifcolorelse{\XMLop{color}} - \donothing - {\setXMLpar{fo:block}{color}{}}} - - \doifsomething{\XMLop{background-color}} - {\expanded - {\definetextbackground - [FOattribute-\FOblocklevel] - [location=paragraph, - color=\XMLop{color}, - style=, - before=, - after=, - background=color, - backgroundcolor=\XMLop{background-color}]}} - - \endgraf - - \getvalue{startFOattribute-\FOblocklevel} - - \directsetup{fo:hyphenation:setup} - \directsetup{fo:align:setup} - \directsetup{fo:margin:setup} - - \doif{\XMLop{wrap-option}}{no-wrap} - {\obeylines} - - \doif{\XMLop{white-space-collapse}}{false} - {\obeyspaces} - - % todo : remember old one and do like fonts - - \directsetup{fo:textindent:setup} - -\stopsetups - -\startsetups fo:block:stop - - \endstrut \endgraf - - \getvalue{stopFOattribute-\FOblocklevel} - - \endgraf - - \endgroup - - \directsetup{fo:break-and-space:after} - - \endgroup - - \doif{\XMLpar{fo:block}{span}{}}{all}{\ifinsidecolumns \stopcolumnsetspan \fi} - -\stopsetups - -\startsetups fo:textindent:setup - - \edefXMLinh\xFOtextindent{text-indent} - - \doifsomething\xFOtextindent - {\scratchdimen\hsize - \setpercentdimen\scratchdimen\xFOtextindent - \expanded{\setupindenting[\the\scratchdimen]}} - -\stopsetups - -\indenting[always] % can be zero points - -% todo: map - -\mapXMLvalue {fo:break} {column} {\column} -\mapXMLvalue {fo:break} {page} {\page} -\mapXMLvalue {fo:break} {even-page} {\page[even]} -\mapXMLvalue {fo:break} {odd-page} {\page[odd]} - -% keep-together : either vbox or something \interlinepenalty\maxdimen ? -% -% nasty interference with accumulated skips - -\mapXMLvalue {fo:keep-next} {auto} {} -\mapXMLvalue {fo:keep-next} {always} {\nobreak} - -\mapXMLvalue {fo:keep-prev} {auto} {} -\mapXMLvalue {fo:keep-prev} {always} {\nobreak} - -\mapXMLvalue {fo:keep-start} {auto} {} -\mapXMLvalue {fo:keep-start} {always} {\interlinepenalty\maxdimen} - -\mapXMLvalue {fo:keep-stop} {auto} {} -\mapXMLvalue {fo:keep-stop} {always} {} - -\newskip\FOsavedlastskip - -\startsetups fo:break-and-space:before - - \XMLval{fo:break}{\XMLop{break-before}}{} - - \FOsavedlastskip \lastskip \ifdim\FOsavedlastskip>\zeropoint \vskip-\FOsavedlastskip \fi - - \XMLval{fo:keep-start}{\XMLop{keep-together}}\empty - \XMLval{fo:keep-start}{\XMLop{keep-together.within-column}}\empty - \XMLval{fo:keep-start}{\XMLop{keep-together.within-page}}\empty - - \XMLval{fo:keep-prev} {\XMLop{keep-with-previous}}\empty - \XMLval{fo:keep-prev} {\XMLop{keep-with-previous.within-column}}\empty - \XMLval{fo:keep-prev} {\XMLop{keep-with-previous.within-page}}\empty - - \ifdim\FOsavedlastskip>\zeropoint \vskip\FOsavedlastskip \fi - - \doFObeforeskip\currentXMLelement - -\stopsetups - -\startsetups fo:break-and-space:after - -% \doFOafterskip\currentXMLelement - - \FOsavedlastskip \lastskip \ifdim\FOsavedlastskip>\zeropoint \vskip-\FOsavedlastskip \fi - - \XMLval{fo:keep-stop}{\XMLop{keep-together}}\empty - \XMLval{fo:keep-stop}{\XMLop{keep-together.within-column}}\empty - \XMLval{fo:keep-stop}{\XMLop{keep-together.within-page}}\empty - - \XMLval{fo:keep-next}{\XMLop{keep-with-next}}\empty - \XMLval{fo:keep-next}{\XMLop{keep-with-next.within-column}}\empty - \XMLval{fo:keep-next}{\XMLop{keep-with-next.within-page}}\empty - - \ifdim\FOsavedlastskip>\zeropoint \vskip\FOsavedlastskip \fi - - \doFOafterskip\currentXMLelement - - \XMLval{fo:break}{\XMLop{break-after}}{} - -\stopsetups - -\startsetups fo:space:start - \doFOstartspace\currentXMLelement -\stopsetups - -\startsetups fo:space:end - \doFOendspace\currentXMLelement -\stopsetups - -\startsetups fo:indent:setup - - \doifsomething{\XMLop{start-indent}}{\advance\leftskip \XMLop{start-indent}\relax} - \doifsomething{\XMLop{end-indent}} {\advance\rightskip\XMLop{end-indent} \relax} - -% \FOattributeT -% \FOattributeR -% \FOattributeB -% \FOattributeL - - -\stopsetups - -\mapXMLvalue {fo:align} {center} {\raggedcenter} -\mapXMLvalue {fo:align} {left} {\raggedright} -\mapXMLvalue {fo:align} {right} {\raggedleft} -\mapXMLvalue {fo:align} {begin} {\raggedright} -\mapXMLvalue {fo:align} {start} {\raggedright} -\mapXMLvalue {fo:align} {end} {\raggedleft} - -\mapXMLvalue {fo:align-key} {center} {middle} -\mapXMLvalue {fo:align-key} {left} {flushleft} -\mapXMLvalue {fo:align-key} {right} {flushright} -\mapXMLvalue {fo:align-key} {begin} {flushleft} -\mapXMLvalue {fo:align-key} {start} {flushleft} -\mapXMLvalue {fo:align-key} {end} {flushright} - -\startsetups fo:align:setup - - \XMLval{fo:align}{\XMLop{text-align}}{} - -\stopsetups - -\startsetups fo:margin:setup - - \checkFOmargin{fo:block} - - \FOscratchML \XMLpar{fo:block}{margin-left} \zeropoint - \FOscratchMR \XMLpar{fo:block}{margin-right} \zeropoint - \FOscratchMT \XMLpar{fo:block}{margin-top} \zeropoint - \FOscratchMB \XMLpar{fo:block}{margin-bottom}\zeropoint - - \advance\leftskip \FOscratchML - \advance\rightskip\FOscratchMR - -\stopsetups - -% todo: font-stretch -% -% ultra-condensed -% extra-condensed -% condensed -% semi-condensed -% expanded -% extra-expanded -% ultra-expanded -% -% wider narrower - -\mapXMLvalue {fo:font-size} {xx-small} {\dFOfontsize0.58\dFOfontsize} -\mapXMLvalue {fo:font-size} {x-small} {\dFOfontsize0.69\dFOfontsize} -\mapXMLvalue {fo:font-size} {small} {\dFOfontsize0.83\dFOfontsize} -\mapXMLvalue {fo:font-size} {medium} {\relax} -\mapXMLvalue {fo:font-size} {large} {\dFOfontsize1.20\dFOfontsize} -\mapXMLvalue {fo:font-size} {x-large} {\dFOfontsize1.44\dFOfontsize} -\mapXMLvalue {fo:font-size} {xx-large} {\dFOfontsize1.73\dFOfontsize} - -\mapXMLvalue {fo:font-size} {smaller} {\dFOfontsize0.83\dFOfontsize} -\mapXMLvalue {fo:font-size} {larger} {\dFOfontsize1.20\dFOfontsize} - -\newdimen\dFOfontsize - -% evt class Times Helvetica - -\definefontsynonym [FO:Times] [Times-Roman] -\definefontsynonym [FO:Times:bold] [Times-Bold] -\definefontsynonym [FO:Times:italic] [Times-Italic] -\definefontsynonym [FO:Times:bold:italic] [Times-BoldItalic] - -\definefontsynonym [FO:Times:small-caps] [Times-Roman] -\definefontsynonym [FO:Times:bold:small-caps] [Times-Bold] -\definefontsynonym [FO:Times:italic:small-caps] [Times-Italic] -\definefontsynonym [FO:Times:bold:italic:small-caps] [Times-BoldItalic] - -\definefontsynonym [FO:Helvetica] [Helvetica] -\definefontsynonym [FO:Helvetica:bold] [Helvetica-Bold] -\definefontsynonym [FO:Helvetica:italic] [Helvetica-Italic] -\definefontsynonym [FO:Helvetica:bold:italic] [Helvetica-BoldItalic] - -\definefontsynonym [FO:Helvetica:small-caps] [Helvetica] -\definefontsynonym [FO:Helvetica:bold:small-caps] [Helvetica-Bold] -\definefontsynonym [FO:Helvetica:italic:small-caps] [Helvetica-Italic] -\definefontsynonym [FO:Helvetica:bold:italic:small-caps] [Helvetica-BoldItalic] - -\definefontsynonym [FO:Courier] [Courier] -\definefontsynonym [FO:Courier:bold] [Courier-Bold] -\definefontsynonym [FO:Courier:italic] [Courier-Oblique] -\definefontsynonym [FO:Courier:bold:italic] [Courier-BoldOblique] - -\definefontsynonym [FO:Courier:small-caps] [Courier] -\definefontsynonym [FO:Courier:bold:small-caps] [Courier-Bold] -\definefontsynonym [FO:Courier:italic:small-caps] [Courier-Oblique] -\definefontsynonym [FO:Courier:bold:italic:small-caps] [Courier-BoldOblique] - -\definefontsynonym [FO:Symbol] [ZapfDingbats] - -\definefontsynonym [FO:Computer-Modern-Typewriter] [ComputerModernMono] -\definefontsynonym [FO:Computer-Modern-Typewriter:italic] [ComputerModernMono-Slanted] - -\definefontsynonym [*Times Roman*] [Times] - -% nasty: no FO prefix - -\definefontsynonym [*serif*] [Times] -\definefontsynonym [*sans-serif*] [Helvetica] -\definefontsynonym [*monospace*] [Courier] - -\definefontsynonym [*cursive*] [Times] -\definefontsynonym [*fantasy*] [Helvetica] - -\definefontsynonym [*Arial*] [Helvetica] -\definefontsynonym [*Times Roman*] [Times] -\definefontsynonym [*Wingdings*] [ZapfDingbats] - -% \definefontsynonym [Computer-Modern-Typewriter] [ComputerModernMono] -% \definefontsynonym [monospace] [ComputerModernMono] - -\startsetups fo:fonts:reset - - \dFOfontsize=\bodyfontsize - - \def\FOfontsize {10pt}% {12pt} - \def\FOfontfamily {Times} - \def\FOfontweight {normal} - \def\FOfontstyle {normal} - \def\FOfontvariant {normal} - \def\FOfontsizeadjust{1} - - \def\FOtextdepth {} - \def\FOtextaltitude {} - \def\FOlineheight {} - - \def\FOfontdefinition{} - \def\FOfontname {} - -\stopsetups - -\def\FOfontdefinition{} -\def\FOfontname {} - -\directsetup{fo:fonts:reset} - -% test for \FOfontvariant: normal or else - -\def\setFOfontname - {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight:\FOfontstyle:\FOfontvariant}% - %\begingroup\infofont\xFOfontname]\endgroup - \doifelsefontsynonym\xFOfontname - {\let\FOfontname\xFOfontname} - {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight:\FOfontstyle}% - \doifelsefontsynonym\xFOfontname - {\let\FOfontname\xFOfontname} - {\edef\xFOfontname{FO:\FOfontfamily:\FOfontstyle}% - \doifelsefontsynonym\xFOfontname - {\let\FOfontname\xFOfontname} - {\edef\xFOfontname{FO:\FOfontfamily:\FOfontweight}% - \doifelsefontsynonym\xFOfontname - {\let\FOfontname\xFOfontname} - {\edef\xFOfontname{FO:\FOfontfamily}% - \doifelsefontsynonym\xFOfontname - {\let\FOfontname\xFOfontname} - {}}}}}} - -% \unprotected \def\doifelseFOfontsynonym#1#2#3#4#5% family weight style variant default -% {\edef\FOfontname -% {\ifcsname \??ff\fontclass FO:#1:#2:#3:#4\endcsname FO:#1:#2:#3:#4% -% \else\ifcsname\??ff\fontclass FO:#1:#2:#3\endcsname FO:#1:#2:#3% -% \else\ifcsname\??ff\fontclass FO:#1:#3\endcsname FO:#1:#3% -% \else\ifcsname\??ff\fontclass FO:#1:#2\endcsname FO:#1:#2% -% \else\ifcsname\??ff\fontclass FO:#1\endcsname FO:#1% -% \else #5% -% \fi\fi\fi\fi\fi}} - -\startsetups fo:font:family:check - - \doifelsefontsynonym{*\FOfontfamily*} - {\expandfontsynonym\FOfontfamily{*\FOfontfamily*}} - {} - -\stopsetups - -\let\FOfont\empty - -\startsetups fo:font:setup - - % todo: optimize, define fonts first time and do that global - - \edefXMLinh\xFOfont {font} - \edefXMLinh\xFOfontsize {font-size} - \edefXMLinh\xFOfontsizeadjust{font-size-adjust} - \edefXMLinh\xFOfontfamily {font-family} - \edefXMLinh\xFOfontweight {font-weight} - \edefXMLinh\xFOfontstyle {font-style} - \edefXMLinh\xFOfontvariant {font-variant} - -% \edef\xFOfont {\XMLpar{fo}{font}{}} -% \edef\xFOfontsize {\XMLpar{fo}{font-size}{}} -% \edef\xFOfontsizeadjust{\XMLpar{fo}{font-size-adjust}{}} -% \edef\xFOfontfamily {\XMLpar{fo}{font-family}{}} -% \edef\xFOfontweight {\XMLpar{fo}{font-weight}{}} -% \edef\xFOfontstyle {\XMLpar{fo}{font-style}{}} -% \edef\xFOfontvariant {\XMLpar{fo}{font-variant}{}} - - \donefalse - - \ifx\xFOfont\empty \else \ifx\xFOfont\relax \else - \let\FOfont\xFOfont - \checkFOfont\FOfont - \fi \fi - - \ifx\xFOfontsize\empty \else \ifx\xFOfontsize\FOfontsize \else - \let\FOfontsize\xFOfontsize - \doifXMLvalelse{fo:font-size}\FOfontsize - {\XMLval{fo:font-size}\FOfontsize\empty} - {\setpercentdimen\dFOfontsize\FOfontsize} - \fi \fi - - \ifx\xFOfontsizeadjust\empty \else - \doifelse\xFOfontsizeadjust{none} - {\def\FOfontsizeadjust{1}} - {\let\FOfontsizeadjust\xFOfontsizeadjust} - \fi - - \ifx\xFOfontfamily\empty \else \ifx\xFOfontfamily\FOfontfamily \else - \donetrue \let\FOfontfamily\xFOfontfamily \directsetup{fo:font:family:check} - \fi \fi - \ifx\xFOfontweight\empty \else \ifx\xFOfontweight\FOfontweight \else - \donetrue \let\FOfontweight\xFOfontweight - \fi \fi - \ifx\xFOfontstyle\empty \else \ifx\xFOfontstyle\FOfontstyle \else - \donetrue \let\FOfontstyle\xFOfontstyle - \fi \fi - \ifx\xFOfontvariant\empty \else \ifx\xFOfontvariant\FOfontvariant \else - \donetrue \let\FOfontvariant\xFOfontvariant - \fi \fi - - \ifdone - \setFOfontname - \ifx\FOfontname\empty % klopt dit - \edef\xFOfontdefinition{\purefontname{\font} at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} -% \let\xFOfontdefinition\empty - \else - \edef\xFOfontdefinition{\FOfontname\space at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} - \fi - \else - \edef\xFOfontdefinition{\purefontname{\font} at \the\dimexpr(\FOfontsizeadjust\dFOfontsize)} - \fi - - \ifx\xFOfontdefinition\empty \else - \ifx\FOfontdefinition\xFOfontdefinition - \else - \let\FOfontdefinition\xFOfontdefinition - \expanded{\definedfont[\FOfontdefinition]} - \fi - \fi - -\stopsetups - -\newdimen\dFOlineheight -\newdimen\dFOdepth -\newdimen\dFOaltitude - -\let\FOlineheight \empty -\let\FOtextdepth \empty -\let\FOtextaltitude\empty - -\startsetups fo:line-height:setup - - \edefXMLinh\xFOtextdepth {text-depth} - \edefXMLinh\xFOtextaltitude{text-altitude} - \edefXMLinh\xFOlineheight {line-height} - -% \edef\xFOtextdepth {\XMLpar{fo}{text-depth}{}} -% \edef\xFOtextaltitude{\XMLpar{fo}{text-altitude}{}} -% \edef\xFOlineheight {\XMLpar{fo}{line-height}{}} - - \ifx\xFOtextdepth\empty \else \ifx\xFOtextdepth\FOtextdepth \else - \let\FOtextdepth\xFOtextdepth - \doifnot\FOtextdepth{use-font-metrics} - {\setstrut \dFOdepth\strutdepth - \setpercentdimen\dFOdepth\FOtextdepth - \setupinterlinespace[mindepth=\dFOdepth]} - \fi \fi - - \ifx\xFOtextaltitude\empty \else \ifx\xFOtextaltitude\FOtextaltitude \else - \let\FOtextaltitude\xFOtextaltitude - \doifnot\FOtextaltitude{use-font-metrics} - {\setstrut \dFOaltitude\strutheight \advance\dFOaltitude\strutdepth - \setpercentdimen\dFOaltitude\FOtextaltitude - \setupinterlinespace[minheight=\dFOaltitude]} - \fi \fi - -\ifinsidecolumns \else - - \ifx\xFOlineheight\empty \else \ifx\xFOlineheight\FOlineheight \else - \let\FOlineheight\xFOlineheight - \doifelse\FOlineheight{normal} - {\dFOlineheight2.8ex - \setupinterlinespace[line=\dFOlineheight]} - {\doifnot\FOlineheight{use-font-metrics} - {\setstrut \dFOlineheight\strutheight \advance\dFOlineheight\strutdepth - \setpercentdimen\dFOlineheight\FOlineheight - \setupinterlinespace[line=\dFOlineheight]}} - \fi \fi - -\fi - -\stopsetups - -\let\orphanpenalty \clubpenalty -\let\orphanpenalties\clubpenalties - -\newcount\FOwidows \FOwidows =2 -\newcount\FOorphans \FOorphans=2 - -\mapXMLvalue {fo:hyphens} {false} {\nohyphens} -\mapXMLvalue {fo:hyphens} {true} {\dohyphens} - -\startsetups fo:hyphenation:setup - - \edefXMLinh\xFOhyphenate {hyphenate} - \edefXMLinh\xFOwidows {widows} - \edefXMLinh\xFOorphans {orphans} - -% \edef\xFOhyphenate {\XMLpar{fo}{hyphenate}{}} -% \edef\xFOwidows {\XMLpar{fo}{widows}{}} -% \edef\xFOorphans {\XMLpar{fo}{orphans}{}} - - \ifx\xFOhyphenate\empty \else - \XMLval{fo:hyphens}{\xFOhyphenate}\empty - \fi - \ifx\xFOwidows\empty \else \ifnum\xFOwidows=\FOwidows \else - \FOwidows\xFOwidows \setpenalties\widowpenalties\FOwidows\maxdimen - \fi \fi - \ifx\xFOorphans\empty \else \ifnum\xFOorphans=\FOorphans \else - \FOorphans\xFOorphans \setpenalties\clubpenalties\FOorphans\maxdimen - \fi \fi - - % hyphenation-character - -\stopsetups - -%D fo:block-container - -% todo: potential optimization: set fonts and spacing at container level - -% display-align=, -% intrusion-displace=, -% reference-orientation=, -% writing-mode=, - -\defineXMLenvironment - [fo:block-container] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:absolute-positioning}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:keeps-and-breaks}, - block-progression-dimension=, - inline-progression-dimension=, - clip=, - height=, - overflow=, - span=, - width=, - z-index=] - {\beginXMLelement\directsetup{fo:block-container:start}} - {\directsetup{fo:block-container:stop}\endXMLelement} - -\mapXMLvalue {fo:block-container:start} {absolute} {\directsetup{fo:block-container:start:pos}} -\mapXMLvalue {fo:block-container:start} {fixed} {\directsetup{fo:block-container:start:pos}} - -\mapXMLvalue {fo:block-container:stop} {absolute} {\directsetup{fo:block-container:stop:pos}} -\mapXMLvalue {fo:block-container:stop} {fixed} {\directsetup{fo:block-container:stop:pos}} - -\startsetups fo:block-container:start - - \XMLval{fo:block-container:start}{\XMLpar{fo:block-container}{absolute-position}{}}{} - - \setFOreference{fo:block-container} - -\stopsetups - -\startsetups fo:block-container:stop - - \XMLval{fo:block-container:stop}{\XMLpar{fo:block-container}{absolute-position}{}}{} - -\stopsetups - -% i need to figure out the details (specs are a bit fuzzy) - -% replaced, see position - -\newdimen\FOcontainerW \newdimen\FOcontainerX \newdimen\FOcontainerL \newdimen\FOcontainerR \newdimen\FOcontainerWW -\newdimen\FOcontainerH \newdimen\FOcontainerY \newdimen\FOcontainerT \newdimen\FOcontainerB \newdimen\FOcontainerHH - -\startsetups fo:block-container:start:pos - - % todo: textwidth -> region dimensions - - \begingroup % \forgetall - - \FOcontainerWW\textwidth - \FOcontainerHH\textheight - \def\FOlayername{\XMLpar{fo:flow}{flow-name}{xsl-region-body}} - - \iftracingFO \tracelayerstrue \fi - - \directsetup{fo:preset:layer} - - \setlayerframed - [\XMLpar{fo:flow}{flow-name}{xsl-region-body}] - [frame=off, - width=\FOcontainerW, - height=\FOcontainerH] - - \bgroup - -\stopsetups - -\startsetups fo:block-container:stop:pos - - \egroup - - \endgroup - -\stopsetups - -%D fo:bidi-override - -% \XMLattributeset{aural}, -% color=, -% direction=, -% letter-spacing=, -% line-height=, -% word-spacing=, - -\defineXMLenvironment - [fo:bidi-override] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:relative-position}, - score-spaces=, - unicode-bidi=] - {\beginXMLelement} - {\endXMLelement} - -% todo - -%D fo:character - -% \XMLattributeset{fo:aural}, -% color=, -% glyph-orientation-horizontal=, -% glyph-orientation-vertical=, -% line-height=, - -\defineXMLsingular - [fo:character] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:hyphenation}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - \XMLattributeset{fo:character}, - alignment-adjust=, - baseline-shift=, - dominant-baseline=, -% text-depth=, -% text-altitude=, - keep-with-next=, - keep-with-previous=, - score-spaces=, - visibility=] - {\directsetup{fo:character:process}} - -\mapXMLvalue {fo:vertical-align} {baseline} {\hbox} -\mapXMLvalue {fo:vertical-align} {sub} {\low} -\mapXMLvalue {fo:vertical-align} {super} {\high} -\mapXMLvalue {fo:vertical-align} {inherit} {\firstofoneargument} - -\startsetups fo:character:process - - % border - % font - % margin - % positioning - % baseline - % color - % depth and altitude - % keep-with - % lineheight - - \dontleavehmode \begingroup - - \directsetup{fe:setup} - \directsetup{fo:font:setup} - - \iftracingFO \ruledhbox \else \hbox \fi \bgroup - - \doifsomethingXMLop{vertical-align} - {\doifXMLvalelse{fo:vertical-align}{\XMLop{vertical-align}} - {\XMLval{fo:vertical-align}{\XMLop{vertical-align}}{}} - {\wordshiftamount\lineheight - \setpercentdimen\wordshiftamount{\XMLop{vertical-align}} - \shiftedword}} - - {\directsetup{fo:character:orient}} - - \egroup \endgroup - -\stopsetups - -\startsetups fo:character:orient - -% \rotate[rotation=-\XMLop{glyph-orientation-horizontal}] - - \doifsomethingXMLop{glyph-orientation-horizontal} - {\rotate[rotation=\XMLval{fo:reference-orientation}{\XMLop{glyph-orientation-horizontal}}{0}]} - {\XMLop{character}} - -\stopsetups - -%D fo:initial-property-set - -% \XMLattributeset{fo:aural}, -% color=, -% letter-spacing=, -% line-height=, -% text-transform=, -% word-spacing=, - -\defineXMLprocess - [fo:initial-property-set] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:relative-position}, - score-spaces=, - text-decoration=, - text-shadow=] - -%D fo:external-graphic - -\useMPlibrary[dum] - -% \XMLattributeset{fo:aural}, -% display-align=, -% height=, -% text-align=, - -\defineXMLenvironmentsave - [fo:external-graphic] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - block-progression-dimension=, - clip=, - content-height=, - content-type=, - content-width=, - dominant-baseline=, - height=, - inline-progression-dimension=, - keep-with-next=, - keep-with-previous=, - overflow=, - scaling=, - scaling-method=, - src=dummy, - width=] - {} - {\directsetup{fo:external-graphic:process}} - -\newdimen\FOgraphicwidth -\newdimen\FOgraphicheight - -\mapXMLvalue {external-graphic:align} {top} {\tbox} -\mapXMLvalue {external-graphic:align} {bottom} {\bbox} -\mapXMLvalue {external-graphic:align} {center} {\cbox} - -\startsetups fo:external-graphic:process - - \doifelsenothing{\XMLop{content-height}} - {\FOgraphicheight\zeropoint} - {\doifelse{\XMLop{content-height}}{scale-to-fit}% is this official ? - {\FOgraphicwidth\zeropoint} - {\doifelse{\XMLop{content-height}}{auto} - {\FOgraphicheight\zeropoint} - {\FOgraphicheight\lineheight - \setpercentdimen\FOgraphicheight{\XMLop{content-height}}}}} - - \doifelsenothing{\XMLop{content-width}} - {\FOgraphicwidth\zeropoint} - {\doifelse{\XMLop{content-width}}{scale-to-fit}% is this official ? - {\FOgraphicwidth\zeropoint} - {\doifelse{\XMLop{content-width}}{auto} - {\FOgraphicwidth\zeropoint} - {\FOgraphicwidth1em - \setpercentdimen\FOgraphicwidth {\XMLop{content-width}}}}} - - % leeg maken vars gaat ook goed, dan een \externalfigure - - % todo : height/width scale-to-fit: factor=... - - \setbox\scratchbox\hbox - {\setFOimagename{\XMLpar{fo:external-graphic}{src}{dummy}} - \ifdim\FOgraphicheight>\zeropoint - \ifdim\FOgraphicwidth>\zeropoint - \externalfigure[\FOimagename][height=\FOgraphicheight,width=\FOgraphicwidth] - \else - \externalfigure[\FOimagename][height=\FOgraphicheight] - \fi - \else - \ifdim\FOgraphicwidth>\zeropoint - \externalfigure[\FOimagename][width=\FOgraphicwidth] - \else - \externalfigure[\FOimagename] - \fi - \fi} - - \dontleavehmode \XMLval{external-graphic:align}{\XMLop{vertical-align}}{}{\box\scratchbox} - -\stopsetups - -%D fo:instream-foreign-object - -% like external-graphic, only no src - -% \XMLattributeset{fo:aural}, -% display-align=, -% line-height=, -% text-align=, - -\defineXMLprocess - [fo:instream-foreign-object] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - block-progression-dimension=, - clip=, - content-height=, - content-type=, - content-width=, - dominant-baseline=, - height=, - inline-progression-dimension=, - keep-with-next=, - keep-with-previous=, - overflow=, - scaling=, - scaling-method=, - width=] - -%D Element: fo:inline - -% \XMLattributeset{fo:aural}, -% line-height=, -% wrap-option=, -% color=, -% keep-together=, - -\defineXMLnestedenvironmentsave - [fo:inline] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - block-progression-dimension=, - dominant-baseline=, - height=, - inline-progression-dimension=, - keep-with-next=, - keep-with-previous=, - text-decoration=, - visibility=, - width=] - {\beginXMLelement} - {\directsetup{fo:inline:process}\endXMLelement} - -\defineXMLsingular - [fo:inline] - {} - -% baseline-shift: baseline sub super % dimen inherit - -\chardef\isolatedwordsmode=1 - -\newdimen\wordshiftamount - -\def\shiftedword{\raise\wordshiftamount\hbox} - -\long\def\shiftedwords#1{\processisolatedwords{#1}\shiftedword} -\long\def\normalwords #1{\processisolatedwords{#1}\hbox} -\long\def\highwords #1{\processisolatedwords{#1}\high} -\long\def\lowwords #1{\processisolatedwords{#1}\low} - -\mapXMLvalue {fo:baseline-shift} {baseline} {\normalwords} -\mapXMLvalue {fo:baseline-shift} {sub} {\lowwords} -\mapXMLvalue {fo:baseline-shift} {super} {\highwords} -\mapXMLvalue {fo:baseline-shift} {inherit} {\firstofoneargument} - -\startsetups fo:inline:process - - \directsetup{fo:position:start} - - \dontleavehmode - - \doFOreference{fo:inline} - - \begingroup - - \directsetup{fe:setup} - \directsetup{fo:space:start} - - \begingroup - - \directsetup{fo:hyphenation:setup} - \directsetup{fo:font:setup} - - \doifelsenothing{\XMLop{baseline-shift}} - {\XMLflushself} - {\doifXMLvalelse{fo:baseline-shift}{\XMLop{baseline-shift}} - {\XMLval{fo:baseline-shift}{\XMLop{baseline-shift}}{}{\XMLflushself}} - {\wordshiftamount\lineheight - \setpercentdimen\wordshiftamount{\XMLop{baseline-shift}} - \shiftedwords{\XMLflushself}}} - - \endgroup - - \directsetup{fo:space:end} - - \endgroup - - \directsetup{fo:position:stop} - -\stopsetups - -\startsetups fo:position:start - \begingroup - \directsetup{fo:position:\XMLop{position}:start} - \begingroup -\stopsetups - -\startsetups fo:position:stop - \endgroup - \directsetup{fo:position:\XMLop{position}:stop} - \endgroup -\stopsetups - -\startsetups fo:position:static:start -\stopsetups - -\startsetups fo:position:static:stop -\stopsetups - -\startsetups fo:position:fixed:start - \FOcontainerWW\paperwidth - \FOcontainerHH\paperheight - \def\FOlayername{regions} - \directsetup{fo:preset:layer} - \setlayer[regions]{\vbox \bgroup \setlocalhsize} -\stopsetups - -\startsetups fo:position:fixed:stop - \egroup -\stopsetups - -\enableparpositions % slows down but who uses fo anyway ... - -\startsetups fo:position:absolute:start - \setbox\FOpositionbox\hbox\bgroup -\stopsetups - -\startsetups fo:position:absolute:stop - \egroup - % evt uitstellen tot otr, zodat text/realfolio is solved - \edef\FOpartag{p:\number\parposcounter} - \edef\FOtxttag{text:\realfolio} - \FOcontainerWW\MPplus\FOpartag{1}{0pt} - \FOcontainerHH\zeropoint % todo: add anchors to each 'object' - \directsetup{fo:preset:position} - \setlayer - [xsl-region-body] - [preset=lefttop, - hoffset=\dimexpr(\MPx\FOtxttag-\MPx\FOpartag), - voffset=\dimexpr(\MPy\FOtxttag+\MPh\FOtxttag-\MPy\FOpartag-\MPh\FOpartag)] - {\iftracingFO \ruledhbox \bgroup \fi - \offset - [method=fixed, - leftoffset=\FOcontainerL, - rightoffset=\FOcontainerR, - topoffset=\FOcontainerT, - bottomoffset=\FOcontainerB] - {\box\FOpositionbox} - \iftracingFO \egroup \fi} -\stopsetups - -\newbox\FOpositionbox - -\startsetups fo:position:relative:start - \setbox\FOpositionbox\hbox\bgroup -\stopsetups - -\startsetups fo:position:relative:stop - \egroup - \FOcontainerWW\wd\FOpositionbox - \FOcontainerHH\dimexpr(\ht\FOpositionbox+\dp\FOpositionbox) - \directsetup{fo:preset:position} - \iftracingFO \ruledhbox \bgroup \fi - \offset - [method=fixed, - leftoffset=\FOcontainerL, - rightoffset=\FOcontainerR, - topoffset=\FOcontainerT, - bottomoffset=\FOcontainerB] - {\box\FOpositionbox} - \iftracingFO \egroup \fi -\stopsetups - -% - -\startsetups fo:preset:position - - \FOcontainerW\zeropoint \FOcontainerL\zeropoint \FOcontainerR\zeropoint - \FOcontainerH\zeropoint \FOcontainerT\zeropoint \FOcontainerB\zeropoint - - \doifnot{\XMLop{left}} {auto}{\FOcontainerL\FOcontainerWW\setpercentdimen\FOcontainerL{\XMLop{left}}} - \doifnot{\XMLop{right}} {auto}{\FOcontainerR\FOcontainerWW\setpercentdimen\FOcontainerR{\XMLop{right}}} - \doifnot{\XMLop{top}} {auto}{\FOcontainerT\FOcontainerHH\setpercentdimen\FOcontainerT{\XMLop{top}}} - \doifnot{\XMLop{bottom}}{auto}{\FOcontainerB\FOcontainerHH\setpercentdimen\FOcontainerB{\XMLop{bottom}}} - - \doifnot{\XMLop{width}} {auto}{\FOcontainerW\FOcontainerWW\setpercentdimen\FOcontainerW{\XMLop{width}}} - \doifnot{\XMLop{height}}{auto}{\FOcontainerH\FOcontainerHH\setpercentdimen\FOcontainerH{\XMLop{height}}} - -\stopsetups - -\startsetups fo:preset:layer - - \directsetup{fo:preset:position} - - \setuplayer - [\FOlayername] - [width=\FOcontainerWW, - height=\FOcontainerHH] - - \ifzeropt\FOcontainerW - \FOcontainerW\dimexpr(\FOcontainerWW-\FOcontainerL-\FOcontainerR) - \fi - \ifzeropt\FOcontainerH - \FOcontainerH\dimexpr(\FOcontainerHH-\FOcontainerT-\FOcontainerB) - \fi - - \ifzeropt\FOcontainerB - \ifzeropt\FOcontainerL - \setuplayer[\FOlayername][preset=righttop, x=\FOcontainerR,y=\FOcontainerT] - \else - \setuplayer[\FOlayername][preset=lefttop, x=\FOcontainerL,y=\FOcontainerT] - \fi - \else - \ifzeropt\FOcontainerL - \setuplayer[\FOlayername][preset=rightbottom,x=\FOcontainerR,y=\FOcontainerB] - \else - \setuplayer[\FOlayername][preset=leftbottom, x=\FOcontainerL,y=\FOcontainerB] - \fi - \fi - -\stopsetups - -%D Element: fo:inline-container - -% display-align=, -% line-height=, -% reference-orientation=, -% writing-mode=, -% keep-together=, - -\defineXMLenvironment - [fo:inline-container] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - block-progression-dimension=, - clip=, - dominant-baseline=, - height=, - inline-progression-dimension=, - keep-with-next=, - keep-with-previous=, - overflow=, - width=] - {\beginXMLelement\begingroup} - {\endgroup\endXMLelement} - -%D Element: fo:leader - -% also a kind of fake fill - -% \XMLattributeset{fo:aural}, -% color=, -% line-height=, -% word-spacing=, - -\defineXMLenvironmentsave - [fo:leader] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - \XMLattributeset{fo:leader-and-rule}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - dominant-baseline=, - % text-depth=, - % text-altitude=, - keep-with-next=, - keep-with-previous=, - letter-spacing=, - text-shadow=, - visibility=] - {\beginXMLelement} - {\directsetup{fo:leader:process}\endXMLelement} - -\mapXMLvalue {fo:leader-pattern} {space} {\hfill} -\mapXMLvalue {fo:leader-pattern} {dots} {.} -\mapXMLvalue {fo:leader-pattern} {rule} {\hrulefill} -\mapXMLvalue {fo:leader-pattern} {use-content} {\XMLflushself} - -% todo: speed up - -\startsetups fo:leader:process - - %tracebackXMLattribute{leader-pattern-width} - - \strut \leaders - %edefXMLinh \FOlepatwd {leader-pattern-width} - \hbox to \XMLinh{leader-pattern-width} - {\hss\XMLval{fo:leader-pattern}{\XMLinh{leader-pattern}}{\hfill}\hss} - \hfill \strut - -\stopsetups - -%D Element: fo:pagenumber - -% \XMLattributeset{fo:aural}, -% line-height=, -% wrap-option=, -% letter-spacing=, -% text-transform=, -% word-spacing=, - -\defineXMLsingular - [fo:page-number] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - dominant-baseline=, - keep-with-next=, - keep-with-previous=, - score-spaces=, -% text-altitude=, - text-decoration=, -% text-depth=, - text-shadow=, - visibility=] - {\directsetup{fo:page-number:process}} - -\newcount\FOpnrefcounter - -\startsetups fo:page-number:process - - \doifelsenothing{\XMLpar{fo:page-sequence}{format}{}} - {\pagenumber} - {\ifinotr - \globallet\FOpnrefnumber\folio - \else - \global\advance\FOpnrefcounter\plusone - \pagereference[pnref:\the\FOpnrefcounter] - \doifreferencefoundelse{pnref:\the\FOpnrefcounter} - {\globallet\FOpnrefnumber\currentfolioreference} - {\globallet\FOpnrefnumber\folio} - \fi - \expanded{\handletokens\XMLpar{fo:page-sequence}{format}{}}\with{\handleFOformat{\FOpnrefnumber}}} - -\stopsetups - -\defineconversion[1][\numbers] - -\long\def\handleFOformat#1#2% - {\defconvertedargument\ascii{#2}% - \doifconversiondefinedelse\ascii{\convertnumber\ascii{#1}}{#2}} - -%D Element: fo:pagenumber-citation - -% same as page-number - -% \XMLattributeset{fo:aural}, -% line-height=, -% wrap-option=, -% letter-spacing=, -% text-transform=, -% word-spacing=, - -\defineXMLsingular - [fo:page-number-citation] - [\XMLattributeset{fo:inherited}, - id=, - ref-id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:font}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - dominant-baseline=, - keep-with-next=, - keep-with-previous=, - score-spaces=, -% text-altitude=, - text-decoration=, -% text-depth=, - text-shadow=, - visibility=] - {\directsetup{fo:page-number-citation:process}} - -\startsetups fo:page-number-citation:process - - \doifreferencefoundelse{\XMLop{ref-id}} - {\globallet\FOpnrefnumber\currentfolioreference - \globallet\FOpnrefformat\currenttextreference} - {\gdef\FOpnrefnumber{?} - \gdef\FOpnrefformat{}} - - \doifelsenothing{\FOpnrefformat} - {\FOpnrefnumber} - {\expanded{\handletokens\FOpnrefformat}\with{\handleFOformat{\FOpnrefnumber}}} - -\stopsetups - -%D Element: fo:table-and-caption - -% \XMLattributeset{fo:aural}, -% text-align=, -% caption-side=, -% intrusion-displace=, -% keep-together=, - -\defineXMLenvironment - [fo:table-and-caption] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:relative-position}, - break-after=, - break-before=, - keep-with-next=, - keep-with-previous=] - {\beginXMLelement} - {\endXMLelement} - -%D Element: fo:table fo:table-caption fo:table-header fo:table-footer -%D to:table-column fo:table-body fo:table-row fo:table-cell - -% \XMLattributeset{fo:aural}, -% border-collapse=, -% border-separation=, -% intrusion-displace=, -% keep-together=, -% writing-mode=, - -\defineXMLenvironment - [fo:table] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:relative-position}, - block-progression-dimension=, - border-after-precedence=, - border-before-precedence=, - border-start-precedence=, - border-end-precedence=, - break-after=, - break-before=, - inline-progression-dimension=, - height=, - keep-with-next=, - keep-with-previous=, - table-layout=, - table-omit-footer-at-break=, - table-omit-header-at-break=, -% text-indent=0pt, % yes or no? - width=] - {\beginXMLelement - \bTABLE % [option=stretch] % - \newcounter\FOtablecolumn} - {\eTABLE - \endXMLelement} - -\newdimen\FOtableW -\newdimen\FOtableH - -\defineXMLsingular - [fo:table-column] - [\XMLattributeset{fo:inherited}, - \XMLattributeset{fo:border-padding-background}, % only background, not the rest, make subset - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - column-width=, - column-number=, - number-columns-repeated=, - number-columns-spanned=, - visibility=] - {\directsetup{fo:table-column:action}} - -% \XMLattributeset{fo:aural}, -% intrusion-displace=, -% keep-together=, - -\defineXMLprocess - [fo:table-caption] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - block-progression-dimension=, - height=, - inline-progression-dimension=, - width=] - -% \XMLattributeset{fo:aural}, - -\defineXMLnested - [fo:table-header] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - visibility=] - {\beginXMLelement\bTABLEhead} - {\eTABLEhead\endXMLelement} - -% \XMLattributeset{fo:aural}, - -\defineXMLnested - [fo:table-footer] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - visibility=] - {\beginXMLelement\bTABLEfoot} - {\eTABLEfoot\endXMLelement} - -% \XMLattributeset{fo:aural}, - -\defineXMLnested - [fo:table-body] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - visibility=] - {\beginXMLelement\bTABLEbody} - {\eTABLEbody\endXMLelement} - -% TODO: when stretch and when not - -% \XMLattributeset{fo:aural}, -% keep-together=, - -\defineXMLnested - [fo:table-row] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - break-after=, - break-before=, - height=, - keep-with-next=, - keep-with-previous=, - visibility=] - {\beginXMLelement - \directsetup{fo:table-row:start}% - \expanded{\bTR[\the\scratchtoks]}% - \beginXMLelement} - {\endXMLelement - \eTR - \directsetup{fo:table-row:stop} - \endXMLelement} - -\startsetups fo:table-row:start - - \inTABLErowtrue - - \scratchtoks\emptytoks - - \doifsomething{\XMLop{height}} - {\FOtableH\textheight - \setpercentdimen\FOtableH{\XMLop{height}} - \appendetoks - height=\the\FOtableH - \to \scratchtoks} - - \appendetoks - ,extras={\rescanXMLattributes{fo:table-row}} - \to\scratchtoks - -\stopsetups - -\startsetups fo:table-row:stop - - \inTABLErowfalse - -\stopsetups - -% \XMLattributeset{fo:aural}, -% display-align=, -% relative-align=, -% empty-cells=, - -\newif\ifinTABLErow -\newdimen\FOtablecellwidth -\newdimen\FOtablecellheight - -\defineXMLnested - [fo:table-cell] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:relative-position}, - border-after-precedence=, - border-before-precedence=, - border-end-precedence=, - border-start-precedence=, - column-number=, - ends-row=, - height=, - inline-progression-dimension=, - number-columns-spanned=1, - number-rows-spanned=1, - starts-row=, - width=] - {\directsetup{fo:table-cell:start}% - \expanded{\bTD[\the\scratchtoks]}% - \beginXMLelement} - {\endXMLelement - \eTD - \directsetup{fo:table-cell:stop}} - -\startsetups fo:table-column:action - - \doifelsenothing{\XMLop{column-number}} - {\increment\FOtablecolumn} - {\edef\FOtablecolumn{\XMLop{column-number}} - \expanded{\setupTABLE[column][\FOtablecolumn][n=\FOtablecolumn]}} - - \doifsomething{\XMLop{column-width}} - {%\setlocalhsize - %\FOtableW\localhsize - \analyzefunction{\XMLop{column-width}}% - % hm, we need to set localhsize earlier - \doifelse\functionname{proportional-column-width} - {\FOtableW\functionA\textwidth} - {\FOtableW\textwidth - \setpercentdimen\FOtableW{\XMLop{column-width}}}% - \expanded{\setupTABLE[column][\FOtablecolumn][width=\the\FOtableW]}} - - \doif{\XMLop{border-style}}{none} - {\expanded{\setupTABLE[column][\FOtablecolumn][frame=off]}} - - \doifelsenothing{\XMLop{display-align}} - {\doifsomething{\XMLop{text-align}} - {\expanded{\setupTABLE[column][\FOtablecolumn] - [align=\XMLpav{fo:align-key}{fo:table-column}{text-align}{normal}]}}} - {\doifsomething{\XMLop{text-align}} - {\expanded{\setupTABLE[column][\FOtablecolumn] - [align={\XMLpav{fo:display-align}{fo:table-column}{display-align}{high},\XMLpav{fo:align-key}{fo:table-column}{text-align}{normal}}]}} - {\expanded{\setupTABLE[column][\FOtablecolumn] - [align=\XMLpav{fo:display-align}{fo:table-column}{display-align}{high}]}}} - -\expanded{\setupTABLE[column][\FOtablecolumn][extras={\rescanXMLattributes{fo:table-column}}]} - -\stopsetups - -\startsetups fo:table-cell:start - - \doif{\XMLop{starts-row}}{true}{\ifinTABLErow\eTR\inTABLErowfalse\fi} - - \ifinTABLErow\else\bTR\inTABLErowtrue\fi - - \doifelsenothing{\XMLop{background-color}} - {\let\FoTableBG\empty} - {\checkhexcolor[\XMLop{background-color}] - \doifcolorelse{\XMLop{background-color}} - {\def\FoTableBG{color}} - {\setXMLpar{fo:table-cell}{background-color}{} - \let\FoTableBG\empty}} - -% \doifelse{\XMLpar{fo:table-cell}{width}{}}{} -% {\def\pFOtablewidth{fit}} -% {\FOtablecellwidth\textwidth % probably must be localhsize or frozen at an outer level -% \setpercentdimen\FOtablecellwidth{\XMLpar{fo:table-cell}{width}{0pt}}% -% \edef\pFOtablewidth{\the\FOtablecellwidth}}% - -% \doifelse{\XMLpar{fo:table-cell}{height}{}}{} -% {\def\pFOtableheight{fit}} -% {\FOtablecellheight\textheight % probably must be localhsize or frozen at an outer level -% \setpercentdimen\FOtablecellheight{\XMLpar{fo:table-cell}{height}{0pt}}% -% \edef\pFOtableheight{\the\FOtablecellheight}}% - - \scratchtoks\emptytoks \appendetoks -% style=\noexpand\directsetup{fo:font:setup}, % else not expanded - nx=\XMLop{number-columns-spanned}, - ny=\XMLop{number-rows-spanned}, - n=\XMLop{column-number}, - background=\FoTableBG - \to \scratchtoks - - \doifnot{\XMLop{border-style}}{none} - {\appendetoks - ,frame=on - \to\scratchtoks} - - \doifsomething{\XMLop{background-color}} - {\appendetoks - ,backgroundcolor=\XMLop{background-color} - \to \scratchtoks} - - % todo : padding - - \doifsomething{\XMLop{padding}} - {\appendetoks - ,offset=\XMLop{padding} - \to \scratchtoks} - - % todo: interference with presets in column (outer level) -> \setupcolumn[column] ...; - % misschien meerdere align switches - - \doifelsenothing{\XMLop{display-align}} - {\doifsomething{\XMLop{text-align}} - {\appendetoks - ,align=\XMLpav{fo:align-key}{fo:table-cell}{text-align}{normal} - \to \scratchtoks}} - {\doifsomething{\XMLop{text-align}} - {\appendetoks - ,align={\XMLpav{fo:display-align}{fo:table-cell}{display-align}{high},\XMLpav{fo:align-key}{fo:table-cell}{text-align}{normal}}, - \to \scratchtoks} - {\appendetoks - ,align=\XMLpav{fo:display-align}{fo:table-cell}{display-align}{high} - \to \scratchtoks}} - - \appendetoks - ,extras={\rescanXMLattributes{fo:table-cell}} - \to\scratchtoks - -\stopsetups - -% \startsetups fo:table-cell:setup - -% [\XMLpar{fo:table-cell}{text-indent}{}] - -% \edefXMLinhpar\xFOtextindent{fo:table-cell}{text-indent} - -% \doifsomething\xFOtextindent -% {\scratchdimen\hsize -% \setpercentdimen\scratchdimen\xFOtextindent -% \expanded{\setupindenting[\the\scratchdimen]}} - -% \stopsetups - -\startsetups fo:table-cell:stop - - \doif{\XMLop{ends-row}}{true}{\eTR\inTABLErowfalse} - -\stopsetups - -%D Element: fo:list-block fo:list-item fo:list-body fo:list-item-label - -% \XMLattributeset{fo:aural}, -% intrusion-displace=, -% keep-together=, -% provisional-distance-between-starts=24pt, -% provisional-label-separation=6pt, - -\defineXMLenvironment - [fo:list-block] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:relative-position}, - break-after=, - break-before=, - keep-with-next=, -% space-between-list-rows=, % ? mentioned in bradley -text-indent=0pt, % yes - keep-with-previous=] - {\beginXMLelement\directsetup{fo:list:start}} - {\directsetup{fo:list:stop}\endXMLelement} - -\startsetups fo:list:start - \endgraf - \begingroup - \directsetup{fe:setup} - \disablemode[fo:in-list] - % \forgetall, no! -% \directsetup{fo:break-and-space:before} - \directsetup{fo:indent:setup} - \begingroup -\stopsetups - -\startsetups fo:list:stop - \endgraf - \endgroup -% \directsetup{fo:break-and-space:after} - \endgroup -\stopsetups - -% \XMLattributeset{fo:aural}, -% relative-align=, -% intrusion-displace=, -% keep-together=, - -% The list model is plain stupid. Instead of just defining a few mechanism -% or using some kind of type attribute, a strange mechanism of functions is -% used. Why on the one hand introduce redundant attributes and on the other -% hand safe a few elements. A proper segmentation of the problem would have -% brought better solutions. - -\defineXMLenvironment - [fo:list-item] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-block}, - \XMLattributeset{fo:relative-position}, - break-after=, - break-before=, - keep-with-next=, - keep-with-previous=] - {\beginXMLelement\directsetup{fo:list-item:start}} - {\directsetup{fo:list-item:stop}\endXMLelement} - -% check what is needed - -\newdimen\FOlistitemlabelhsize \newdimen\FOlistitembodyhsize \newdimen\FOlistitemdistance -\newdimen\FOlistitemlabelleftskip \newdimen\FOlistitembodyleftskip -\newdimen\FOlistitemlabelrightskip \newdimen\FOlistitembodyrightskip - -\defineXMLnestedsave - [fo:list-item-body] - [\XMLattributeset{fo:inherited}, - id=, % keep-together=, - \XMLattributeset{fo:accessibility}] - -\defineXMLnestedsave - [fo:list-item-label] - [\XMLattributeset{fo:inherited}, - id=, % keep-together=, - \XMLattributeset{fo:accessibility}] - -\startsetups fo:list-item:start - - \bgroup - -% \startmode[fo:in-list] -% \doifsomething{\XMLpar{fo:list-block}{space-between-list-rows}{}} -% {\vskip\XMLpar{fo:list-block}{space-between-list-rows}{}} % todo ! ! ! ! -% \stopmode - - \enablemode[fo:in-list] - -\stopsetups - -% todo : relative-align in list item - -\newif\ifFOlabelend -\newif\ifFObodystart - -\startsetups fo:list-item:stop - - % 24pt en 6pt in fo:root instellen - - % \tracebackXMLattribute{provisional-distance-between-starts} - - \edefXMLinh \FOprodis {provisional-distance-between-starts} - \edefXMLinh \FOprolab {provisional-label-separation} - -% \edef\FOprodis{\XMLpar{fo}{provisional-distance-between-starts}{}} -% \edef\FOprolab{\XMLpar{fo}{provisional-label-separation}{}} - - \edef\FOprodis{\ifx\FOprodis\empty24pt\else\FOprodis\fi} - \edef\FOprolab{\ifx\FOprolab\empty 6pt\else\FOprolab\fi} - - \setlocalhsize - - \FOlistitemlabelleftskip \zeropoint - \FOlistitemlabelrightskip\zeropoint - \FOlistitembodyleftskip \zeropoint - \FOlistitembodyrightskip \zeropoint - - \doifelse{\XMLpar{fo:list-item-label}{end-indent} {}}{label-end()} \FOlabelendtrue \FOlabelendfalse - \doifelse{\XMLpar{fo:list-item-body} {start-indent}{}}{body-start()}\FObodystarttrue\FObodystartfalse - - \setpercentdimen\FOlistitemlabelleftskip {\XMLpar{fo:list-item-label}{start-indent}{0pt}} - \setpercentdimen\FOlistitembodyrightskip {\XMLpar{fo:list-item-body} {end-indent} {0pt}} - - % maybe i need to implement something configurable - - \ifFObodystart - \ifFOlabelend - \FOlistitemlabelrightskip\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOprodis+\FOprolab) - \FOlistitembodyleftskip\dimexpr(\FOlistitemlabelleftskip+\FOprodis) - \FOlistitemlabelhsize\dimexpr(\FOprodis-\FOprolab) - \else - \setpercentdimen\FOlistitemlabelrightskip{\XMLpar{fo:list-item-label}{end-indent}{0pt}} - \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) - \FOlistitembodyleftskip\dimexpr(\FOlistitemlabelleftskip+\FOlistitemlabelhsize+\FOprolab) - \fi - \FOlistitemdistance \dimexpr(\FOprolab) - \else - \setpercentdimen\FOlistitembodyleftskip{\XMLpar{fo:list-item-body}{start-indent}{0pt}} - \ifFOlabelend - \FOlistitemlabelrightskip\dimexpr(\localhsize-\FOlistitembodyleftskip+\FOprolab) - \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) - \FOlistitemdistance \dimexpr(\FOprolab) - \else - \setpercentdimen\FOlistitemlabelrightskip{\XMLpar{fo:list-item-label}{end-indent}{0pt}} - \FOlistitemlabelhsize\dimexpr(\localhsize-\FOlistitemlabelleftskip-\FOlistitemlabelrightskip) - \FOlistitemdistance \dimexpr(\FOlistitembodyleftskip-\FOlistitemlabelleftskip-\FOlistitemlabelhsize) - \fi - \fi - - % is this fall back permitted ? - - \ifzeropt\FOlistitemlabelleftskip \ifzeropt\FOlistitemlabelrightskip - \FOlistitembodyleftskip\FOprodis - \FOlistitemdistance\FOprolab - \FOlistitemlabelhsize\dimexpr(\FOlistitembodyleftskip-\FOlistitemdistance) - \fi \fi - - % - - \FOlistitembodyhsize\localhsize - - \advance\FOlistitembodyhsize-\FOlistitembodyleftskip - \advance\FOlistitembodyhsize-\FOlistitembodyrightskip - - \doifelse{\XMLpar{fo:list-item}{display-align}{}}{center} - {\directsetup{fo:list-item:display}} - {\directsetup{fo:list-item:text}} - - \egroup - -\stopsetups - -% todo: textindent - -\startsetups fo:list-item:display - - \endgraf - - \advance\leftskip \FOlistitemlabelleftskip - \advance\rightskip\FOlistitembodyrightskip - - \dontleavehmode \valign\bgroup\forgetall\vss##\vss\cr - \iftracingFO\ruledvtop\else\vbox\fi{\hsize\FOlistitemlabelhsize\directsetup{fo:list-item-label:setup}\XMLflush{fo:list-item-label}}\cr - \iftracingFO\ruledvtop\else\vbox\fi{\hsize\FOlistitembodyhsize \directsetup{fo:list-item-body:setup}\XMLflush{fo:list-item-body}}\cr - \egroup - -% \dontleavehmode \placesidebyside % or maybe paired boxes (legends) -% {\ruledvtop{\forgetall\hsize\FOlistitemlabelhsize\XMLflush{fo:list-item-label}}} -% {\ruledvtop{\forgetall\hsize\FOlistitembodyhsize \XMLflush{fo:list-item-body}}} - - \endgraf - -\stopsetups - -\newtoks\savedeverypar \savedeverypar\everypar - -\startsetups fo:list-item:text - - \everypar\savedeverypar % \appendtoksonce\insertparagraphintro\to\everypar % hack, binnen footnote ... - - \advance\leftskip \FOlistitembodyleftskip - \advance\rightskip\FOlistitembodyrightskip - - \setupparagraphintro[first][\directsetup{fo:list-item-label:process}] - \setupparagraphintro[next] [\begstrut\resetpenalties\clubpenalties] - \directsetup{fo:list-item-body:setup} - \XMLflush{fo:list-item-body}\endstrut - -\stopsetups - -\startsetups fo:list-item-label:setups - - \edefXMLinhpar\xFOtextindent{fo:item-label}{text-indent} - - \doifsomething\xFOtextindent - {\scratchdimen\hsize - \setpercentdimen\scratchdimen\xFOtextindent - \expanded{\setupindenting[\the\scratchdimen]}} - -\stopsetups - -\startsetups fo:list-item-body:setups - - \edefXMLinh\xFOtextindent{fo:item-body}{text-indent} - - \doifsomething\xFOtextindent - {\scratchdimen\hsize - \setpercentdimen\scratchdimen\xFOtextindent - \expanded{\setupindenting[\the\scratchdimen]}} - -\stopsetups - -\newbox\FOitembox - -\startsetups fo:list-item-label:process - - \setbox \FOitembox \iftracingFO \ruledvtop \else \vtop \fi \bgroup - \forgetall - \postponenotes - \hsize\FOlistitemlabelhsize - \directsetup{fo:list-item-label:setup} - \XMLflush{fo:list-item-label} - \egroup - \getnoflines{\dimexpr(\ht\FOitembox+\dp\FOitembox)} - \setpenalties\clubpenalties\noflines\maxdimen - \strut\llap{\box\FOitembox\hskip\FOlistitemdistance} - -\stopsetups - -% \setlocalhsize \hsize\localhsize - -%D Element: fo:basic-link - -% \XMLattributeset{fo:aural}, -% keep-together=, -% line-height=, - -\defineXMLenvironmentsave - [fo:basic-link] - [\XMLattributeset{fo:inherited}, - id=, - \XMLattributeset{fo:accessibility}, - \XMLattributeset{fo:border-padding-background}, - \XMLattributeset{fo:margin-inline}, - \XMLattributeset{fo:relative-position}, - alignment-adjust=, - alignment-baseline=, - baseline-shift=, - destination-placement-offset=, - dominant-baseline=, - external-destination=, - indicate-destination=, - internal-destination=, - keep-with-next=, - keep-with-previous=, - show-destination=, - target-processing-context=, - target-presentation-context=, - target-stylesheet=] - {} - {\directsetup{fo:basic-link}} - -\startsetups fo:basic-link - - \goto{\XMLflushself}[unknown] - -\stopsetups - -%D Element: fo:multi-switch fo:multi-case fo:multi-toggle fo:multi-properties fo:multi-property-set - -\defineXMLprocess[fo:multi-switch] -\defineXMLprocess[fo:multi-case] -\defineXMLprocess[fo:multi-toggle] -\defineXMLprocess[fo:multi-properties] -\defineXMLprocess[fo:multi-property-set] - -%D Element: fo:float - -\defineXMLenvironmentsave - [fo:float] - [\XMLattributeset{fo:inherited}, - float=before, - clear=] - {} - {\directsetup{fo:float:process}} - -% clear: start end left right both none inherit -% float: before start end left right none - -\mapXMLvalue {fo:float-position} {before} {here} % todo -\mapXMLvalue {fo:float-position} {start} {here} % todo -\mapXMLvalue {fo:float-position} {end} {here} % todo -\mapXMLvalue {fo:float-position} {left} {left} -\mapXMLvalue {fo:float-position} {right} {right} -\mapXMLvalue {fo:float-position} {none} {here} % todo - -\startsetups fo:float:process - - \placefigure - [\XMLval{fo:float-position}{\XMLop{float}},none] - {} - {\XMLflushself} - -\stopsetups - -%D Element: fo:footnote fo:footnote-body - -% Let's assume that 'whatever' contains the number or footnote marker. -% -% whatevernote - -% todo xsl-footnote area - -\defineXMLprocess - [fo:footnote] - [\XMLattributeset{fo:accessibility}] - -\defineXMLargument - [fo:footnote-body] - [\XMLattributeset{fo:accessibility}] - {\footnote[-]} - -%D Element: fo:wrapper - -\defineXMLenvironment % todo: all inheritable - [fo:wrapper] - [\XMLattributeset{fo:inherited}, - \XMLattributeset{fe:tracing}, - \XMLattributeset{fo:fonts}, - \XMLattributeset{fo:hyphenation}] - {\beginXMLelement\begingroup\directsetup{fo:wrapper}} - {\endgroup\endXMLelement} - -\startsetups fo:wrapper - - \directsetup{fe:setup} - \directsetup{fo:hyphenation:setup} - \directsetup{fo:font:setup} - -\stopsetups - -%D Element: fo:marker fo:retrieve-marker - -% In order to support 'retrieve-boundary' (page, page-sequence, -% document) I need to extend the context mark handler. - -% This object will probably interfere with a too spacy layout since -% it is unaware if its surrounding. - -\defineXMLenvironmentsave - [fo:marker] - [marker-class-name=unknown] - {} - {\directsetup{fo:marker:process}} - -\startsetups fo:marker:process - - \doifelsemarking{fo:\XMLop{marker-class-name}} - {} {\definerawmarking[fo:\XMLop{marker-class-name}]} - - \expanded{\marking[fo:\XMLop{marker-class-name}]{\XMLflushself}} - -\stopsetups - -\defineXMLcommand - [fo:retrieve-marker] - [retrieve-class-name=unknown, - retrieve-position=first-starting-within-page, - retrieve-boundary=] - {\directsetup{fo:retrieve-marker:process}} - -\mapXMLvalue {fo:marker-position} {first-starting-within-page} {first} % first mark -\mapXMLvalue {fo:marker-position} {first-including-carryover} {previous} % top mark -\mapXMLvalue {fo:marker-position} {last-starting-within-page} {first} % dunno -\mapXMLvalue {fo:marker-position} {last-ending-within-page} {last} % bot mark - -\startsetups fo:retrieve-marker:process - - \expanded{\getmarking - [fo:\XMLop{retrieve-class-name}] - [\XMLval{fo:marker-position}{\XMLop{retrieve-position}}{first}]} - -\stopsetups - -%D Auxiliary macros - -\unprotect - -\long\def\noFOchecks#1\od{} - -\def\FOassignskip#1#2#3% - {\edef\!!stringa{\XMLpar{#1}{#2}\empty}% - \edef\!!stringb{\XMLpar{#1}{#2.optimum}\empty}% - \edef\!!stringc{\XMLpar{#1}{#2.minimum}\empty}% - \edef\!!stringd{\XMLpar{#1}{#2.maximum}\empty}% - \dimen0=\ifx\!!stringa\empty\zeropoint\else\!!stringa\fi - \dimen2=\ifx\!!stringb\empty\dimen0 \else\!!stringb\fi - \dimen4=\dimexpr(\ifx\!!stringd\empty\dimen0 \else\!!stringd\fi-\dimen2)\relax - \dimen6=\dimexpr(\ifx\!!stringc\empty\dimen0 \else\!!stringc\fi-\dimen2)\relax - #3=\dimen2 \ifzeropt\dimen4 \else\!!plus\dimen4 \fi\ifzeropt\dimen6 \else\!!minus\dimen6 \fi\relax} - -\mapXMLvalue{fo:space:conditionality} {retain} {\let\next\retainedskip } -\mapXMLvalue{fo:space:conditionality} {discard} {\let\next\discardedskip} -\mapXMLvalue{fo:space:conditionality} {} {\let\next\discardedskip} - -\mapXMLvalue{fo:space:precedence} {force} {\let\next\forcedskip} - -\def\FOdoskip#1#2% - {\begingroup - \iftracingFO\showskips\fi - \FOassignskip{#1}{#2}\scratchskip - \XMLval{fo:space:conditionality}{\XMLpar{#1}{#2.conditionality}\empty}\empty - \XMLval{fo:space:precedence}{\XMLpar{#1}{#2.precedence}\empty}\empty - \ifdim\scratchskip=\zeropoint - \ifdim\gluestretch\scratchskip=\zeropoint - \ifdim\glueshrink\scratchskip=\zeropoint - \let\next\gobbleoneargument - \fi - \fi - \fi - \next\scratchskip - \endgroup} - -\def\doFObeforeskip#1{\FOdoskip{#1}{space-before}} -\def\doFOafterskip #1{\FOdoskip{#1}{space-after}} - -\def\FOassignspace#1#2#3% - {\edef\!!stringa{\XMLpar{#1}{#2}\empty}% - \ifx\!!stringa\empty - #3=\zeropoint - \else - #3=1em% ? - \setpercentdimen#3\!!stringa - \fi - \relax} - -\def\FOdospace#1#2% - {\begingroup - \iftracingFO\showskips\fi - \FOassignspace{#1}{#2}\scratchskip - \ifdim\scratchskip=\zeropoint \else - \hskip\scratchskip - \fi - \endgroup} - -\def\doFOstartspace#1{\FOdospace{#1}{space-start}} -\def\doFOendspace #1{\FOdospace{#1}{space-end}} - -\def\checkFOborder#1#2% - {\edef\FOattribute{\XMLpar{#1}{border-#2}\empty}% - \ifx\FOattribute\empty\else - \edef\FOtag{#1}% - \edef\FOatt{border-#2}% - \expanded{\docheckFOborder\FOattribute\space\relax\space\relax}\od - \fi} - -\def\docheckFOborder#1#2 #3% - {\ifx#1\relax - \expandafter\noFOchecks - \else - \doifhexcolorelse{#1#2} - {\setXMLpar\FOtag{\FOatt-color}{#1#2}} - {\doifelsenothing{\XMLval{fo:border-style}{#1#2}\empty} - {\doifcolorelse{#1#2} - {\setXMLpar\FOtag{\FOatt-color}{#1#2}} - {\setXMLpar\FOtag{\FOatt-width}{#1#2}}} - {\setXMLpar\FOtag{\FOatt-style}{#1#2}}}% - \expandafter\docheckFOborder - \fi#3} - -\def\checkFOposition#1#2% - {\edef\FOattribute{\XMLpar{#1}{#2-position}\empty}% - \ifx\FOattribute\empty\else - \edef\FOtag{#1}% - \edef\FOatt{#2-position}% - \scratchcounter\zerocount - \expanded{\docheckFOposition\FOattribute\space\relax\space\relax}\od - \fi} - -\def\docheckFOposition#1#2 #3% - {\ifx#1\relax - \expandafter\noFOchecks - \else - \advance\scratchcounter\plusone - \ifcase\scratchcounter - \or - \setXMLpar\FOtag{\FOatt-vertical}{#1#2}% - \or - \setXMLpar\FOtag{\FOatt-horizontal}{#1#2}% - \fi - \expandafter\docheckFOposition - \fi#3} - -\def\checkFOpadding{\def\FOatt{padding}\checkFOquadruple} -\def\checkFOmargin {\def\FOatt{margin}\checkFOquadruple} - -\def\checkFOquadruple#1% - {\edef\FOattribute{\XMLpar{#1}\FOatt\empty}% - \ifx\FOattribute\empty\else - \edef\FOtag{#1}% - \scratchcounter\zerocount - \expanded{\docheckFOquadruple\FOattribute\space\relax\space\relax}\od - \ifcase\scratchcounter - \let\FOattributeT\FOattribute - \let\FOattributeR\FOattribute - \let\FOattributeB\FOattribute - \let\FOattributeL\FOattribute - \or % (tblr) - \let\FOattributeT\FOattribute - \let\FOattributeR\FOattribute - \let\FOattributeB\FOattribute - \let\FOattributeL\FOattribute - \or % (tb)(lr) - \let\FOattributeB\FOattributeT - \let\FOattributeL\FOattributeR - \or % (t)(lr)(b) - \let\FOattributeL\FOattributeR - \or % (t)(r)(b)(l) - % already ok - \fi - \letXMLpar\FOtag{\FOatt-top}\FOattributeT - \letXMLpar\FOtag{\FOatt-right}\FOattributeR - \letXMLpar\FOtag{\FOatt-bottom}\FOattributeB - \letXMLpar\FOtag{\FOatt-left}\FOattributeL - \fi} - -\def\docheckFOquadruple#1#2 #3% - {\ifx#1\relax - \expandafter\noFOchecks - \else - \advance\scratchcounter\plusone - \ifcase\scratchcounter - \or - \edef\FOattributeT{#1#2}% - \or - \edef\FOattributeR{#1#2}% - \or - \edef\FOattributeB{#1#2}% - \or - \edef\FOattributeL{#1#2}% - \fi - \expandafter\docheckFOquadruple - \fi#3} - -% \def\setFOimagename#1% -% {\edef\FOimagename{#1}% -% \aftersplitstring \FOimagename\at url('\to\xFOimagename -% \ifx\xFOimagename\empty \else -% \beforesplitstring\xFOimagename\at ')\to\FOimagename -% \fi -% \aftersplitstring \FOimagename\at url("\to\xFOimagename -% \ifx\xFOimagename\empty \else -% \beforesplitstring\xFOimagename\at ")\to\FOimagename -% \fi} -% -% let's overkill: - -\def\setFOimagename#1% - {\analyzefunction{#1}% - \doifelse\functionname{url} - {\edef\FOimagename{\@EA\unstringed\functionA}} - {\ifx\functionname\empty - \def\FOimagename{#1}% - \else - \def\FOimagename{dummy}% - \fi}} - -% font - -\mapXMLvalue {fo:weight} {normal} {} -\mapXMLvalue {fo:weight} {bold} {bold} -\mapXMLvalue {fo:weight} {bolder} {bold} -\mapXMLvalue {fo:weight} {lighter} {normal} -\mapXMLvalue {fo:weight} {100} {normal} -\mapXMLvalue {fo:weight} {200} {normal} -\mapXMLvalue {fo:weight} {300} {normal} -\mapXMLvalue {fo:weight} {400} {normal} -\mapXMLvalue {fo:weight} {500} {normal} -\mapXMLvalue {fo:weight} {600} {normal} -\mapXMLvalue {fo:weight} {700} {normal} -\mapXMLvalue {fo:weight} {800} {normal} -\mapXMLvalue {fo:weight} {900} {normal} - -\mapXMLvalue {fo:variant} {normal} {} -\mapXMLvalue {fo:variant} {small-caps} {small-caps} - -\mapXMLvalue {fo:style} {normal} {normal} -\mapXMLvalue {fo:style} {italic} {italic} -\mapXMLvalue {fo:style} {oblique} {oblique} -\mapXMLvalue {fo:style} {backslant} {normal} - -% we can get crap like: 10pt/1.5 bold "Times Roman" ; i'm really puzzled why an -% otherwise rather verbose coding occasionally packs attributes; a design flaw - -\newtoks\FOfonttoks - -\def\checkFOfontSS#1'{} -\def\checkFOfontDD#1"{} -\def\checkFOfontII#1 {} - -\bgroup -\catcode`\'=\active -\catcode`\"=\active -\catcode`\/=\active -\gdef\setcheckFOfontX - {\catcode`\'=\active - \catcode`\"=\active - \catcode`\/=\active - \def'##1'{\global\FOfonttoks\expandafter{\the\FOfonttoks\def\FOfontfamily{##1}}}% - \def"##1"{\global\FOfonttoks\expandafter{\the\FOfonttoks\def\FOfontfamily{##1}}}% - \def/##1 {}}% todo linespacing -\gdef\setcheckFOfontXX - {\catcode`\'=\active - \catcode`\"=\active - \catcode`\/=\active - \def'##1'{}% - \def"##1"{}% - \def/##1 {}}% todo linespacing -\egroup - -\globallet\xFOattribute\empty - -\def\checkFOfont#1% - {\FOfonttoks\emptytoks - \bgroup - \catcode`\\=\@@escape - \catcode`\{=\@@begingroup - \catcode`\}=\@@endgroup -% \catcode`\:=\@@letter -% \catcode`\-=\@@letter - \setcheckFOfontX - \xdef\xFOattribute{#1 }% - \setbox\scratchbox\hbox{\scantokens\@EA{\xFOattribute}}% - \setcheckFOfontXX - \scantokens\@EA{\@EA\xdef\@EA\xFOattribute\@EA{\xFOattribute}}% - \egroup - \the\FOfonttoks - \ifx\xFOattribute\empty\else - \expanded{\docheckFOfont\xFOattribute\space\relax\space\relax}\od - \fi - \directsetup{fo:font:family:check}} - -\def\docheckFOfont#1#2 #3% - {\ifx#1\relax - \expandafter\noFOchecks - \else - \directsetup{fo:fonts:reset}% - \doifelsefontsynonym{#1#2} - {\def\FOfontfamily{#1#2}} - {\doifelsenothing{\XMLval{fo:weight}{#1#2}{}} - {\doifelsenothing{\XMLval{fo:variant}{#1#2}{}} - {\doifelsenothing{\XMLval{fo:style}{#1#2}{}} - {\setpercentdimen\dFOfontsize{#1#2}} - {\edef\FOfontstyle{\XMLval{fo:style}{#1#2}{}}}} - {\edef\FOfontvariant{\XMLval{fo:variant}{#1#2}{}}}} - {\edef\FOfontweight{\XMLval{fo:weight}{#1#2}{}}}}% - \expandafter\docheckFOfont - \fi#3} - -\protect - -\newtoks\FOreferences - -\def\setFOreference#1% - {\doifsomething{\XMLpar{#1}{id}{}} - {\expanded{\appendtoks - \noexpand\reference[\XMLpar{#1}{id}{}]{\XMLpar{fo:page-sequence}{format}{}}}% - \to\FOreferences}} - -\def\flushFOreferences - {\the\FOreferences - \global\FOreferences\emptytoks} - -\def\doFOreference#1% - {\doifsomething{\XMLpar{#1}{id}{}} - {\expanded{\reference[\XMLpar{#1}{id}{}]{\XMLpar{fo:page-sequence}{format}{}}}}} - -\appendtoks \flushFOreferences \to \everypar -\appendtoks \flushFOreferences \to \neverypar % check ! - -%D Graphics: static frames - -\startMPinclusions - input mp-fobg.mp ; -\stopMPinclusions - -\def\unknownMPcolor{FoNoColor} - -% todo: combine into one en alleen tweede run, immers toch geen invloed; is -% aangezien de referentiepunten vast liggen - -\def\FoRegionWidth#1% - {\XMLpav - {fo:border-width} - {fo:region-\MPvar{location}} - {border-#1-width} - {FoMedium}} - -\def\FoRegionStyle#1% - {\XMLpav - {fo:border-style} - {fo:region-\MPvar{location}} - {border-#1-style} - {FoNone}} - -\def\FoRegionColor#1% - {\MPcolor{\XMLpar - {fo:region-\MPvar{location}} - {border-#1-color} - {black}}} - -\def\FoRegionBackgroundColor - {\MPcolor{\XMLpar - {fo:region-\MPvar{location}} - {background-color} - {FoNoColor}}} - -% todo: when connected and same color : one draw - -\startuseMPgraphic{region-do} - FoBackgroundColor := \FoRegionBackgroundColor ; - FoLineColor[FoTop] := \FoRegionColor{top} ; - FoLineColor[FoBottom] := \FoRegionColor{bottom} ; - FoLineColor[FoLeft] := \FoRegionColor{left} ; - FoLineColor[FoRight] := \FoRegionColor{right} ; - FoLineStyle[FoTop] := \FoRegionStyle{top} ; - FoLineStyle[FoBottom] := \FoRegionStyle{bottom} ; - FoLineStyle[FoLeft] := \FoRegionStyle{left} ; - FoLineStyle[FoRight] := \FoRegionStyle{right} ; - FoLineWidth[FoTop] := \FoRegionWidth{top} ; - FoLineWidth[FoBottom] := \FoRegionWidth{bottom} ; - FoLineWidth[FoLeft] := \FoRegionWidth{left} ; - FoLineWidth[FoRight] := \FoRegionWidth{right} ; - if FoBackgroundColor <> FoNoColor : - fill OverlayBox - withcolor FoBackgroundColor ; - fi ; - path OverlayFrameBox ; - interim linecap := butt ; - OverlayFrameBox := OverlayBox - topenlarged -.5FoLineWidth[FoTop] - bottomenlarged -.5FoLineWidth[FoBottom] - leftenlarged -.5FoLineWidth[FoLeft] - rightenlarged -.5FoLineWidth[FoRight] ; - DrawFoFrame(FoTop, topboundary OverlayFrameBox) ; - DrawFoFrame(FoBottom, bottomboundary OverlayFrameBox) ; - DrawFoFrame(FoLeft, leftboundary OverlayFrameBox) ; - DrawFoFrame(FoRight, rightboundary OverlayFrameBox) ; -\stopuseMPgraphic - -\startuseMPgraphic{region-body} \includeMPgraphic{region-do} \stopuseMPgraphic -\startuseMPgraphic{region-before} \includeMPgraphic{region-do} \stopuseMPgraphic -\startuseMPgraphic{region-after} \includeMPgraphic{region-do} \stopuseMPgraphic -\startuseMPgraphic{region-start} \includeMPgraphic{region-do} \stopuseMPgraphic -\startuseMPgraphic{region-end} \includeMPgraphic{region-do} \stopuseMPgraphic - -\startnotmode[fo-no-bg] - -\defineoverlay[region-body-graphic] [\useMPgraphic{region-body}{location=body}] -\defineoverlay[region-before-graphic][\useMPgraphic{region-before}{location=before}] -\defineoverlay[region-after-graphic] [\useMPgraphic{region-after}{location=after}] -\defineoverlay[region-start-graphic] [\useMPgraphic{region-start}{location=start}] -\defineoverlay[region-end-graphic] [\useMPgraphic{region-end}{location=end}] - -\stopnotmode - -% more efficient: todo: relocate and move to page background - -% \def\FoRegionWidth#1#2% -% {\XMLpav -% {fo:border-width} -% {fo:region-#2} -% {border-#1-width} -% {FoMedium}} - -% \def\FoRegionStyle#1#2% -% {\XMLpav -% {fo:border-style} -% {fo:region-#2} -% {border-#1-style} -% {FoNone}} - -% \def\FoRegionColor#1#2% -% {\MPcolor{\XMLpar -% {fo:region-#2} -% {border-#1-color} -% {black}}} - -% \def\FoRegionBackgroundColor#1% -% {\MPcolor{\XMLpar -% {fo:region-#1} -% {background-color} -% {FoNoColor}}} - -% \def\combinedFOgraphic#1% -% {FoBackgroundColor := \FoRegionBackgroundColor{#1} ; -% FoLineColor[FoTop] := \FoRegionColor{top}{#1} ; -% FoLineColor[FoBottom] := \FoRegionColor{bottom}{#1} ; -% FoLineColor[FoLeft] := \FoRegionColor{left}{#1} ; -% FoLineColor[FoRight] := \FoRegionColor{right}{#1} ; -% FoLineStyle[FoTop] := \FoRegionStyle{top}{#1} ; -% FoLineStyle[FoBottom] := \FoRegionStyle{bottom}{#1} ; -% FoLineStyle[FoLeft] := \FoRegionStyle{left}{#1} ; -% FoLineStyle[FoRight] := \FoRegionStyle{right}{#1} ; -% FoLineWidth[FoTop] := \FoRegionWidth{top}{#1} ; -% FoLineWidth[FoBottom] := \FoRegionWidth{bottom}{#1} ; -% FoLineWidth[FoLeft] := \FoRegionWidth{left}{#1} ; -% FoLineWidth[FoRight] := \FoRegionWidth{right}{#1} ; -% if FoBackgroundColor <> FoNoColor : -% fill OverlayBox -% withcolor FoBackgroundColor ; -% fi ; -% path OverlayFrameBox ; -% interim linecap := butt ; -% OverlayFrameBox := OverlayBox -% topenlarged -.5FoLineWidth[FoTop] -% bottomenlarged -.5FoLineWidth[FoBottom] -% leftenlarged -.5FoLineWidth[FoLeft] -% rightenlarged -.5FoLineWidth[FoRight] ; -% DrawFoFrame(FoTop, topboundary OverlayFrameBox) ; -% DrawFoFrame(FoBottom, bottomboundary OverlayFrameBox) ; -% DrawFoFrame(FoLeft, leftboundary OverlayFrameBox) ; -% DrawFoFrame(FoRight, rightboundary OverlayFrameBox) ;} - -% \startuseMPgraphic{region-body} -% \combinedFOgraphic{before} -% \combinedFOgraphic{body} -% \combinedFOgraphic{after} -% \combinedFOgraphic{start} -% \combinedFOgraphic{end} -% \stopuseMPgraphic - -% \defineoverlay[region-body-graphic] [\useMPgraphic{region-body}{location=body}] -% \defineoverlay[region-before-graphic][] -% \defineoverlay[region-after-graphic] [] -% \defineoverlay[region-start-graphic] [] -% \defineoverlay[region-end-graphic] [] - -\stopXMLcompiling - -\endinput - -% we can follow two approaches: set the attributes global, using -% -% \defineXML...[tag][prefix][empty] -% -% in that case we trust the fo-file to be correct, i.e. the xslt style -% sheets should not put attributes in the wrong places; however, we need -% to do that with care, since for instance the attributes of some objects -% (regions) are used mixed -% -% \defineXMLprocess [fo:root] [XMLFO] [test=unset] -% -% \defineXMLenvironment [fo:block-container] [XMLFO] -% {\begingroup} -% {\endgroup} -% -% \defineXMLenvironment [fo:block] [XMLFO] -% {\begingroup\getXMLparameters[XMLFO]\begingroup} -% {\endgroup\XMLFOtest\endgraf\endgroup} -% -% \startXMLdata -% -% second: -% unset: -% nested:outer: -% last: -% -% \stopXMLdata -% -% the other approach is to set the attributes explicitly for each -% element, which is slower but more robust -% -% A mix is: -% -% \defineXMLenvironment -% [fo:root] -% [test=unset] -% {\beginXMLelement} -% {\endXMLelement} -% -% \defineXMLenvironment -% [fo:block-container] -% [test=\XMLpar\XMLpureparent{test}{}] -% {\beginXMLelement} -% {\endXMLelement} -% -% \defineXMLenvironment -% [fo:block] -% [test=\XMLpar\XMLpureparent{test}{}] -% {\beginXMLelement -% \begingroup} -% {\endgroup -% \XMLpar{fo:block}{test}{} -% \endXMLelement} -% -% \startXMLdata -% -% second: -% unset: -% nested:outer: -% last: -% -% \stopXMLdata diff --git a/tex/context/base/x-foxet.mkii b/tex/context/base/x-foxet.mkii new file mode 100644 index 000000000..0f8e43af9 --- /dev/null +++ b/tex/context/base/x-foxet.mkii @@ -0,0 +1,28 @@ +%D \module +%D [ file=x-foxet, +%D version=2004.03.12, % based on earlier experiments +%D title=\FOXET, +%D subtitle=Formatting Objects, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module is just a shortcut for: + +% fo = basic formatting objects +% fe = basic formatting extensions +% fx = extra formatting objects +% fu = user formatting objects +% fs = setup + +\usemodule[fo,fe,fx,fu,fs,mathml] + +\usemodule[fp] % passivetex bonus + +% \autoXMLnamespace[mml,mm,mathml] + +\endinput diff --git a/tex/context/base/x-foxet.mkiv b/tex/context/base/x-foxet.mkiv new file mode 100644 index 000000000..b27969721 --- /dev/null +++ b/tex/context/base/x-foxet.mkiv @@ -0,0 +1,29 @@ +%D \module +%D [ file=x-foxet, +%D version=2004.03.12, % based on earlier experiments +%D title=\FOXET, +%D subtitle=Formatting Objects, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Nota bene: I will reimplement formatting object in proper +%D \MKIV\ code. + +\writestatus{foxet}{the mkiv variant is under construction} + +%D This module is just a shortcut for: + +% fo = basic formatting objects +% fe = basic formatting extensions +% fx = extra formatting objects +% fu = user formatting objects +% fs = setup + +% \usemodule[fo,fe,fx,fu,fs,mathml] + +\endinput diff --git a/tex/context/base/x-foxet.tex b/tex/context/base/x-foxet.tex deleted file mode 100644 index 78cc0efb7..000000000 --- a/tex/context/base/x-foxet.tex +++ /dev/null @@ -1,15 +0,0 @@ -%D This is just a shortcut for: - -% fo = basic formatting objects -% fe = basic formatting extensions -% fx = extra formatting objects -% fu = user formatting objects -% fs = setup - -\usemodule[fo,fe,fx,fu,fs,mathml] - -\usemodule[fp] % passivetex bonus - -% \autoXMLnamespace[mml,mm,mathml] - -\endinput diff --git a/tex/context/base/x-pending.mkiv b/tex/context/base/x-pending.mkiv new file mode 100644 index 000000000..114b81890 --- /dev/null +++ b/tex/context/base/x-pending.mkiv @@ -0,0 +1,38 @@ +%D \module +%D [ file=x-pending, +%D version=2008.04.04, +%D title=\CONTEXT\ Style File, +%D subtitle=Track \MKII\ \XML\ usage in \MKIV, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Including this module will result in the production of +%D a file \type {jobname-pending-xml.log} which has a +%D \LUA\ table with \XML\ elements that are still catched by +%D \MKII\ code, when enabled. + +\startluacode + local list = { } + function document.check_pending_xml_element(str) + list[str] = (list[str] and (list[str]+1)) or 1 + end + function document.show_pending_xml_elements() + io.savedata("\jobname-pending-xml-mkii.log", table.serialize(list)) + io.savedata("\jobname-pending-xml-mkiv.log", table.serialize(lxml.get_command_status())) + end +\stopluacode + +\defineXMLcommand + [default] + {\ctxlua{document.check_pending_xml_element("\currentXMLelement")}} + +\appendtoks + \ctxlua{document.show_pending_xml_elements()}% +\to \everystoptext + +\endinput diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index 4e86f668e..087aeb459 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -89,10 +89,37 @@ %D Loading: -\startxmlsetups xml:setups:register +\let\currentSETUPfullname\s!unknown + +\startxmlsetups xml:setups:assemblename + \doifelse {\xmlatt{#1}{environment}} {yes} { + \let\currentSETUPprefix\e!start + } { + \let\currentSETUPprefix\empty + } \edef\currentSETUPname{\xmlatt{#1}{name}} - % \writestatus{setups}{registering \currentSETUPname}% - \expanded{\texcommand[stp:x:\currentSETUPname]{\currentSETUPname}} + \doifelse {\xmlatt{#1}{generated}} {yes} { + \def\currentSETUPgenerated{*} + } { + \let\currentSETUPgenerated\empty + } + \doifelsenothing {\xmlatt{#1}{variant}} { + \let\currentSETUPvariant\empty + } { + \def\currentSETUPvariant{:\xmlatt{#1}{variant}} + } + \edef\currentSETUPfullname { + \currentSETUPprefix + \currentSETUPname + \currentSETUPvariant + \currentSETUPgenerated + } +\stopxmlsetups + +\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 @@ -125,7 +152,8 @@ \def\shortsetup{\shortsetuptrue \doshowsetup} \def\setupsetup{\dodoubleargument\getparameters[\??stp]} -\unexpanded\def\showsetupinlist#1#2#3{\shortsetupfalse\showsetupindeed{#3}\par} +%unexpanded\def\showsetupinlist#1#2#3{\shortsetupfalse\showsetupindeed{#3}\par} +\unexpanded\def\showsetupinlist#1#2#3{\shortsetupfalse\xmlsetup{#3}{xml:setups:typeset}\par} % todo: only references in lists @@ -166,7 +194,6 @@ \startxmlsetups xml:setups:typeset \xmlpushdocument{setups} - \edef\currentSETUPname{\xmlatt{#1}{name}}% \getvalue{\e!start setuptext} \tttf \nohyphens diff --git a/tex/context/base/x-set-12.tex b/tex/context/base/x-set-12.tex index 6d3667771..d79901433 100644 --- a/tex/context/base/x-set-12.tex +++ b/tex/context/base/x-set-12.tex @@ -72,7 +72,7 @@ \definecolor [lightgray] [s=.9] \definecolor [darkgray] [s=.1] -\usetypescript[palatino][\defaultencoding] +\usetypescript[palatino] \setupbodyfont[palatino,9pt] \setupcolors @@ -192,9 +192,9 @@ \startmakeup[\v!standard] \dontcomplain + \setupalign[\v!left] \startcolor[TitleColor] \definedfont[RegularBold at 100pt]\setstrut - \setupalign[\v!left] \strut Con\TeX t \par \definedfont[RegularBold at 50pt]\setstrut \setups[text:commands] diff --git a/tex/context/base/x-xtag.mkiv b/tex/context/base/x-xtag.mkiv new file mode 100644 index 000000000..d7e2f2559 --- /dev/null +++ b/tex/context/base/x-xtag.mkiv @@ -0,0 +1,23 @@ +%D \module +%D [ file=x-xtag, +%D version=2009.09.23, +%D title=\CONTEXT\ Modules, +%D subtitle=\XML\ stream handler, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\ifdefined\XMLbanner \endinput \fi + +\loadcorefile{xtag-ini} +\loadcorefile{xtag-ext} +\loadcorefile{xtag-exp} +\loadcorefile{xtag-pre} % has old encoding code +\loadcorefile{xtag-xsd} % will go away (stub anyway) +\loadcorefile{xtag-rng} % will go away (stub anyway) + +\endinput diff --git a/tex/context/interface/cont-cs.xml b/tex/context/interface/cont-cs.xml index c22ededd8..53d861c90 100644 --- a/tex/context/interface/cont-cs.xml +++ b/tex/context/interface/cont-cs.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml index af98387fc..aaea5d00c 100644 --- a/tex/context/interface/cont-de.xml +++ b/tex/context/interface/cont-de.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml index 01feb5e50..4f0237627 100644 --- a/tex/context/interface/cont-en.xml +++ b/tex/context/interface/cont-en.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml index 22011cd9f..690903ca4 100644 --- a/tex/context/interface/cont-fr.xml +++ b/tex/context/interface/cont-fr.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml index 14b9cbaa4..e2502d5cd 100644 --- a/tex/context/interface/cont-it.xml +++ b/tex/context/interface/cont-it.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml index 401fe14e1..47ce230b5 100644 --- a/tex/context/interface/cont-nl.xml +++ b/tex/context/interface/cont-nl.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-pe.xml b/tex/context/interface/cont-pe.xml index e0d3f7ce5..bcf164d8d 100644 --- a/tex/context/interface/cont-pe.xml +++ b/tex/context/interface/cont-pe.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml index ba83586a1..2f6dd9f3e 100644 --- a/tex/context/interface/cont-ro.xml +++ b/tex/context/interface/cont-ro.xml @@ -4001,6 +4001,7 @@ + diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index a07ca9466..e107372e9 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/23/09 10:11:52 +-- merge date : 09/25/09 09:47:31 do -- begin closure to overcome local limits and interference -- cgit v1.2.3