summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-07-09 20:28:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-07-09 20:28:00 +0200
commite718f750bd4902d4921a156691005844e4d63f03 (patch)
tree69ed8882e803199d83f0c0f42a03fb4602cda772 /tex
parentb7363176fdde8bc35822c375bd2fb045b7cb94dc (diff)
downloadcontext-e718f750bd4902d4921a156691005844e4d63f03.tar.gz
beta 2012.07.09 20:28
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/context-version.pdfbin4133 -> 4138 bytes
-rw-r--r--tex/context/base/context-version.pngbin105114 -> 106297 bytes
-rw-r--r--tex/context/base/mult-def.mkiv1
-rw-r--r--tex/context/base/mult-low.lua5
-rw-r--r--tex/context/base/mult-sys.mkiv20
-rw-r--r--tex/context/base/page-flt.mkiv2
-rw-r--r--tex/context/base/page-one.mkiv2
-rw-r--r--tex/context/base/page-sid.mkiv10
-rw-r--r--tex/context/base/status-files.pdfbin24487 -> 24476 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin182715 -> 179530 bytes
-rw-r--r--tex/context/base/status-mkiv.lua17
-rw-r--r--tex/context/base/status-mkiv.tex1
-rw-r--r--tex/context/base/strc-con.mkvi8
-rw-r--r--tex/context/base/strc-def.mkiv53
-rw-r--r--tex/context/base/strc-doc.mkiv233
-rw-r--r--tex/context/base/strc-num.mkiv2
-rw-r--r--tex/context/base/strc-ren.mkiv782
-rw-r--r--tex/context/base/strc-sec.mkiv755
-rw-r--r--tex/context/base/supp-box.mkiv5
-rw-r--r--tex/context/base/syst-ini.mkiv252
20 files changed, 1167 insertions, 981 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 5576edcd5..c8c4aa513 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 150dedf60..a2ff996ee 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index c7c3402a6..433eae9f9 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -70,6 +70,7 @@
\ifdefined\v!kerncharacters\else \def\v!kerncharacters{kerncharacters} \fi % no time now for translations should be a e! actually
\ifdefined\v!stretched \else \def\v!stretched {stretched} \fi
\ifdefined\v!vulgarfraction\else \def\v!vulgarfraction{vulgarfraction} \fi
+\ifdefined\v!block \else \def\v!block {block} \fi
% stop todo
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index a3d2e8ecb..571c4e48f 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -188,6 +188,8 @@ return {
"scratchboxone", "scratchboxtwo", "scratchboxthree",
"scratchnx", "scratchny", "scratchmx", "scratchmy",
--
+ "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip",
+ --
"doif", "doifnot", "doifelse",
"doifinset", "doifnotinset", "doifinsetelse",
"doifnextcharelse", "doifnextoptionalelse", "doifnextbgroupelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse",
@@ -246,6 +248,7 @@ return {
--
"newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant",
"newmacro", "setnewmacro", "newfraction",
+ "newsignal",
--
"dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty",
"dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument",
@@ -259,6 +262,6 @@ return {
--
"startnointerference", "stopnointerference",
--
- "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut",
+ "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut", "lineheight",
}
}
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 407fd4ce6..de72b5b80 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -253,8 +253,8 @@
\definesystemconstant {multi}
\definesystemconstant {indeed}
-% \def\s!parent{=>} % 1% faster / does not work in assignments
-% \def\s!child {<=} % 1% faster / does not work in assignments
+% \def\s!parent{->} % 1% faster / => does not work in assignments
+% \def\s!child {<-} % 1% faster / <= does not work in assignments
\definesystemconstant {hasnumber}
\definesystemconstant {hastitle}
@@ -624,4 +624,20 @@
\definemessageconstant {addresses}
\definemessageconstant {documents}
+%D Nicer than being undefined:
+
+\let\p_align \empty
+\let\p_aligntitle\empty
+\let\p_continue \empty
+\let\p_footer \empty
+\let\p_label \empty
+\let\p_number \empty
+\let\p_page \empty
+\let\p_state \empty
+\let\p_strut \empty
+\let\p_text \empty
+\let\p_tolerance \empty
+
+% more will follow
+
\protect \endinput
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index a608df0c8..c745290d1 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -153,7 +153,7 @@
\def\currentfloat{#1}%
\blank[\rootfloatparameter\c!spacebefore]%
\box\floatbox
- \blank[\rootfloatparameter\c!spaceafter]
+ \blank[\rootfloatparameter\c!spaceafter]%
\fi}}
% \setupcaption [figure] [align=flushleft]
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 2246bf78d..e9ca80e2b 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -247,7 +247,7 @@
\noffloatinserts\c_page_floats_n_of_top\relax
\fi
\else
- \ifcoditional\c_page_floats_some_waiting
+ \ifconditional\c_page_floats_some_waiting
\showmessage\m!floatblocks6{\the\c_page_floats_n_of_top}%
\fi
\let\page_one_command_set_top_insertions_indeed\relax
diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv
index 029824597..629596c33 100644
--- a/tex/context/base/page-sid.mkiv
+++ b/tex/context/base/page-sid.mkiv
@@ -189,8 +189,8 @@
+\compensatedinnermakeupmargin
\relax
\fi
- \ifdim\d_page_sides_rightskip>\zeropoint \doglobal\advance\d_page_sides_rightskip\rightskip \fi
- \ifdim\d_page_sides_leftskip >\zeropoint \doglobal\advance\d_page_sides_leftskip \leftskip \fi}
+ \ifdim\d_page_sides_rightskip>\zeropoint \global\advance\d_page_sides_rightskip\rightskip \fi
+ \ifdim\d_page_sides_leftskip >\zeropoint \global\advance\d_page_sides_leftskip \leftskip \fi}
\def\page_sides_flush_floats
{\par
@@ -308,7 +308,9 @@
\ifdim\wd\b_page_sides_bottom<\d_page_sides_hsize
\parskip\zeropoint
%\noindent
- \ifinner\else\vadjust{\penalty\minusone}\fi
+ \ifinner\else
+ \vadjust{\penalty\minusone}%
+ \fi
\ifconditional\c_page_sides_l_eq
\global\setfalse\c_page_sides_l_eq
\else
@@ -399,7 +401,7 @@
\else
\kern\d_page_sides_shift
\fi
- \vbox{#1\ifnum\c_page_sides_align=\plusfour \removedepth\fi}%
+ \vbox{#1\ifnum\c_page_sides_align=\plusfour \removedepth \fi}%
\ifnum\c_page_sides_float_type>\plusfour
\kern\d_page_sides_shift
\else
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index ca1df2412..966f28c40 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index df6eddfe4..5c97ea52a 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index c8782e532..327df0214 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -204,8 +204,8 @@ return {
{
filename = "layo-ini",
marktype = "mkiv",
- status = "todo",
- comment = "more might move to here",
+ status = "okay",
+ comment = "in due time more might move to here",
},
{
filename = "node-ini",
@@ -509,7 +509,8 @@ return {
{
filename = "strc-doc",
marktype = "mkiv",
- status = "todo",
+ status = "okay",
+ comment = "this module migh tgo away when code has been moved",
},
{
filename = "strc-num",
@@ -535,7 +536,8 @@ return {
{
filename = "strc-sec",
marktype = "mkiv",
- status = "todo",
+ status = "okay",
+ comment = "some of the local current and synchronization macros will be renamed",
},
{
filename = "strc-pag",
@@ -545,7 +547,8 @@ return {
{
filename = "strc-ren",
marktype = "mkiv",
- status = "todo",
+ status = "okay",
+ comment = "(support for) setups might get improved"
},
{
filename = "strc-xml",
@@ -556,7 +559,7 @@ return {
{
filename = "strc-def",
marktype = "mkiv",
- status = "todo",
+ status = "okay",
},
{
filename = "strc-ref",
@@ -654,7 +657,7 @@ return {
filename = "strc-con",
marktype = "mkiv",
status = "okay",
- comment = "maybe more common counter code here",
+ comment = "maybe more common counter code here and setups need to be improved",
},
{
filename = "strc-des",
diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex
index 8bbb89ee9..36bab777b 100644
--- a/tex/context/base/status-mkiv.tex
+++ b/tex/context/base/status-mkiv.tex
@@ -54,6 +54,7 @@
\startitem consider moving setups directly to lua end (e.g. in characterspacing, breakpoint, bitmaps etc.) \stopitem
\startitem more local temporary \type {\temp...} will become \type {\p_...} \stopitem
\startitem check all ctxlua calls for ctxcommand \stopitem
+ \startitem rename all those \type {\current<whatever>}s in strc.
\stopitemize
\stoptitle
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
index bd1309f48..620e64c2e 100644
--- a/tex/context/base/strc-con.mkvi
+++ b/tex/context/base/strc-con.mkvi
@@ -340,6 +340,8 @@
\installcorenamespace{constructionrenderings}
% see lists: alternativemethods ... todo
+%
+% there will be a proper interface to variables
\installcommandhandler \??constructionalternative {constructionalternative} \??constructionalternative
@@ -419,7 +421,7 @@
{\setbox\constructionheadbox\vtop % \vbox gaat fout in hang
{\forgetall
\dontcomplain
- \hsize\constructionsheadwidth
+ \hsize\constructionsheadwidth\relax
\ifx\p_strc_constructions_headalign\empty
\setupalign[#1]% use fast one
\else
@@ -435,7 +437,7 @@
{\setbox\constructionheadbox\vtop
{\forgetall
\dontcomplain
- \hsize\constructionsheadwidth
+ \hsize\constructionsheadwidth\relax
\ifx\p_strc_constructions_headalign\empty
\setupalign[#1]% use fast one
\else
@@ -598,7 +600,7 @@
\stopsetups
\startsetups[\??constructionrenderings:\v!top]
- \dohandlepagebreakX\plusone
+ \strc_sectioning_prevent_page_break\plusone
\let\\=\space
\noindent
\copy\constructionheadbox % why copy ?
diff --git a/tex/context/base/strc-def.mkiv b/tex/context/base/strc-def.mkiv
index 396b4c154..bd7c25170 100644
--- a/tex/context/base/strc-def.mkiv
+++ b/tex/context/base/strc-def.mkiv
@@ -16,59 +16,6 @@
\unprotect
-\setupheads[%
- %\c!after=,
- %\c!align=,
- %\c!aligntitle=,
- \c!alternative=\v!normal,
- %\c!before=,
- %\c!color=,
- \c!command=\normalplacehead,
- \c!continue=\v!yes,
- %\c!coupling=,
- %\c!deepnumbercommand=,
- %\c!deeptextcommand=,
- %\c!default=,
- \c!distance=\zeropoint,
- \c!expansion=\v!no,
- %\c!file=,
- %\c!footer=,
- %\c!grid=,
- \c!hang=\v!none,
- %\c!header=,
- \c!incrementnumber=\v!yes,
- \c!indentnext=\v!no,
- %\c!label=,
- %\c!limittext=\languageparameter\c!limittext,
- \c!margin=\zeropoint,
- %\c!margintext=,
- \c!number=\v!yes,
- \c!numbercolor=\headparameter\c!color,
- \c!textcolor=\headparameter\c!color,
- \c!numberstyle=\headparameter\c!style,
- \c!textstyle=\headparameter\c!style,
- %\c!numbercommand=,
- %\c!textcommand=,
- \c!ownnumber=\v!no,
- %\c!page=,
- \c!placehead=\v!yes,
- \c!sectionconversionset=\s!default,
- \c!sectionnumber=\v!yes,
- %\c!sectionsegments=,
- \c!sectionseparatorset=\s!default,
- \c!sectionset=\v!all,
- \c!interlinespace=,
- %\c!sectionstopper=,
- %\c!sectionstarter=,
- %\c!strut=,
- %\c!style=,
- %\c!text=,
- %\c!tolerance=,
- %\c!beforesection=\directsetup{document:\currenthead:start}, % these might become defaults i.e. acpect document: namespace
- %\c!insidesection=\directsetup{document:\currenthead:inside}, % these might become defaults i.e. acpect document: namespace
- %\c!aftersection=\directsetup{document:\currenthead:stop}, % these might become defaults i.e. acpect document: namespace
- ]
-
% \setupsectionblock[appendix][sectionconversionset=appendix]
% \setuphead[chapter][sectionconversionset=\sectionblockparameter\c!sectionconversionset] % \sectionblockparameter]
diff --git a/tex/context/base/strc-doc.mkiv b/tex/context/base/strc-doc.mkiv
index 0263095eb..c8dfae1e4 100644
--- a/tex/context/base/strc-doc.mkiv
+++ b/tex/context/base/strc-doc.mkiv
@@ -17,239 +17,10 @@
\unprotect
-% We operate in a \type {@@ns} namespace. All data is passed through
-% variables. Of course we can built another interface on top of this
-% that accepts multiple arguments. We might change this approach and
-% remove this layer but it was needed for the transition.
+%D This will move:
-\installcorenamespace{structure}
-
-\installdirectcommandhandler \??structure {structure} % unchecked, so we need to initialize used parameters
-
-% \definesystemvariable{ns}
-% \def\structureparameter#1{\csname\??ns#1\endcsname}
-% \def\detokenizedstructureparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??ns#1\endcsname}}
-
-\setupstructure % not a user command so we might need to change the name
- [\c!number=,
- \c!level=,
- \c!name=,
- \c!title=,
- \c!bookmark=,
- \c!marking=,
- \c!list=,
- \c!label=,
- \c!coupling=,
- \c!ownnumber=,
- \c!sectionseparatorset=\s!default,
- \c!sectionconversionset=\s!default,
- \c!sectionstopper=,
- \c!sectionstarter=,
- \c!sectionsegments=,
- \c!sectionresetset=,
- \c!reference=,
- \c!backreference=,
- \c!expansion=\v!no,
- \c!xmlsetup=,
- \s!catcodes=,
- \c!saveinlist=\v!yes,
- \c!command=\showstructuredata]
-
-% maybe flags for list, bm, mark
-
-\def\m_strc_references_prefix_yes{+}
-\def\m_strc_references_prefix_nop{-}
-
-\def\setstructurereferenceprefix % will move
- {\ifx\currentstructurereferenceprefix\empty
- % nothing
- \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_yes
- \global\advance\prefixcounter \plusone % temp here
- \setupglobalreferenceprefix[\the\prefixcounter]%
- \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_nop
- \setupglobalreferenceprefix[]%
- \else
- \setupglobalreferenceprefix[\currentstructurereferenceprefix]%
- \fi\fi\fi
- \let\currentstructurereferenceprefix\referenceprefix}
-
-% why xdef ?
-
-\unexpanded\def\structurecomponent
- {\dodoubleempty\dostructurecomponent}
-
-\def\dostructurecomponent[#1][#2]% #1=interfaced-settings, #2=optional user data (not yet supported)
- {\begingroup
- \setupstructure[#1]%
- \xdef\currentstructurename {\structureparameter\c!name}%
- \xdef\currentstructurecoupling {\structureparameter\c!coupling}%
- \xdef\currentstructureownnumber {\structureparameter\c!ownnumber}% optional own number
- \xdef\currentstructurelevel {\structureparameter\c!level}%
- \edef\currentstructureexpansion {\structureparameter\c!expansion}%
- \xdef\currentstructurexmlsetup {\structureparameter\c!xmlsetup}%
- \xdef\currentstructurecatcodes {\structureparameter\s!catcodes}%
- \xdef\currentstructurelabel {\structureparameter\c!label}%
- \xdef\currentstructurereference {\structureparameter\c!reference}%
- \xdef\currentstructurereferenceprefix{\structureparameter\c!referenceprefix}%
- \xdef\currentstructurebackreference {\structureparameter\c!backreference}%
- \xdef\currentstructureshownumber {\structureparameter\c!number}%
- \xdef\currentstructuresaveinlist {\structureparameter\c!saveinlist}%
- \xdef\currentstructureincrementnumber{\structureparameter\c!incrementnumber}%
- \ifx\currentstructureexpansion\s!xml
- \xmlstartraw
- \xdef\currentstructuretitle {\structureparameter\c!title}%
- \xdef\currentstructurebookmark{\structureparameter\c!bookmark}%
- \xdef\currentstructuremarking {\structureparameter\c!marking}%
- \xdef\currentstructurelist {\structureparameter\c!list}%
- \xmlstopraw
- \ifx\currentstructurelist\empty
- \globallet\currentstructurelist\currentstructuretitle
- \fi
- \globallet\currentstructurecoding\s!xml
- \else
- \ifx\currentstructureexpansion\v!yes
- \xdef\currentstructuretitle {\structureparameter\c!title}%
- \xdef\currentstructurebookmark{\structureparameter\c!bookmark}%
- \xdef\currentstructuremarking {\structureparameter\c!marking}%
- \xdef\currentstructurelist {\structureparameter\c!list}%
- \else
- \xdef\currentstructuretitle {\detokenizedstructureparameter\c!title}%
- \xdef\currentstructurebookmark{\detokenizedstructureparameter\c!bookmark}%
- \xdef\currentstructuremarking {\detokenizedstructureparameter\c!marking}%
- \xdef\currentstructurelist {\detokenizedstructureparameter\c!list}%
- \iflocation \ifx\currentstructurebookmark\empty
- \begingroup
- \simplifycommands
- \xdef\currentstructurebookmark{\detokenize\expandafter{\normalexpanded{\structureparameter\c!title}}}%
- \endgroup
- \fi \fi
- \fi
- \ifx\currentstructurelist\empty
- \globallet\currentstructurelist\currentstructuretitle
- \fi
- \globallet\currentstructurecoding\s!tex
- \fi
- \setnextinternalreference
- \setstructurereferenceprefix
- \xdef\currentstructurenumber{\ctxlua{ % todo: combine with next call, adapt marks accordingly
- structures.sections.somelevel {
- references = {
- internal = \nextinternalreference,
- block = "\currentsectionblock",
- reference = "\currentstructurereference",
- referenceprefix = "\currentstructurereferenceprefix",
- backreference = "\currentstructurebackreference",
- },
- directives = {
- resetset = "\structureparameter\c!sectionresetset",
- },
- metadata = {
- kind = "section",
- name = "\currentstructurename",
- catcodes = \the\ifx\currentstructurecatcodes\empty\catcodetable\else\csname\currentstructurecatcodes\endcsname\fi,
- coding = "\currentstructurecoding",
- \ifx\currentstructurecoding\s!xml
- xmlroot = "\xmldocument",
- \fi
- \ifx\currentstructurexmlsetup\empty \else
- xmlsetup = "\currentstructurexmlsetup",
- \fi
- \ifx\currentstructuresaveinlist\v!no
- nolist = true,
- \fi
- \ifx\currentstructureincrementnumber\v!yes
- increment = "\currentstructureincrementnumber",
- \fi
- },
- titledata = { % we can add mark and reference
- label = \!!bs\detokenize\expandafter{\currentstructurelabel }\!!es,
- title = \!!bs\detokenize\expandafter{\currentstructuretitle }\!!es,
- \ifx\currentstructurebookmark\currentstructuretitle \else
- bookmark = \!!bs\detokenize\expandafter{\currentstructurebookmark }\!!es,
- \fi
- \ifx\currentstructuremarking\currentstructuretitle \else
- marking = \!!bs\detokenize\expandafter{\currentstructuremarking }\!!es,
- \fi
- \ifx\currentstructuresaveinlist\v!no \else
- \ifx\currentstructurelist\currentstructuretitle \else
- list = \!!bs\detokenize\expandafter{\currentstructurelist}\!!es,
- \fi
- \fi
- },
- numberdata = {
- % needed ?
- block = "\currentsectionblock",
- hidenumber = \ifx\currentstructureshownumber\v!no true\else nil\fi, % titles
- % so far
- separatorset = "\structureparameter\c!sectionseparatorset",
- conversion = "\structureparameter\c!sectionconversion", % for good old times sake
- conversionset = "\structureparameter\c!sectionconversionset",
- starter = \!!bs\structureparameter\c!sectionstarter\!!es,
- stopper = \!!bs\structureparameter\c!sectionstopper\!!es,
- set = "\structureparameter\c!sectionset",
- segments = "\structureparameter\c!sectionsegments",
- ownnumber = "\currentstructureownnumber",
- },
- userdata = \!!bs\detokenize{#2}\!!es % will be converted to table at the lua end
- }
- }}%
- \xdef\currentstructurelistnumber{\ctxcommand{addtolist(structures.sections.current())}}%
- % \currentstructuresynchronize has to be called someplace, since it introduces a node
- \setstructuresynchronization\currentstructurelistnumber
- \structureparameter\c!command
- \endgroup}
-
-\let\currentstructurenumber \!!zerocount
-\let\currentsectioncountervalue \!!zerocount % redefined later
-\let\previoussectioncountervalue\!!zerocount % redefined later
-
-% todo: a direct flusher (needed when hidden)
-
-\def\setstructuresynchronization#1% todo: use ctxcontext
+\unexpanded\def\setstructuresynchronization#1% todo: use ctxcontext
{\xdef\currentstructureattribute {\ctxlua {tex.write(structures.references.setinternalreference("\currentstructurereferenceprefix","\currentstructurereference",\nextinternalreference,"\interactionparameter\c!focus"))}}%
\xdef\currentstructuresynchronize{\ctxlatecommand{enhancelist(#1)}}}
-\def\reportcurrentstructure{\ctxlua{structures.sections.reportstructure()}}
-
-% Beware: we need to flush the data to the list explicitly. This is because
-% node in inserted and we may want control over when that happens.
-
-\def\showstructuredata
- {\par
- \dontleavehmode\begingroup
- \currentstructuresynchronize
- \currentstructureattribute
- [\currentstructurename: \showstructurelevel: \currentstructuretitle]
- \endgroup\par}
-
-% We can access the (stored) data with the following macros.
-%
-% \def\MyHeadCommand #1#2{\framed{#1}\framed{#2 / \structureuservariable{subtitle}}}
-% \def\MyListCommand#1#2#3{\externalfigure[\structurelistuservariable{figure}][height=5mm]#2}
-%
-% \setuphead[chapter][command=\MyHeadCommand]
-% \setuplist[chapter][alternative=command,command=\MyListCommand]
-%
-% \starttext
-% \setupheadertexts[chapter]
-% \setupinteraction[state=start]
-% \placebookmarks[chapter]
-% \placelist[chapter]
-% \startchapter[ownnumber=10,title=Ton,list=Hans,marking=Kees,bookmark=Bram][figure=cow.pdf,subtitle=oeps]
-% \stopchapter
-% \stoptext
-
-% todo: #1 => "#1" ... adapt lua code for name and number
-
-\def\structurenumber {\ctxcommand{structurenumber()}}
-\def\structuretitle {\ctxcommand{structuretitle()}}
-\def\structurevariable #1{\ctxcommand{structurevariable("#1")}}
-\def\structureuservariable #1{\ctxcommand{structureuservariable("#1")}}
-\def\structurecatcodedget #1{\ctxcommand{structurecatcodedget("#1")}} % bad name
-\def\structuregivencatcodedget #1#2{\ctxcommand{structuregivencatcodedget("#1",\number#2)}} % bad name
-\def\structureautocatcodedget #1#2{\ctxcommand{structureautocatcodedget ("#1","#2")}}
-
-\def\namedstructurevariable #1#2{\ctxcommand{namedstructurevariable ("#1","#2")}}
-\def\namedstructureuservariable#1#2{\ctxcommand{namedstructureuservariable("#1","#2")}}
-
\protect \endinput
diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv
index 52e4960fa..7ce638acb 100644
--- a/tex/context/base/strc-num.mkiv
+++ b/tex/context/base/strc-num.mkiv
@@ -507,6 +507,8 @@
% \m_strc_counters_last_registered_attribute
% \m_strc_counters_last_registered_synchronize
+% currentstructurecomponent => \strc_current_ or just \m_strc_
+
\unexpanded\def\strc_counters_register_component#1#2#3#4#5#6#7[#8][#9]% maybe also nolist
{\begingroup
%
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index d20e494f0..ba14bb59f 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -17,9 +17,8 @@
\newbox\b_strc_rendering_head
-\newdimen\d_strc_rendering_local_height
-\newdimen\d_strc_rendering_local_depth
-\newdimen\d_strc_rendering_local_lineheight
+\newdimen\d_strc_rendering_local_leftoffset
+\newdimen\d_strc_rendering_local_rightoffset
% Martin Kolarik's problem:
%
@@ -29,83 +28,55 @@
\newtoks\everyheadstart
-\unexpanded\def\strc_rendering_component_set_font#1#2%
+\unexpanded\def\strc_rendering_initialize_style_and_color
+ {\ifconditional\headisdisplay
+ \expandafter\strc_rendering_initialize_style_and_color_display
+ \else
+ \expandafter\strc_rendering_initialize_style_and_color_inline
+ \fi}
+
+\unexpanded\def\strc_rendering_initialize_style_and_color_display#1#2%
{\dontconvertfont
- \ifconditional\headisdisplay
- \edef\p_strc_rendering_interlinespace{\headparameter\c!interlinespace}%
- \ifx\p_strc_rendering_interlinespace\empty
- % here the interline space is only set when style sets no space
- \setfalse\fontattributeisset % use the currentfontparameter state instead
- \setfalse\interlinespaceisset
- \useheadstyleandcolor\c!style\c!color
- \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
- \setupinterlinespace
- \fi \fi
- \setfalse\fontattributeisset \useheadstyleandcolor#1#2%
- \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
- \setupinterlinespace
- \fi \fi
- \else
- % here the set interline space overloads any other set space in the style
- \setfalse\fontattributeisset
- \useheadstyleandcolor\c!style\c!color
- \ifconditional\fontattributeisset
- \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace
- \fi
- \setfalse\fontattributeisset
- \useheadstyleandcolor#1#2%
- \ifconditional\fontattributeisset
- \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace
- \fi
- \fi
+ \edef\p_strc_rendering_interlinespace{\headparameter\c!interlinespace}%
+ \ifx\p_strc_rendering_interlinespace\empty
+ % here the interline space is only set when style sets no space
+ \setfalse\fontattributeisset % use the currentfontparameter state instead
+ \setfalse\interlinespaceisset
+ \useheadstyleandcolor\c!style\c!color\relax
+ \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
+ \setupinterlinespace
+ \fi \fi
+ \setfalse\fontattributeisset
+ \useheadstyleandcolor#1#2\relax
+ \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else
+ \setupinterlinespace
+ \fi \fi
\else
+ % here the set interline space overloads any other set space in the style
\setfalse\fontattributeisset
- \useheadstyleandcolor\c!style\c!color
+ \useheadstyleandcolor\c!style\c!color\relax
\ifconditional\fontattributeisset
- \updateraggedskips % \setupspacing
+ \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace
\fi
\setfalse\fontattributeisset
- \useheadstyleandcolor#1#2%
+ \useheadstyleandcolor#1#2\relax
\ifconditional\fontattributeisset
- \updateraggedskips % \setupspacing
+ \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace
\fi
\fi}
-\def\doplaceheadtextcomponent#1%
- {\begingroup
- \strc_rendering_component_set_font\c!textstyle\c!textcolor
- \headparameter\c!commandbefore\relax
- \ifcsname\currentheadhash\c!deeptextcommand\endcsname
- \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname
- \fi
- \ifconditional\headisdisplay % \ifdisplaysectionhead
- % struts can be nilled with \setnostrut
- \headparameter\c!textcommand{\setstrut\begstrut#1\endstrut}%
- \global\d_strc_rendering_local_height\strutht
- \global\d_strc_rendering_local_depth\strutdp
- \global\d_strc_rendering_local_lineheight\lineheight
- \else
- \headparameter\c!textcommand{#1}%
- \fi
- \headparameter\c!commandafter\relax
- \ifconditional\headisdisplay % \ifdisplaysectionhead
- \endgraf
- \fi
- \endgroup}
-
-\def\doplaceheadnumbercomponent#1%
- {\begingroup
- \strc_rendering_component_set_font\c!numberstyle\c!numbercolor
- \ifcsname\currentheadhash\c!deepnumbercommand\endcsname
- \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname
- \fi
- \ifconditional\headisdisplay % \ifdisplaysectionhead
- % can be nilled with \setnostrut
- \headparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}%
- \else
- \headparameter\c!numbercommand{#1}%
- \fi
- \endgroup}
+\unexpanded\def\strc_rendering_initialize_style_and_color_inline#1#2%
+ {\dontconvertfont
+ \setfalse\fontattributeisset
+ \useheadstyleandcolor\c!style\c!color\relax
+ \ifconditional\fontattributeisset
+ \updateraggedskips % \setupspacing
+ \fi
+ \setfalse\fontattributeisset
+ \useheadstyleandcolor#1#2\relax
+ \ifconditional\fontattributeisset
+ \updateraggedskips % \setupspacing
+ \fi}
\let\currentstructurereferenceattribute\attributeunsetvalue
@@ -141,13 +112,15 @@
% maybe auto: backreference when given, else list
\fi\fi}
-\unexpanded\def\placecurrentheadtext
- {\beginheadplacement
+% a bit messy ... empty in place instead of self .. might change (or use special
+% whatsig (invisible user one)
+
+\unexpanded\def\strc_rendering_place_head_text
+ {\strc_rendering_start_placement
\setheadmarking
\doresettructureheadnumbercontent
- \ifconditional\headleaveempty
- \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{}%
- \makestrutofbox\b_strc_rendering_head
+ \ifconditional\c_strc_sectioning_empty
+ \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{\strut}%
\else
\docheckheadreference
\setbox\b_strc_rendering_head\hbox \headreferenceattributes
@@ -155,30 +128,29 @@
\doresettructureheadnumbercontent
\useheadstyleparameter\c!style
\setinlineheadreferenceattributes
- \headparameter\c!command{}{\doplaceheadtextcomponent\getheadtitle}}%
+ \strc_rendering_inject_text}%
\fi
- \endheadplacement\getheadsyncs}
+ \strc_rendering_stop_placement}
-\unexpanded\def\placecurrentheadnumbertext
- {\beginheadplacement
+\unexpanded\def\strc_rendering_place_head_number_and_text
+ {\strc_rendering_start_placement
\setheadmarking
\doiftextelse\getheadnumber
\dosettructureheadnumbercontent
\doresettructureheadnumbercontent
- \ifconditional\headleaveempty
- \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{}%
- \makestrutofbox\b_strc_rendering_head
+ \ifconditional\c_strc_sectioning_empty
+ \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{\strut}%
\else % = needed
\docheckheadreference
\setbox\b_strc_rendering_head\hbox \headreferenceattributes
{\spac_grids_set_local_snapping{\headparameter\c!internalgrid}%
\useheadstyleparameter\c!style
\setinlineheadreferenceattributes
- \headparameter\c!command{\doplaceheadnumbercomponent\getheadnumber}{\doplaceheadtextcomponent\getheadtitle}}%
+ \strc_rendering_inject_number_and_text}%
\fi
- \endheadplacement\getheadsyncs}
+ \strc_rendering_stop_placement}
-\unexpanded\def\placecurrentheadempty
+\unexpanded\def\strc_rendering_place_head_empty
{\hbox \headreferenceattributes {\getheadsyncs}}
%D \starttyping
@@ -193,56 +165,96 @@
%D \MySubject{feeling stretched feeling stretched feeling stretched feeling stretched}
%D \stoptyping
-\def\dolocalheadsetup
- {\forgetall
+% helpers
+
+% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em]
+%
+% \defineheadplacement[MyTest][horizontal]#1#2%
+% {\startlocalheadsetup
+% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay
+% \ChapterInMargin{\strut#2}% zero destination, ref okay
+% \stoplocalheadsetup}
+%
+% \setuphead
+% [chapter]
+% [alternative=MyTest]
+
+\unexpanded\def\headhbox{\hbox\headreferenceattributes}
+\unexpanded\def\headvbox{\vbox\headreferenceattributes}
+
+\unexpanded\def\startlocalheadsetup{\bgroup\strc_rendering_initialize_spacing}
+\unexpanded\def\stoplocalheadsetup {\egroup}
+
+\unexpanded\def\strc_rendering_initialize_spacing
+ {\forgetall % local !
\edef\p_align{\headparameter\c!align}%
\ifx\p_align\empty \else
- \normalexpanded{\setupalign[\p_align]}%
+ \setupalign[\p_align]%
\fi
\edef\p_tolerance{\headparameter\c!tolerance}%
\ifx\p_tolerance\empty \else
- \normalexpanded{\setuptolerance[\p_tolerance]}%
+ \setuptolerance[\p_tolerance]%
\fi
\edef\p_strut{\headparameter\c!strut}%
\ifx\p_strut\v!no
\setnostrut
\fi
- \def\\{\crlf\strut\ignorespaces}}
+ \let\\\strc_rendering_shortcut_backslash}
-\def\beginheadplacement
+\unexpanded\def\strc_rendering_shortcut_backslash
+ {\crlf
+ \strut
+ \ignorespaces}
+
+\def\strc_rendering_start_placement
{\bgroup
\setsystemmode\currenthead
- \global\d_strc_rendering_local_height\strutht
- \global\d_strc_rendering_local_depth\strutdp
- \global\d_strc_rendering_local_lineheight\lineheight
+ %
+ \strc_rendering_initialize_alternatives
+ \strc_rendering_initialize_dimensions
+ %
+ \strc_rendering_initialize_line_state
\reseteverypar % needed indeed
- \noindent % ipv \whitespace elders, na \forgetall !
+ \noindent % ipv \whitespace elders, na \forgetall !
\bgroup
- \doifinsetelse{\headparameter\c!aligntitle}{\v!yes,\v!float}% new
- {\skip0 1\leftskip
- \skip2 1\rightskip
- \xdef\localheadskip{\the\skip0}%
- \forgetall
- \leftskip\skip0
- \rightskip\skip2
- \setlocalhsize\hsize\localhsize
- \forgetbothskips}
- {\globallet\localheadskip\!!zeropoint
- \forgetall}%
+ \edef\p_aligntitle{\headparameter\c!aligntitle}%
+ \ifx\p_aligntitle\v!yes
+ \strc_rendering_initialize_hsize_local
+ \else\ifx\p_aligntitle\v!float
+ \strc_rendering_initialize_hsize_local
+ \else
+ \strc_rendering_initialize_hsize_global
+ \fi\fi
\setfalse\inhibitmargindata % brrrr is set in forgetall
\dontcomplain
\postponenotes
- \iflocation
- \ifconditional\headisdisplay % \ifdisplaysectionhead
- \else
- % obsolete: \noninterferingmarks
- \fi
- \fi
- \resetinteractionparameter\c!style
+ \strc_rendering_initialize_interaction
+ % delayed
+ \let\localheadsetup \strc_rendering_initialize_spacing % historic name
+ \let\headsetupspacing\strc_rendering_initialize_spacing}
+
+\def\strc_rendering_initialize_hsize_local
+ {\global\d_strc_rendering_local_leftoffset \leftskip
+ \global\d_strc_rendering_local_rightoffset\rightskip
+ % \forgetall
+ % \leftskip \d_strc_rendering_local_leftoffset % no stretch
+ % \rightskip\d_strc_rendering_local_rightoffset % no stretch
+ % \setlocalhsize
+ % \hsize\localhsize
+ % \forgetbothskips}
+ \scratchwidth\availablehsize
+ \forgetall
+ \hsize\scratchwidth}
+
+\def\strc_rendering_initialize_hsize_global
+ {\global\d_strc_rendering_local_leftoffset \zeropoint
+ \global\d_strc_rendering_local_rightoffset\zeropoint
+ \forgetall}
+
+\def\strc_rendering_initialize_interaction
+ {\resetinteractionparameter\c!style
\resetinteractionparameter\c!color
- \resetinteractionparameter\c!contrastcolor
- %\strictouterreferencestrue % tzt instelling
- \let\localheadsetup\dolocalheadsetup}
+ \resetinteractionparameter\c!contrastcolor}
% \setuphead[chapter] [style=\bfd,after=,hang=line] % fit broad 2
% \setuphead[section] [style=\bfc,after=,hang=line]
@@ -263,14 +275,24 @@
% \subsubsubsection{Test\\Test} \input tufte \page
\newdimen\d_strc_rendering_hang_height
+\newcount\n_strc_rendering_hang_lines
+
+\newdimen\d_strc_rendering_local_height
+\newdimen\d_strc_rendering_local_depth
+\newdimen\d_strc_rendering_local_lineheight
+
+\def\strc_rendering_initialize_line_state
+ {\global\d_strc_rendering_local_height\strutht
+ \global\d_strc_rendering_local_depth\strutdp
+ \global\d_strc_rendering_local_lineheight\lineheight}
-\def\hangheadplacement
+\def\strc_rendering_check_hang
{\begingroup
\openlineheight\d_strc_rendering_local_lineheight
\d_strc_rendering_hang_height\htdp\b_strc_rendering_head
\getnoflines\d_strc_rendering_hang_height
- \normalexpanded{\endgroup\noflines\the\dimexpr\noflines-\plusone\relax}% brrr
- \setbox\b_strc_rendering_head\hbox{\lower\noflines\d_strc_rendering_hang_height\box\b_strc_rendering_head}%
+ \normalexpanded{\endgroup\n_strc_rendering_hang_lines\the\numexpr\noflines-\plusone\relax}% brrr
+ \setbox\b_strc_rendering_head\hbox{\lower\n_strc_rendering_hang_lines\d_strc_rendering_hang_height\box\b_strc_rendering_head}%
\d_strc_rendering_hang_height\dimexpr\htdp\b_strc_rendering_head-\d_strc_rendering_local_height+\strutdp\relax
\ht\b_strc_rendering_head\strutht
\dp\b_strc_rendering_head\strutdp
@@ -278,22 +300,31 @@
\installcorenamespace{headplacementcheckhang}
-\setvalue{\??headplacementcheckhang\v!line }{\hangheadplacement
- \noflines\zerocount}
-\setvalue{\??headplacementcheckhang\v!broad }{\hangheadplacement
+\setvalue{\??headplacementcheckhang\v!line }{\strc_rendering_check_hang
+ \n_strc_rendering_hang_lines\zerocount}
+\setvalue{\??headplacementcheckhang\v!broad }{\strc_rendering_check_hang
\getnoflines\d_strc_rendering_hang_height}
-\setvalue{\??headplacementcheckhang\v!fit }{\hangheadplacement
+\setvalue{\??headplacementcheckhang\v!fit }{\strc_rendering_check_hang
\getrawnoflines\d_strc_rendering_hang_height}
-\setvalue{\??headplacementcheckhang\v!none }{\noflines\zerocount}
-\setvalue{\??headplacementcheckhang }{\noflines\zerocount}
-\setvalue{\??headplacementcheckhang\s!unknown}{\hangheadplacement
- \noflines\numexpr\p_hang-\plusone\relax}
-
-\def\endheadplacement#1%
- {\noflines\zerocount
- \ifconditional\headisdisplay % \ifdisplaysectionhead
- \edef\p_hang{\headparameter\c!hang}%
- \expandcheckedcsname\??headplacementcheckhang\p_hang\s!unknown
+\setvalue{\??headplacementcheckhang\v!none }{\n_strc_rendering_hang_lines\zerocount}
+\setvalue{\??headplacementcheckhang }{\n_strc_rendering_hang_lines\zerocount}
+\setvalue{\??headplacementcheckhang\s!unknown}{\strc_rendering_check_hang
+ \n_strc_rendering_hang_lines\numexpr\p_hang-\plusone\relax}
+
+\def\strc_rendering_initialize_line_hang
+ {\ifconditional\headisdisplay
+ \edef\p_hang{\headparameter\c!hang}%
+ \expandcheckedcsname\??headplacementcheckhang\p_hang\s!unknown
+ \relax
+ \else
+ \n_strc_rendering_hang_lines \zerocount
+ \d_strc_rendering_hang_height\zeropoint
+ \fi}
+
+\def\strc_rendering_stop_placement
+ {\n_strc_rendering_hang_lines\zerocount
+ \ifconditional\headisdisplay
+ \strc_rendering_initialize_line_hang
% kind of special, we want to snap heads also according to local specs local
\ifgridsnapping
\hbox\bgroup % extra hbox will trigger global snapper on top of local
@@ -307,31 +338,31 @@
\fi
\fi
\snaptogrid[\p_grid]\hbox
- {\hskip\dimexpr\localheadskip+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+ {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
\egroup
\else
\hbox
- {\hskip\dimexpr\localheadskip+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+ {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
\fi
\flushnotes % new, not really needed
\endgraf
\ifvmode
- \ifnum\noflines>\zerocount
- \dorecurse\noflines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked
+ \ifnum\n_strc_rendering_hang_lines>\zerocount
+ \dorecurse\n_strc_rendering_hang_lines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked
\fi
\nointerlineskip
\dosomebreak\nobreak
\fi
- #1%
+ \getheadsyncs
\else
\strut
\flushnotes % new, here since we're in par mode
\unhbox\b_strc_rendering_head
- #1%
- \hskip\numberheaddistance\!!plus\numberheaddistance\!!minus.25\dimexpr\numberheaddistance\relax
- \hskip\continuousheadsignal\ignorespaces
+ \getheadsyncs
+ \hskip\headnumberdistance\!!plus\headnumberdistance\!!minus.25\dimexpr\headnumberdistance\relax
+ \strc_sectioning_inject_continuous_signal
\fi
- \ifconditional\headisdisplay % \ifdisplaysectionhead
+ \ifconditional\headisdisplay
\ifvmode
\ifgridsnapping % important, font related depth, see comment
\prevdepth\strutdp
@@ -342,7 +373,7 @@
\fi
\egroup
\egroup
- \ifconditional\headisdisplay % \ifdisplaysectionhead
+ \ifconditional\headisdisplay
\useindentnextparameter\headparameter
\else
\nonoindentation % recently added, was a bug
@@ -362,55 +393,168 @@
% \input tufte \par
% \stopnarrower
-\installcorenamespace{headplacementalternative}
-\installcorenamespace{headplacementnature}
-
-\let\numberheadalternative\v!normal
-
-\unexpanded\def\defineheadplacement
- {\dodoubleargument\dodefineheadplacement}
-
-% \def\dodefineheadplacement[#1][#2]% #3#4
-% {\setvalue{\??headplacementnature#1}{#2}%
-% \setvalue{\??headplacementalternative#1}}
-
% \dodefineheadplacement[sectiona][vertical]{#1->#2}
% \dodefineheadplacement[sectionb][vertical]#1#2{#1->#2}
%
% \setuphead[section][alternative=sectiona]
% \setuphead[subsection][alternative=sectionb]
-\def\dodefineheadplacementyes[#1][#2]%#3#4%
- {\setvalue{\??headplacementnature#1}{#2}%
- \setvalue{\??headplacementalternative#1}##1##2}
+% \startsetups[\??headrenderings:\v!vertical:\v!sectiona]
+% ... there will be a more public namespace
+% \stopsetups
-\def\dodefineheadplacementnop[#1][#2]%
- {\setvalue{\??headplacementnature#1}{#2}%
- \setvalue{\??headplacementalternative#1}}
+\installcorenamespace{headplacementalternative}
+\installcorenamespace{headrenderings}
+\installcorenamespace{headalternative}
+
+\installcommandhandler \??headalternative {headalternative} \??headalternative % or just \??head
+
+\setupheadalternative
+ [%\c!width=\headparameter\c!width,
+ %\c!distance=\headparameter\c!distance,
+ \c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\currentheadalternative]
+
+\let\currentheadalternative \v!normal
+\let\currentheadrenderingsetup \empty
+\let\currentheadrenderingalternative\v!vertical
+
+\unexpanded\def\defineheadplacement % old mechanism
+ {\dodoubleargument\strc_rendering_define_placement}
-\def\dodefineheadplacement[#1][#2]%
+\def\strc_rendering_define_placement[#1][#2]%
{\doifnextbgroupelse
- {\dodefineheadplacementyes[#1][#2]}%
- {\dodefineheadplacementnop[#1][#2]}}
+ {\strc_rendering_define_placement_yes[#1][#2]}%
+ {\strc_rendering_define_placement_nop[#1][#2]}}
-\def\presetnumberheadalternative
- {\doifelsevalue{\??headplacementnature\numberheadalternative}\v!horizontal\setfalse\settrue\headisdisplay}
+\def\strc_rendering_define_placement_yes[#1][#2]%
+ {\defineheadalternative[#1][\c!alternative=#2,\c!renderingsetup=\??headrenderings:\v!command]%
+ \setuvalue{\??headplacementalternative#1}##1##2}
-\def\normalplacehead
- {\csname\??headplacementalternative\ifcsname\??headplacementalternative\numberheadalternative\endcsname\numberheadalternative\else\v!normal\fi\endcsname}
+\def\strc_rendering_define_placement_nop[#1][#2]%
+ {\defineheadalternative[#1][\c!alternative=#2,\c!renderingsetup=\??headrenderings:\v!command]%
+ \setuvalue{\??headplacementalternative#1}}
+
+% these can be used in setups:
+%
+% \headnumbercontent
+% \headtextcontent
+%
+% \headwidth
+% \headtextwidth
+% \headnumberdistance
+% \headnumberwidth
+% \headsetupspacing
+%
+% \headshownumber
+% \headisdisplay
+
+\let\headnumbercontent\empty
+\let\headtextcontent \empty
+
+\newdimen\headwidth
+\newdimen\headtextwidth
+\newdimen\headnumberdistance
+\newdimen\headnumberwidth
+
+% \newconditional\headshownumber % defined already
+% \newconditional\headisdisplay % defined already
+
+\unexpanded\def\strc_rendering_initialize_alternatives
+ {\edef\currentheadalternative {\headparameter \c!alternative}%
+ \edef\currentheadrenderingsetup {\headalternativeparameter\c!renderingsetup}%
+ \edef\currentheadrenderingalternative{\headalternativeparameter\c!alternative}%
+ \ifx\currentheadrenderingalternative\empty
+ \let\currentheadrenderingalternative\v!vertical
+ \fi
+ \ifx\currentheadrenderingalternative\v!horizontal
+ \global\setfalse\headisdisplay % global
+ \else
+ \global\settrue\headisdisplay % global
+ \fi}
+
+\unexpanded\def\strc_rendering_initialize_dimensions
+ {\headwidth \headparameter\c!width \relax % \zeropoint == unset
+ \headnumberwidth \headparameter\c!numberwidth\relax % \zeropoint == unset
+ \headnumberdistance\headparameter\c!distance \relax
+ \headtextwidth \headparameter\c!textwidth \relax} % \zeropoint == unset
+
+\unexpanded\def\headtextcontent
+ {\begingroup
+ \strc_rendering_initialize_style_and_color\c!textstyle\c!textcolor
+ \headparameter\c!commandbefore\relax
+ \ifcsname\currentheadhash\c!deeptextcommand\endcsname
+ \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname
+ \fi
+ \ifconditional\headisdisplay
+ % struts can be nilled with \setnostrut
+ \headparameter\c!textcommand{\setstrut\begstrut\getheadtitle\endstrut}%
+ \global\d_strc_rendering_local_height\strutht
+ \global\d_strc_rendering_local_depth\strutdp
+ \global\d_strc_rendering_local_lineheight\lineheight
+ \headparameter\c!commandafter\relax
+ \endgraf
+ \else
+ \headparameter\c!textcommand{\getheadtitle}%
+ \headparameter\c!commandafter\relax
+ \fi
+ \endgroup}
-\def\setheaddisplay % used in strc-sec
- {\doifelsevalue{\??headplacementnature\headparameter\c!alternative}\v!horizontal
- \setfalse\settrue\headisdisplay}
+\unexpanded\def\headnumbercontent
+ {\begingroup
+ \strc_rendering_initialize_style_and_color\c!numberstyle\c!numbercolor
+ \ifcsname\currentheadhash\c!deepnumbercommand\endcsname
+ \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname
+ \fi
+ \ifconditional\headisdisplay
+ % can be nilled with \setnostrut
+ \headparameter\c!numbercommand{\setstrut\begstrut\getheadnumber\endstrut}%
+ \else
+ \headparameter\c!numbercommand{\getheadnumber}%
+ \fi
+ \endgroup}
-\defineheadplacement[\v!paragraph][\v!vertical]#1#2%
- {\vbox
- {\localheadsetup
- \begstrut
- \ifconditional\headshownumber % \ifheadnumbercontent
- #1\hskip\numberheaddistance
- \fi
- #2}}
+\unexpanded\def\strc_rendering_inject_number_and_text
+ {\edef\p_command{\headparameter\c!command}% assumes \unexpanded definition
+ \ifx\p_command\empty
+ \directsetup\currentheadrenderingsetup
+ \else
+ \p_command\headnumbercontent\headtextcontent
+ \fi}
+
+\unexpanded\def\strc_rendering_inject_text
+ {\edef\p_command{\headparameter\c!command}% assumes \unexpanded definition
+ \ifx\p_command\empty
+ \directsetup\currentheadrenderingsetup
+ \else
+ \p_command\empty\headtextcontent
+ \fi}
+
+\startsetups[\??headrenderings:\v!command]
+ \csname\??headplacementalternative\currentheadalternative\endcsname \headnumbercontent \headtextcontent
+\stopsetups
+
+% obsolete
+%
+% \def\normalplacehead % hooks into \c!command
+% {\csname\??headplacementalternative\ifcsname\??headplacementalternative\currentheadalternative\endcsname\currentheadalternative\else\v!normal\fi\endcsname}
+
+\defineheadalternative
+ [\v!paragraph]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!paragraph]
+
+\startsetups[\??headrenderings:\v!paragraph]
+ \vbox {
+ \headsetupspacing
+ \begstrut
+ \ifconditional\headshownumber % \ifheadnumbercontent
+ \headnumbercontent
+ \hskip\headnumberdistance
+ \fi
+ \headtextcontent
+ }
+\stopsetups
% \setuphead
% [chapter]
@@ -419,123 +563,183 @@
% \chapter{Oeps oeps oeps} \input tufte \section{Oeps}
% \chapter{Oeps oeps oeps} \section{Oeps} \input tufte
-\defineheadplacement[\v!normal][\v!vertical]#1#2%
- {\vbox
- {\localheadsetup
- \edef\headwidth {\headparameter\c!width }%
- \edef\headnumberwidth{\headparameter\c!numberwidth}%
- \edef\headtextwidth {\headparameter\c!textwidth }%
- \ifconditional\headshownumber
- \ifx\headwidth\empty
- \else
- \ifx\headnumberwidth\empty
- \ifx\headtextwidth\empty\else
- \edef\headnumberwidth{\the\dimexpr\headwidth-\headtextwidth\relax}%
+\defineheadalternative
+ [\v!normal]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!normal]
+
+\startsetups[\??headrenderings:\v!normal]
+ \vbox {
+ \headsetupspacing
+ \ifconditional\headshownumber
+ \ifdim\headwidth=\zeropoint \else
+ \ifdim\headnumberwidth=\zeropoint
+ \ifdim\headtextwidth=\zeropoint \else
+ \headnumberwidth\dimexpr\headwidth-\headtextwidth\relax
+ \fi
+ \else
+ \ifdim\headtextwidth=\zeropoint
+ \headtextwidth\dimexpr\headwidth-\headnumberwidth\relax
+ \fi
+ \fi
+ \hsize\headwidth
\fi
- \else
- \ifx\headtextwidth\empty
- \edef\headtextwidth{\the\dimexpr\headwidth-\headnumberwidth\relax}%
+ \ifdim\headnumberwidth=\zeropoint\else
+ \headnumberdistance\zeropoint
\fi
- \fi
- \hsize\headwidth
- \fi
- \ifx\headnumberwidth\empty\else
- \let\numberheaddistance\!!zeropoint
+ \setbox\scratchbox\hbox \ifdim\headnumberwidth=\zeropoint\else to \headnumberwidth\fi{\headnumbercontent}
+ \scratchdimen\dimexpr\wd\scratchbox+\headnumberdistance\relax
+ \ifdim\headtextwidth=\zeropoint\else
+ \hsize\dimexpr\scratchdimen+\headtextwidth\relax
+ \fi
+ \hangindent\scratchdimen
+ \hangafter \plusone
+ \noindent
+ \box\scratchbox
+ \hskip\headnumberdistance
+ \else
+ \ifdim\headtextwidth=\zeropoint
+ \ifdim\headwidth=\zeropoint \else
+ \hsize\headwidth
+ \fi
+ \else
+ \hsize\headtextwidth
+ \fi
+ \noindent
\fi
- \setbox\scratchbox\hbox \ifx\headnumberwidth\empty\else to \headnumberwidth\fi{{#1}}%
- \scratchdimen\dimexpr\wd\scratchbox+\numberheaddistance\relax
- \ifx\headtextwidth\empty\else
- \hsize\dimexpr\scratchdimen+\headparameter\c!textwidth\relax
+ \headtextcontent
+ }
+\stopsetups
+
+\defineheadalternative
+ [\v!inmargin]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!inmargin]
+
+\startsetups[\??headrenderings:\v!inmargin]
+ \vbox {
+ \headsetupspacing
+ \begstrut % use one \strut here!
+ \dontleavehmode % in case there is no strut, else side effects with llap
+ \ifconditional\headshownumber
+ \llap {
+ \hbox {
+ \hfill
+ \headnumbercontent
+ \hskip\dimexpr\d_strc_rendering_local_leftoffset+\doifoddpageelse\leftmargindistance\rightmargindistance\relax
+ }
+ }
\fi
- \hangindent\scratchdimen
- \hangafter \plusone
- \noindent
- \box\scratchbox
- \hskip\numberheaddistance
- \else
- \ifx\headtextwidth\empty
- \ifx\headwidth\empty
- \else
- \hsize\headwidth
- \fi
- \else
- \hsize\headtextwidth
+ \headtextcontent
+ }
+\stopsetups
+
+\defineheadalternative
+ [\v!inmargin]
+ [\v!margin]
+
+% \startsetups[\??headrenderings:\v!vertical:\v!margin]
+% \directsetup{\??headrenderings:\v!vertical:\v!inmargin}
+% \stopsetups
+
+\defineheadalternative
+ [\v!middle]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!middle]
+
+\startsetups[\??headrenderings:\v!middle]
+ \vbox {
+ \headsetupspacing
+ \veryraggedcenter
+ \let\\\endgraf
+ \let\crlf\endgraf
+ \ifconditional\headshownumber
+ \strut
+ \headnumbercontent
+ \par
\fi
- \noindent
- \fi
- #2}}
-
-\unexpanded\def\placeheadmarginalternative#1#2%
- {\vbox
- {\localheadsetup
- \begstrut % use one \strut here!
- \dontleavehmode % in case there is no strut, else side effects with llap
- \ifconditional\headshownumber
- \llap{\hbox{\hfill{#1}\hskip\dimexpr\localheadskip+\doifoddpageelse\leftmargindistance\rightmargindistance\relax}}% introduces whitespace
- \fi
- {#2}}}
-
-\defineheadplacement[\v!inmargin][\v!vertical]#1#2%
- {\placeheadmarginalternative{#1}{#2}}
-
-\defineheadplacement[\v!margin] [\v!vertical]#1#2%
- {\placeheadmarginalternative{#1}{#2}}
-
-\defineheadplacement[\v!middle][\v!vertical]#1#2%
- {\vbox
- {\localheadsetup
- \veryraggedcenter
- \let\\\endgraf
- \let\crlf\endgraf
- \ifconditional\headshownumber
- \strut#1\par
- \fi
- \begstrut#2}}
-
-\defineheadplacement[\v!text][\v!horizontal]#1#2%
- {\bgroup
- \localheadsetup % no stretch in distance
- \ifconditional\headshownumber
- {#1}\kern\numberheaddistance
- \fi
- {\begstrut#2}%
- \egroup}
-
-\unexpanded\def\placeheadlohialternative#1#2#3%
- {\ifconditional\headshownumber
- \setbox0\hbox{#2}
- \setbox2=#1{\localheadsetup\advance\hsize-\wd0\relax#3}%
- \hbox{\box0\hskip\numberheaddistance\box2}%
- \else
- #1{\localheadsetup\noindent#3}%
- \fi}
+ \begstrut
+ \headtextcontent
+ \endstrut
+ }
+\stopsetups
+
+\defineheadalternative
+ [\v!text]
+ [\c!alternative=\v!horizontal,
+ \c!renderingsetup=\??headrenderings:\v!text]
+
+\startsetups[\??headrenderings:\v!text]
+ \begingroup
+ \headsetupspacing % no stretch in distance
+ \ifconditional\headshownumber
+ \headnumbercontent
+ \kern\headnumberdistance
+ \fi
+ \begstrut
+ \headtextcontent
+ \endstrut
+ \endgroup
+\stopsetups
% onder/boven lijnt het nummer op de onderste/bovenste regel uit van een meerregelige kop
-\defineheadplacement[\v!bottom][\v!vertical]#1#2%
- {\placeheadlohialternative\vbox{#1}{#2}}
-
-\defineheadplacement[\v!top][\v!vertical]#1#2%
- {\placeheadlohialternative\vtop{#1}{#2}}
-
-% helpers
-
-% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em]
-%
-% \defineheadplacement[MyTest][horizontal]#1#2%
-% {\startlocalheadsetup
-% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay
-% \ChapterInMargin{\strut#2}% zero destination, ref okay
-% \stoplocalheadsetup}
-%
-% \setuphead
-% [chapter]
-% [alternative=MyTest]
-
-\unexpanded\def\headhbox{\hbox\headreferenceattributes}
-\unexpanded\def\headvbox{\vbox\headreferenceattributes}
-
-\unexpanded\def\startlocalheadsetup{\bgroup\localheadsetup}
-\unexpanded\def\stoplocalheadsetup {\egroup}
+\defineheadalternative
+ [\v!bottom]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!bottom]
+
+\startsetups[\??headrenderings:\v!bottom]
+ \ifconditional\headshownumber
+ \setbox0\hbox {
+ \headnumbercontent
+ }
+ \setbox2\vbox {
+ \headsetupspacing
+ \advance\hsize-\wd0\relax
+ \headtextcontent
+ }
+ \hbox {
+ \box0
+ \hskip\headnumberdistance
+ \box2
+ }
+ \else
+ \vbox {
+ \headsetupspacing
+ \noindent
+ \headtextcontent
+ }
+ \fi
+\stopsetups
+
+\defineheadalternative
+ [\v!top]
+ [\c!alternative=\v!vertical,
+ \c!renderingsetup=\??headrenderings:\v!top]
+
+\startsetups[\??headrenderings:\v!top]
+ \ifconditional\headshownumber
+ \setbox0\hbox {
+ \headnumbercontent
+ }
+ \setbox2\vtop {
+ \headsetupspacing
+ \advance\hsize-\wd0\relax
+ \headtextcontent
+ }
+ \hbox {
+ \box0
+ \hskip\headnumberdistance
+ \box2
+ }
+ \else
+ \vtop{
+ \headsetupspacing
+ \noindent
+ \headtextcontent
+ }
+ \fi
+\stopsetups
\protect \endinput
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 7cf6921cb..ea087185c 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -15,7 +15,227 @@
\unprotect
-\ifdefined \v!block \else \def\v!block{block} \fi
+\installcorenamespace{structure}
+
+\installdirectcommandhandler \??structure {structure} % unchecked, so we need to initialize used parameters
+
+\setupstructure % not a user command so we might need to change the name
+ [\c!number=,
+ \c!level=,
+ \c!name=,
+ \c!title=,
+ \c!bookmark=,
+ \c!marking=,
+ \c!list=,
+ \c!label=,
+ \c!coupling=,
+ \c!ownnumber=,
+ \c!sectionseparatorset=\s!default,
+ \c!sectionconversionset=\s!default,
+ \c!sectionstopper=,
+ \c!sectionstarter=,
+ \c!sectionsegments=,
+ \c!sectionresetset=,
+ \c!reference=,
+ \c!backreference=,
+ \c!expansion=\v!no,
+ \c!xmlsetup=,
+ \s!catcodes=,
+ \c!saveinlist=\v!yes]
+
+% maybe flags for list, bm, mark
+
+\def\m_strc_references_prefix_yes{+}
+\def\m_strc_references_prefix_nop{-}
+
+\def\strc_sectioning_set_reference_prefix
+ {\ifx\currentstructurereferenceprefix\empty
+ % nothing
+ \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_yes
+ \global\advance\prefixcounter \plusone % temp here
+ \setupglobalreferenceprefix[\the\prefixcounter]%
+ \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_nop
+ \setupglobalreferenceprefix[]%
+ \else
+ \setupglobalreferenceprefix[\currentstructurereferenceprefix]%
+ \fi\fi\fi
+ \let\currentstructurereferenceprefix\referenceprefix}
+
+% why xdef ?
+
+\setupstructure
+ [\c!label={\headparameter{\currentsectionblock\c!label}},
+ \c!incrementnumber=\ifconditional\c_strc_sectioning_increment\v!yes\else\v!no\fi, % not that needed
+ \c!saveinlist=\ifconditional\c_strc_sectioning_to_list\v!yes\else\v!no\fi,
+ \c!level=\currentheadlevel,
+ \c!number=\ifconditional\c_strc_sectioning_increment\ifconditional\headshownumber\v!yes\else\v!no\fi\else\v!no\fi,
+ \c!expansion=\headparameter\c!expansion,
+ \c!xmlsetup=\headparameter\c!xmlsetup,
+ \s!catcodes=\headparameter\s!catcodes,
+ \c!sectionresetset=\headparameter\c!sectionresetset,
+ \c!sectionseparatorset=\headparameter\c!sectionseparatorset,
+ \c!sectionconversionset=\headparameter\c!sectionconversionset,
+ \c!sectionconversion=\headparameter\c!conversion, % just for compatibility
+ \c!sectionstarter=\headparameter\c!sectionstarter,
+ \c!sectionstopper=\headparameter\c!sectionstopper,
+ \c!sectionset=\headparameter\c!sectionset,
+ \c!sectionsegments=\headparameter\c!sectionsegments,
+ \c!reference=\headparameter\c!reference,
+ \c!referenceprefix=\headparameter\c!referenceprefix]
+
+\unexpanded\def\strc_sectioning_register#1#2% #1=interfaced-settings, #2=optional user data (not yet supported)
+ {\begingroup
+ \setupstructure[#1]%
+ \xdef\currentstructurename {\structureparameter\c!name}%
+ \xdef\currentstructurecoupling {\structureparameter\c!coupling}%
+ \xdef\currentstructureownnumber {\structureparameter\c!ownnumber}% optional own number
+ \xdef\currentstructurelevel {\structureparameter\c!level}%
+ \edef\currentstructureexpansion {\structureparameter\c!expansion}%
+ \xdef\currentstructurexmlsetup {\structureparameter\c!xmlsetup}%
+ \xdef\currentstructurecatcodes {\structureparameter\s!catcodes}%
+ \xdef\currentstructurelabel {\structureparameter\c!label}%
+ \xdef\currentstructurereference {\structureparameter\c!reference}%
+ \xdef\currentstructurereferenceprefix{\structureparameter\c!referenceprefix}%
+ \xdef\currentstructurebackreference {\structureparameter\c!backreference}%
+ \xdef\currentstructureshownumber {\structureparameter\c!number}%
+ \xdef\currentstructuresaveinlist {\structureparameter\c!saveinlist}%
+ \xdef\currentstructureincrementnumber{\structureparameter\c!incrementnumber}%
+ \ifx\currentstructureexpansion\s!xml
+ \xmlstartraw
+ \xdef\currentstructuretitle {\structureparameter\c!title}%
+ \xdef\currentstructurebookmark{\structureparameter\c!bookmark}%
+ \xdef\currentstructuremarking {\structureparameter\c!marking}%
+ \xdef\currentstructurelist {\structureparameter\c!list}%
+ \xmlstopraw
+ \ifx\currentstructurelist\empty
+ \globallet\currentstructurelist\currentstructuretitle
+ \fi
+ \globallet\currentstructurecoding\s!xml
+ \else
+ \ifx\currentstructureexpansion\v!yes
+ \xdef\currentstructuretitle {\structureparameter\c!title}%
+ \xdef\currentstructurebookmark{\structureparameter\c!bookmark}%
+ \xdef\currentstructuremarking {\structureparameter\c!marking}%
+ \xdef\currentstructurelist {\structureparameter\c!list}%
+ \else
+ \xdef\currentstructuretitle {\detokenizedstructureparameter\c!title}%
+ \xdef\currentstructurebookmark{\detokenizedstructureparameter\c!bookmark}%
+ \xdef\currentstructuremarking {\detokenizedstructureparameter\c!marking}%
+ \xdef\currentstructurelist {\detokenizedstructureparameter\c!list}%
+ \iflocation \ifx\currentstructurebookmark\empty
+ \begingroup
+ \simplifycommands
+ \xdef\currentstructurebookmark{\detokenize\expandafter{\normalexpanded{\structureparameter\c!title}}}%
+ \endgroup
+ \fi \fi
+ \fi
+ \ifx\currentstructurelist\empty
+ \globallet\currentstructurelist\currentstructuretitle
+ \fi
+ \globallet\currentstructurecoding\s!tex
+ \fi
+ \setnextinternalreference
+ \strc_sectioning_set_reference_prefix
+ \xdef\currentstructurenumber{\ctxlua{ % todo: combine with next call, adapt marks accordingly
+ structures.sections.somelevel {
+ references = {
+ internal = \nextinternalreference,
+ block = "\currentsectionblock",
+ reference = "\currentstructurereference",
+ referenceprefix = "\currentstructurereferenceprefix",
+ backreference = "\currentstructurebackreference",
+ },
+ directives = {
+ resetset = "\structureparameter\c!sectionresetset",
+ },
+ metadata = {
+ kind = "section",
+ name = "\currentstructurename",
+ catcodes = \the\ifx\currentstructurecatcodes\empty\catcodetable\else\csname\currentstructurecatcodes\endcsname\fi,
+ coding = "\currentstructurecoding",
+ \ifx\currentstructurecoding\s!xml
+ xmlroot = "\xmldocument",
+ \fi
+ \ifx\currentstructurexmlsetup\empty \else
+ xmlsetup = "\currentstructurexmlsetup",
+ \fi
+ \ifx\currentstructuresaveinlist\v!no
+ nolist = true,
+ \fi
+ \ifx\currentstructureincrementnumber\v!yes
+ increment = "\currentstructureincrementnumber",
+ \fi
+ },
+ titledata = { % we can add mark and reference
+ label = \!!bs\detokenize\expandafter{\currentstructurelabel }\!!es,
+ title = \!!bs\detokenize\expandafter{\currentstructuretitle }\!!es,
+ \ifx\currentstructurebookmark\currentstructuretitle \else
+ bookmark = \!!bs\detokenize\expandafter{\currentstructurebookmark }\!!es,
+ \fi
+ \ifx\currentstructuremarking\currentstructuretitle \else
+ marking = \!!bs\detokenize\expandafter{\currentstructuremarking }\!!es,
+ \fi
+ \ifx\currentstructuresaveinlist\v!no \else
+ \ifx\currentstructurelist\currentstructuretitle \else
+ list = \!!bs\detokenize\expandafter{\currentstructurelist}\!!es,
+ \fi
+ \fi
+ },
+ numberdata = {
+ % needed ?
+ block = "\currentsectionblock",
+ hidenumber = \ifx\currentstructureshownumber\v!no true\else nil\fi, % titles
+ % so far
+ separatorset = "\structureparameter\c!sectionseparatorset",
+ conversion = "\structureparameter\c!sectionconversion", % for good old times sake
+ conversionset = "\structureparameter\c!sectionconversionset",
+ starter = \!!bs\structureparameter\c!sectionstarter\!!es,
+ stopper = \!!bs\structureparameter\c!sectionstopper\!!es,
+ set = "\structureparameter\c!sectionset",
+ segments = "\structureparameter\c!sectionsegments",
+ ownnumber = "\currentstructureownnumber",
+ },
+ userdata = \!!bs\detokenize{#2}\!!es % will be converted to table at the lua end
+ }
+ }}%
+ \xdef\currentstructurelistnumber{\ctxcommand{addtolist(structures.sections.current())}}%
+ % \currentstructuresynchronize has to be called someplace, since it introduces a node
+ \setstructuresynchronization\currentstructurelistnumber
+ \endgroup}
+
+\let\currentstructurenumber \!!zerocount
+\let\currentsectioncountervalue \!!zerocount % redefined later
+\let\previoussectioncountervalue\!!zerocount % redefined later
+
+% We can access the (stored) data with the following macros.
+%
+% \def\MyHeadCommand #1#2{\framed{#1}\framed{#2 / \structureuservariable{subtitle}}}
+% \def\MyListCommand#1#2#3{\externalfigure[\structurelistuservariable{figure}][height=5mm]#2}
+%
+% \setuphead[chapter][command=\MyHeadCommand]
+% \setuplist[chapter][alternative=command,command=\MyListCommand]
+%
+% \starttext
+% \setupheadertexts[chapter]
+% \setupinteraction[state=start]
+% \placebookmarks[chapter]
+% \placelist[chapter]
+% \startchapter[ownnumber=10,title=Ton,list=Hans,marking=Kees,bookmark=Bram][figure=cow.pdf,subtitle=oeps]
+% \stopchapter
+% \stoptext
+
+% todo: #1 => "#1" ... adapt lua code for name and number
+
+\def\structurenumber {\ctxcommand{structurenumber()}}
+\def\structuretitle {\ctxcommand{structuretitle()}}
+\def\structurevariable #1{\ctxcommand{structurevariable("#1")}}
+\def\structureuservariable #1{\ctxcommand{structureuservariable("#1")}}
+\def\structurecatcodedget #1{\ctxcommand{structurecatcodedget("#1")}} % bad name
+\def\structuregivencatcodedget #1#2{\ctxcommand{structuregivencatcodedget("#1",\number#2)}} % bad name
+\def\structureautocatcodedget #1#2{\ctxcommand{structureautocatcodedget ("#1","#2")}}
+
+\def\namedstructurevariable #1#2{\ctxcommand{namedstructurevariable ("#1","#2")}}
+\def\namedstructureuservariable#1#2{\ctxcommand{namedstructureuservariable("#1","#2")}}
% compatibility issue:
%
@@ -45,7 +265,6 @@
\newconditional\c_strc_rendering_continuous % not used (mkii ?)
-
\def\setstructurelevel #1#2{\ctxlua{structures.sections.setlevel("#1","#2")}} % name, level|parent
\def\getstructurelevel #1{\ctxlua{structures.sections.getcurrentlevel("#1")}}% name
\def\setstructurenumber #1#2{\ctxlua{structures.sections.setnumber(#1,"#2")}} % level, number (+/-)
@@ -77,6 +296,62 @@
\installcommandhandler \??head {head} \??head
+\setuphead [%
+ %\c!after=,
+ %\c!align=,
+ %\c!aligntitle=,
+ \c!alternative=\v!normal,
+ %\c!before=,
+ %\c!color=,
+ %\c!command=,
+ \c!continue=\v!yes,
+ %\c!coupling=,
+ %\c!deepnumbercommand=,
+ %\c!deeptextcommand=,
+ %\c!default=,
+ \c!distance=\zeropoint,
+ \c!textwidth=\zeropoint, % signal too
+ \c!numberwidth=\zeropoint, % signal too
+ \c!width=\zeropoint, % signal too
+ \c!expansion=\v!no,
+ %\c!file=,
+ %\c!footer=,
+ %\c!grid=,
+ \c!hang=\v!none,
+ %\c!header=,
+ \c!incrementnumber=\v!yes,
+ \c!indentnext=\v!no,
+ %\c!label=,
+ %\c!limittext=\languageparameter\c!limittext,
+ \c!margin=\zeropoint,
+ %\c!margintext=,
+ \c!number=\v!yes,
+ \c!numbercolor=\headparameter\c!color,
+ \c!textcolor=\headparameter\c!color,
+ \c!numberstyle=\headparameter\c!style,
+ \c!textstyle=\headparameter\c!style,
+ %\c!numbercommand=,
+ %\c!textcommand=,
+ \c!ownnumber=\v!no,
+ %\c!page=,
+ \c!placehead=\v!yes,
+ \c!sectionconversionset=\s!default,
+ \c!sectionnumber=\v!yes,
+ %\c!sectionsegments=,
+ \c!sectionseparatorset=\s!default,
+ \c!sectionset=\v!all,
+ \c!interlinespace=,
+ %\c!sectionstopper=,
+ %\c!sectionstarter=,
+ %\c!strut=,
+ %\c!style=,
+ %\c!text=,
+ %\c!tolerance=,
+ %\c!beforesection=\directsetup{document:\currenthead:start}, % these might become defaults i.e. acpect document: namespace
+ %\c!insidesection=\directsetup{document:\currenthead:inside}, % these might become defaults i.e. acpect document: namespace
+ %\c!aftersection=\directsetup{document:\currenthead:stop}, % these might become defaults i.e. acpect document: namespace
+ ]
+
\let\setupheads\setuphead % will go
\appendtoks
@@ -135,28 +410,28 @@
\appendtoks
% \setevalue{\e!next \currenthead}{\donexthead [\currenthead]}%
- \setevalue{\e!start\currenthead}{\dostarthead[\currenthead]}%
- \setevalue{\e!stop \currenthead}{\dostophead [\currenthead]}%
+ \setuevalue{\e!start\currenthead}{\strc_sectioning_start[\currenthead]}%
+ \setuevalue{\e!stop \currenthead}{\strc_sectioning_stop [\currenthead]}%
\to \everydefinehead
\appendtoks
\doifelse{\headparameter\c!ownnumber}\v!yes
- {\setevalue\currenthead{\dohandleheadown[\currenthead]}}
- {\setevalue\currenthead{\dohandleheadnop[\currenthead]}}%
+ {\setuevalue\currenthead{\strc_sectioning_handle_own[\currenthead]}}
+ {\setuevalue\currenthead{\strc_sectioning_handle_nop[\currenthead]}}%
\to \everysetuphead
\let\currentnamedsection\empty
\unexpanded\def\startnamedsection
- {\dotripleempty\dostartnamedsection}
+ {\dotripleempty\strc_sectioning_start_named_section}
-\def\dostartnamedsection[#1]% [#2][#3]
+\unexpanded\def\strc_sectioning_start_named_section[#1]% [#2][#3]
{\pushmacro\currentnamedsection
\edef\currentnamedsection{#1}%
- \normalexpanded{\dodostarthead[\currentnamedsection]}} % [#2][#3]
+ \normalexpanded{\strc_sectioning_start_named_section_indeed[\currentnamedsection]}} % [#2][#3]
\unexpanded\def\stopnamedsection
- {\normalexpanded{\dostophead[\currentnamedsection]}%
+ {\normalexpanded{\strc_sectioning_stop[\currentnamedsection]}%
\popmacro\currentnamedsection}
% structure sections (the parents of chapter etc)
@@ -254,42 +529,42 @@
% head construction
-\unexpanded\def\dohandleheadown{\dodoubleempty\dodohandleheadown} % [ref] {nr} {title}
-\unexpanded\def\dohandleheadnop{\dodoubleempty\dodohandleheadnop} % [ref] {title}
-\unexpanded\def\dostarthead {\dotripleempty\dodostarthead} % [settings] [userdata] !!! also used at lua end
+\unexpanded\def\strc_sectioning_handle_own{\dodoubleempty\strc_sectioning_handle_own_indeed} % [ref] {nr} {title}
+\unexpanded\def\strc_sectioning_handle_nop{\dodoubleempty\strc_sectioning_handle_nop_indeed} % [ref] {title}
+\unexpanded\def\strc_sectioning_start {\dotripleempty\strc_sectioning_start_named_section_indeed} % [settings] [userdata] !!! also used at lua end
\newconditional\currentstructureown
\newtoks\everybeforehead % hook, todo: before/after keys
\newtoks\everyafterhead % hook, todo: before/after keys
-\unexpanded\def\dodohandleheadown[#1][#2]#3#4%
+\unexpanded\def\strc_sectioning_handle_own_indeed[#1][#2]#3#4%
{\settrue\currentstructureown
\triggerautostructurelevel
- \dohandlehead{#1}{\c!reference={#2},\c!ownnumber={#3},\c!title={#4}}{}} % name ref nr title --
+ \strc_sectioning_handle{#1}{\c!reference={#2},\c!ownnumber={#3},\c!title={#4}}{}} % name ref nr title --
-\unexpanded\def\dodohandleheadnop[#1][#2]% for taco: [key=value] variant
+\unexpanded\def\strc_sectioning_handle_nop_indeed[#1][#2]% for taco: [key=value] variant
{\setfalse\currentstructureown
\triggerautostructurelevel
- \doifassignmentelse{#2}\dodohandleheadnopA\dodohandleheadnopB{#1}{#2}}
+ \doifassignmentelse{#2}\strc_sectioning_handle_nop_indeed_yes\strc_sectioning_handle_nop_indeed_nop{#1}{#2}}
-\unexpanded\def\dodohandleheadnopA#1#2%
- {\dohandlehead{#1}{#2}{}}
+\unexpanded\def\strc_sectioning_handle_nop_indeed_yes#1#2%
+ {\strc_sectioning_handle{#1}{#2}{}}
-\unexpanded\def\dodohandleheadnopB#1#2#3%
- {\dohandlehead{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title --
+\unexpanded\def\strc_sectioning_handle_nop_indeed_nop#1#2#3%
+ {\strc_sectioning_handle{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title --
-\unexpanded\def\dodostarthead[#1][#2][#3]% for the moment no grouping, too annoying with page breaks
+\unexpanded\def\strc_sectioning_start_named_section_indeed[#1][#2][#3]% for the moment no grouping, too annoying with page breaks
{\setfalse\currentstructureown
%\globalpushmacro\currenthead % this does not work out well
\xdef\currenthead{#1}%
\setsystemmode\currenthead % new, also here now
\headparameter\c!beforesection % beware, no users vars set yet
\the\everybeforehead
- \dohandlehead{#1}{#2}{#3}% name -- -- -- userdata (we might move the tagged to here)
+ \strc_sectioning_handle{#1}{#2}{#3}% name -- -- -- userdata (we might move the tagged to here)
\headparameter\c!insidesection}
-\unexpanded\def\dostophead[#1]% !!! also used at lua end
+\unexpanded\def\strc_sectioning_stop[#1]% !!! also used at lua end
{\dostoptagged
\dostoptagged
%\globalpopmacro\currenthead % so we do a hard recover
@@ -298,70 +573,64 @@
\the\everyafterhead
\resetsystemmode\currenthead} % new, also here now
-% \unexpanded\def\donexthead[#1][#2][#3]% obsolete
-% {\setfalse\currentstructureown
-% \xdef\currenthead{#1}%
-% \dohandlehead{#1}{#2}{#3}} % name -- -- -- userdata
+\let\dostarthead\strc_sectioning_start % used at lua end
+\let\dostophead \strc_sectioning_stop % used at lua end
% \newconditional\structurereversesectionnumbers % todo: key/val
-\newconditional\headtolist
-\newconditional\headdoincrement
-\newconditional\headdoplace
-\newconditional\headleaveempty
-\newconditional\headhidden
-\newconditional\headshownumber
-\newconditional\headisdisplay
+\newconditional\c_strc_sectioning_to_list
+\newconditional\c_strc_sectioning_increment
+\newconditional\c_strc_sectioning_place
+\newconditional\c_strc_sectioning_empty
+\newconditional\c_strc_sectioning_hidden
+
+\newconditional\headshownumber % public
+\newconditional\headisdisplay % public
-\setvalue{\??headincrement\v!yes }{\settrue \headdoincrement\settrue \headtolist}
-\setvalue{\??headincrement\v!no }{\setfalse\headdoincrement\setfalse\headtolist}
-\setvalue{\??headincrement\v!list }{\setfalse\headdoincrement\settrue \headtolist}
-\setvalue{\??headincrement\s!empty}{\settrue \headdoincrement\settrue \headtolist}
+\setvalue{\??headincrement\v!yes }{\settrue \c_strc_sectioning_increment\settrue \c_strc_sectioning_to_list}
+\setvalue{\??headincrement\v!no }{\setfalse\c_strc_sectioning_increment\setfalse\c_strc_sectioning_to_list}
+\setvalue{\??headincrement\v!list }{\setfalse\c_strc_sectioning_increment\settrue \c_strc_sectioning_to_list}
+\setvalue{\??headincrement\s!empty}{\settrue \c_strc_sectioning_increment\settrue \c_strc_sectioning_to_list}
-\def\setheadincrement
+\unexpanded\def\strc_sectioning_initialize_increment
{\edef\currentheadincrement{\headparameter\c!incrementnumber}%
\ifcsname\??headincrement\currentheadincrement\endcsname
\csname\??headincrement\currentheadincrement\endcsname
\else
- \settrue \headdoincrement\settrue \headtolist
+ \settrue \c_strc_sectioning_increment\settrue \c_strc_sectioning_to_list
% \filterheadnumber
\fi}
\def\filterheadnumber
- {\settrue\headdoincrement
- \settrue\headtolist
+ {\settrue\c_strc_sectioning_increment
+ \settrue\c_strc_sectioning_to_list
\ifx\currentproduct\empty
% todo : filter from other toc (number, file, title)
% use : \currentheadincrement as spec
\fi}
\setvalue{\??headplace\v!yes}%
- {\setfalse\headleaveempty
- \settrue \headdoplace
- \setfalse\headhidden}
+ {\setfalse\c_strc_sectioning_empty
+ \settrue \c_strc_sectioning_place
+ \setfalse\c_strc_sectioning_hidden}
\setvalue{\??headplace\v!empty}%
- {\settrue \headleaveempty
- \settrue \headdoplace
- \setfalse\headhidden}
+ {\settrue \c_strc_sectioning_empty
+ \settrue \c_strc_sectioning_place
+ \setfalse\c_strc_sectioning_hidden}
\setvalue{\??headplace\v!no}%
- {\settrue \headleaveempty
- \setfalse\headdoplace
- \setfalse\headhidden}
+ {\settrue \c_strc_sectioning_empty
+ \setfalse\c_strc_sectioning_place
+ \setfalse\c_strc_sectioning_hidden}
\setvalue{\??headplace\v!hidden}%
- {\settrue \headleaveempty
- \setfalse\headdoplace
- \settrue \headhidden}
-
-\def\setheadplacement
- {\executeifdefined
- {\??headplace\headparameter\c!placehead}
- {\getvalue{\??headplace\v!yes}}}
-
+ {\settrue \c_strc_sectioning_empty
+ \setfalse\c_strc_sectioning_place
+ \settrue \c_strc_sectioning_hidden}
-\ifdefined\setheaddisplay \else \let\setheaddisplay\relax \fi
+\unexpanded\def\strc_sectioning_initialize_placement
+ {\expandcheckedcsname\??headplace{\headparameter\c!placehead}\v!yes}
\newmode\v!sectionnumber
@@ -373,12 +642,18 @@
{\resetsystemmode\v!sectionnumber
\setfalse\headshownumber} % why ?
-\def\setheadnumber
- {\doifelse{\sectionblockparameter\c!number}\v!yes % todo
- {\doifelse{\headparameter\c!number}\v!yes
- {\settrue\headshownumber}
- {\setfalse\headshownumber}}
- {\setfalse\headshownumber}}
+\unexpanded\def\strc_sectioning_initialize_number
+ {\edef\p_number{\sectionblockparameter\c!number}%
+ \ifx\p_number\v!yes
+ \edef\p_number{\headparameter\c!number}%
+ \ifx\p_number\v!yes
+ \settrue\headshownumber
+ \else
+ \setfalse\headshownumber
+ \fi
+ \else
+ \setfalse\headshownumber
+ \fi}
\unexpanded\def\theheadsynchonization
{\currentstructuresynchronize}
@@ -419,45 +694,15 @@
\let\currentheadlevel \!!zerocount
\let\currentheadcounter \!!zerocount
-% here we could inherit as well but it's a bit complex
-
-\def\doregisterhead#1#2#3% name data userdata
- {\structurecomponent
- %[\c!label={\headparameter\c!label}, % why { }
- [\c!label={\headparameter{\currentsectionblock\c!label}},
- \c!incrementnumber=\ifconditional\headdoincrement\v!yes\else\v!no\fi, % not that needed
- \c!saveinlist=\ifconditional\headtolist\v!yes\else\v!no\fi,
- \c!level=\currentheadlevel,
- \c!name=#1,
- \c!number=\ifconditional\headdoincrement\ifconditional\headshownumber\v!yes\else\v!no\fi\else\v!no\fi,
- \c!bookmark=,
- \c!marking=,
- \c!list=,
- \c!expansion=\headparameter\c!expansion,
- \c!xmlsetup=\headparameter\c!xmlsetup,
- \s!catcodes=\headparameter\s!catcodes,
- \c!sectionresetset=\headparameter\c!sectionresetset,
- \c!sectionseparatorset=\headparameter\c!sectionseparatorset,
- \c!sectionconversionset=\headparameter\c!sectionconversionset,
- \c!sectionconversion=\headparameter\c!conversion, % just for compatibility
- \c!sectionstarter=\headparameter\c!sectionstarter,
- \c!sectionstopper=\headparameter\c!sectionstopper,
- \c!sectionset=\headparameter\c!sectionset,
- \c!sectionsegments=\headparameter\c!sectionsegments,
- \c!reference=\headparameter\c!reference,
- \c!referenceprefix=\headparameter\c!referenceprefix,
- \c!backreference=,
- \c!command=,
- #2]%
- [#3]%
- \reportcurrentstructure}
-
-\unexpanded\def\placeheadtext {\dosingleempty\strc_sections_place_head_text } % use with care
-\unexpanded\def\placeheadnumber{\dosingleempty\strc_sections_place_head_number} % use with care
-
-\ifdefined\setupheadcomponentfont \else
-
- \unexpanded\def\setupheadcomponentfont#1#2%
+\unexpanded\def\placeheadtext {\dosingleempty\strc_sectioning_place_head_text } % use with care
+\unexpanded\def\placeheadnumber{\dosingleempty\strc_sectioning_place_head_number} % use with care
+
+
+\unexpanded\def\strc_sectioning_report{\ctxlua{structures.sections.reportstructure()}}
+
+\ifdefined\strc_rendering_initialize_style_and_color \else
+
+ \unexpanded\def\strc_rendering_initialize_style_and_color#1#2%
{\dontconvertfont
\useheadstyleandcolor\c!style\c!color
\useheadstyleandcolor#1#2%
@@ -465,110 +710,113 @@
\fi
-\def\strc_sections_place_head_text[#1]%
+\def\strc_sectioning_place_head_text[#1]%
{\dontleavehmode
\begingroup
+ \settrue\headisdisplay % triggers interlinespace checking
\edef\currenthead{#1}%
- \setupheadcomponentfont\c!textstyle\c!textcolor
+ \strc_rendering_initialize_style_and_color\c!textstyle\c!textcolor
\relax
\getspecificstructuretitle{\thenamedheadlevel{#1}}%
\endgraf
\endgroup}
-\def\strc_sections_place_head_number[#1]%
+\def\strc_sectioning_place_head_number[#1]%
{\dontleavehmode
\begingroup
+ \settrue\headisdisplay % triggers interlinespace checking
\edef\currenthead{#1}%
- \setupheadcomponentfont\c!numberstyle\c!numbercolor
+ \strc_rendering_initialize_style_and_color\c!numberstyle\c!numbercolor
\relax
\getfullstructurenumber{\thenamedheadlevel{#1}}%
\endgraf
\endgroup}
-\ifdefined\presetnumberheadalternative \else \let\presetnumberheadalternative\relax \fi
-\ifdefined\setautostructurelevel \else \let\setautostructurelevel \relax \fi
-\ifdefined\triggerautostructurelevel \else \let\triggerautostructurelevel \relax \fi
+\ifdefined\triggerautostructurelevel \else \let\triggerautostructurelevel\relax \fi
-\def\dohandlehead#1#2#3% name data userdata (we can move #1 to the caller)
+\def\strc_sectioning_handle#1#2#3% name data userdata (we can move #1 to the caller)
{\xdef\currenthead {#1}%
\xdef\currentheadcoupling{\sectionheadcoupling\currenthead}%
\xdef\currentheadsection {\sectionheadsection \currentheadcoupling}%
\xdef\currentheadlevel {\sectionlevel \currentheadsection}%
+ %
%writestatus\m!system{setup: \currenthead,\currentheadcoupling,\currentheadsection,\currentheadlevel}%
%
- \setautostructurelevel
- \setheadincrement
- \setheadplacement
- \setheaddisplay
- \setheadnumber
+ \strc_sectioning_initialize_autolevel
+ \strc_sectioning_initialize_increment
+ \strc_sectioning_initialize_placement
+ \strc_sectioning_initialize_number
+ %
+ \unexpanded\def\\{\space}% messy here
%
- \unexpanded\def\\{\space}%
\flushingcolumnfloatsfalse
%
% todo: also mark (for header)
%
% we might remove the lower level
%
- % not here, after optional \page: \doregisterhead\currenthead{#2}{#3}%
+ % not here, after optional \page: \strc_sectioning_register{#2}{#3}%
%
% \xdef\currentheadcounter{\currentsectioncountervalue}% lua call
%
% \currentstructuresynchronize % will move
%
- \edef\numberheaddistance {\headparameter\c!distance }% compatibility
- \edef\numberheadalternative{\headparameter\c!alternative}% compatibility
- \presetnumberheadalternative
- %
\let\getheadnumber\empty
\let\getheadtitle \empty
\let\getheadsyncs \empty
- \ifconditional\headdoincrement
- \ifconditional\headdoplace
- \doheadspacingbeforeyes
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \ifconditional\c_strc_sectioning_increment
+ \ifconditional\c_strc_sectioning_place
+ \strc_sectioning_before_yes
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
\let\getheadtitle\fullheadtitle
\ifconditional\headshownumber
\let\getheadnumber\fullheadnumber
- \placecurrentheadnumbertext
+ \strc_rendering_place_head_number_and_text
\else
- \placecurrentheadtext
+ \strc_rendering_place_head_text
\fi
- \doheadspacingafteryes
- \else\ifconditional\headhidden
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \strc_sectioning_after_yes
+ \else\ifconditional\c_strc_sectioning_hidden
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
- \placecurrentheadhidden % only something when tracing
+ \strc_rendering_place_head_hidden % only something when tracing
\else
- \doheadspacingbeforenop % toegevoegd ivm subpaginanr / tug sheets
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \strc_sectioning_before_nop % toegevoegd ivm subpaginanr / tug sheets
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
- \placecurrentheadempty % just flush 'm
- \doheadspacingafternop
+ \strc_rendering_place_head_empty % just flush 'm
+ \strc_sectioning_after_nop
\fi\fi
\else
- \ifconditional\headdoplace
- \doheadspacingbeforeyes
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \ifconditional\c_strc_sectioning_place
+ \strc_sectioning_before_yes
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
\let\getheadtitle\fullheadtitle
- \placecurrentheadtext
- \doheadspacingafteryes
- \else\ifconditional\headhidden
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \strc_rendering_place_head_text
+ \strc_sectioning_after_yes
+ \else\ifconditional\c_strc_sectioning_hidden
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
- \placecurrentheadhidden % only something when tracing
+ \strc_rendering_place_head_hidden % only something when tracing
\else
% do nothing / should be vbox to 0pt
- \doheadspacingbeforenop
- \doregisterhead\currenthead{#2}{#3}% after optional \page
+ \strc_sectioning_before_nop
+ \strc_sectioning_register{#2}{#3}% after optional \page
+ \strc_sectioning_report
\let\getheadsyncs\theheadsynchonization
- \placecurrentheadempty % just flush 'm
- \doheadspacingafternop
+ \strc_rendering_place_head_empty % just flush 'm
+ \strc_sectioning_after_nop
\fi\fi
\fi
\flushingcolumnfloatstrue
- \setfalse\ignorehandlepagebreak
+ \setfalse\c_strc_sectioniong_ignore_page
% ignorespaces prevents spaces creeping in when after=\dontleavehmode
\dostarttagged\t!sectioncontent\empty
\ifconditional\headisdisplay % \ifdisplaysectionhead
@@ -579,17 +827,17 @@
% typesetting
-\unexpanded\def\placecurrentheadnumbertext
+\unexpanded\def\strc_rendering_place_head_number_and_text
{\setheadmarking
\getheadnumber/\getheadtitle
\getheadsyncs}
-\unexpanded\def\placecurrentheadtext
+\unexpanded\def\strc_rendering_place_head_text
{\setheadmarking
\getheadtitle
\getheadsyncs}
-\unexpanded\def\placecurrentheadempty
+\unexpanded\def\strc_rendering_place_head_empty
{\setheadmarking
\getheadsyncs}
@@ -599,7 +847,7 @@
% todo: when in the page builder we need to resolve the marking immediately
% because otherwise we have an async
-\unexpanded\def\placecurrentheadhidden % maybe trialtypesetting check
+\unexpanded\def\strc_rendering_place_head_hidden % maybe trialtypesetting check
{\setxvalue{\??hiddenheadattr\currenthead}%
{\headreferenceattributes}% can be used when making a box
\setxvalue{\??hiddenheadsync\currenthead}%
@@ -628,50 +876,91 @@
% pagebreaks
-\newcount\precedingstructurelevel \precedingstructurelevel\plusone
-\newconditional\ignorehandlepagebreak
+\letvalue{\??headmarknop\v!page }\donothing
+\setvalue{\??headmarknop\v!reset }{\resetcurrentstructuremarks}
+\letvalue{\??headmarknop\s!unknown}\donothing
+
+\letvalue{\??headmarkyes\v!page }\donothing % to be checked: {\resetcurrentstructuremarks}
+\setvalue{\??headmarkyes\v!reset }{\resetcurrentstructuremarks}
+\letvalue{\??headmarkyes\s!unknown}\donothing
+
+\def\strc_sectioning_check_layout
+ {\edef\p_page{\headparameter\c!page}%
+ \ifx\p_page\empty
+ \strc_sectioning_check_layout_nop
+ \else
+ \strc_sectioning_check_layout_yes
+ \fi}
+
+\def\strc_sectioning_check_layout_nop
+ {\expandcheckedcsname\??headmarknop{\headparameter\c!marking}\s!unknown}
+
+\def\strc_sectioning_check_layout_yes
+ {\page[\p_page]%
+ \expandcheckedcsname\??headmarkyes{\headparameter\c!marking}\s!unknown
+ \edef\p_header{\headparameter\c!header}%
+ \ifx\p_header\empty \else
+ \doifelselayouttextline\v!header{\normalexpanded{\setuplayouttext[\v!header][\c!state=\p_header]}}%
+ \fi
+ \edef\p_text{\headparameter\c!text}%
+ \ifx\p_text\empty \else
+ \doifelselayouttextline\v!text {\normalexpanded{\setuplayouttext[\v!text ][\c!state=\p_text ]}}%
+ \fi
+ \edef\p_header{\headparameter\c!footer}%
+ \ifx\p_header\empty \else
+ \doifelselayouttextline\v!footer{\normalexpanded{\setuplayouttext[\v!footer][\c!state=\p_footer]}}%
+ \fi}
+
+\newcount \c_strc_sectioniong_preceding_level \c_strc_sectioniong_preceding_level\plusone
+\newconditional\c_strc_sectioning_auto_break \settrue\c_strc_sectioning_auto_break
+\newconditional\c_strc_sectioniong_ignore_page
+\newsignal \s_strc_sectioniong_continuous_signal
+
+\unexpanded\def\strc_sectioning_inject_continuous_signal
+ {\ifhmode
+ \hskip\s_strc_sectioniong_continuous_signal\relax
+ \fi}
-\def\doheadspacingbeforeyes
- {\docheckheadbefore
- \dohandleheadpagebreakyes
+\def\strc_sectioning_before_yes
+ {\strc_sectioning_check_before\strc_sectioning_handle_page_yes
\headparameter\c!inbetween
\dostarttagged\t!section\currenthead}
-\def\doheadspacingbeforenop
- {\docheckheadbefore
- \dohandleheadpagebreaknop
+\def\strc_sectioning_before_nop
+ {\strc_sectioning_check_before\strc_sectioning_handle_page_nop
\headparameter\c!inbetween
\dostarttagged\currenthead\empty}
-\def\emptyheadcorrection
- {\ifconditional\headleaveempty % inlined \emptyheadcorrection (with after=\blank)
- \penalty10000 % first ... we need to adapt this all to vspacing
+\def\strc_sectioning_empty_correction
+ {\ifconditional\c_strc_sectioning_empty
+ % this needs checking
+ \penalty\plustenthousand
\vskip-\lineheight
\kern\zeropoint
\prevdepth\strutdepth
\fi}
-\def\doheadspacingafteryes
+\def\strc_sectioning_after_yes
{\ifconditional\headisdisplay
- \dosomebreak\nobreak % needs to be adapted to vspacing
- \emptyheadcorrection
+ \ifconditional\c_strc_sectioning_auto_break
+ \vspacing[\v!samepage-\currentheadlevel]%
+ \fi
+ \strc_sectioning_empty_correction
\headparameter\c!after
\fi}
-\def\doheadspacingafternop
+\def\strc_sectioning_after_nop
{}
-\newsignal\continuousheadsignal
-
-\def\docheckheadbefore#1%
+\def\strc_sectioning_check_before#1%
{\ifhmode
\scratchcounter\lastpenalty\unpenalty % no beauty in this
- \ifdim\lastskip=\continuousheadsignal
+ \ifdim\lastskip=\s_strc_sectioniong_continuous_signal
% no page break
- \ifconditional\ignorehandlepagebreak
- \setfalse\ignorehandlepagebreak
+ \ifconditional\c_strc_sectioniong_ignore_page
+ \setfalse\c_strc_sectioniong_ignore_page
\else
- \global\precedingstructurelevel\currentheadlevel
+ \global\c_strc_sectioniong_preceding_level\currentheadlevel
\nobreak
\fi
\global\settrue\c_strc_rendering_continuous
@@ -685,81 +974,45 @@
#1%
\fi}
-\def\dodocheckheadlayout#1#2%
- {\doifelselayouttextline{#1}
- {\doifsomething{\headparameter#2}{\expanded{\setuplayouttext[#1][\c!state=\headparameter#2]}}}
- \donothing}
-
-\setvalue{\??headmarknop\v!page }{}
-\setvalue{\??headmarknop\v!reset}{\resetcurrentstructuremarks}
-\setvalue{\??headmarkyes\v!page }{} % to be checked: {\resetcurrentstructuremarks}
-\setvalue{\??headmarkyes\v!reset}{\resetcurrentstructuremarks}
-
-\def\docheckheadlayout
- {\doifelsenothing{\headparameter\c!page}
- {\getvalue{\??headmarknop\headparameter\c!marking}}
- {\page[\headparameter\c!page]%
- \getvalue{\??headmarkyes\headparameter\c!marking}%
- \dodocheckheadlayout\v!header\c!header
- \dodocheckheadlayout\v!text \c!text
- \dodocheckheadlayout\v!footer\c!footer}}
-
\def\currentsectioncountervalue {\ctxlua{structures.sections.depthnumber(\thenamedheadlevel\currenthead)}}
\def\previoussectioncountervalue{\ctxlua{structures.sections.depthnumber(\thenamedheadlevel\currenthead-1)}}
-\def\dohandleheadpagebreaknop
- {\doifelse{\headparameter\c!continue}\v!yes
- {\ifnum\previoussectioncountervalue=\zerocount
- \docheckheadlayout
- \else\ifnum\currentsectioncountervalue>\zerocount
- \docheckheadlayout
- \fi\fi}%
- {\docheckheadlayout}}
+\def\strc_sectioning_handle_page_nop
+ {\edef\p_continue{\headparameter\c!continue}%
+ \ifx\p_continue\v!yes
+ \ifnum\previoussectioncountervalue=\zerocount
+ \strc_sectioning_check_layout
+ \else\ifnum\currentsectioncountervalue>\zerocount
+ \strc_sectioning_check_layout
+ \fi\fi
+ \else
+ \strc_sectioning_check_layout
+ \fi}
-\def\dohandleheadpagebreakyes
+\def\strc_sectioning_handle_page_yes
{%[[\currenthead @\thenamedheadlevel\currenthead/prev:\previoussectioncountervalue/curr:\currentsectioncountervalue]]
- \ifconditional\ignorehandlepagebreak
- \setfalse\ignorehandlepagebreak
+ \ifconditional\c_strc_sectioniong_ignore_page
+ \setfalse\c_strc_sectioniong_ignore_page
\else
-% \ifnum\lastpenalty>\zerocount
-% \global\pagebreakdisabledtrue
-% \fi
% beware, these numbers are not yet know here
- \doifelse{\headparameter\c!continue}\v!yes
- {\ifnum\previoussectioncountervalue=\zerocount
- \docheckheadlayout
- \else\ifnum\currentsectioncountervalue>\zerocount
- \docheckheadlayout
- \fi\fi}%
- {\docheckheadlayout}%
- \doifnot{\headparameter\c!aligntitle}\v!float\page_otr_command_flush_side_floats
- \headparameter\c!before
- \relax
-% \ifpagebreakdisabled
-% \global\pagebreakdisabledfalse
-% \else
-% \dopreventbreakafterheadauto % not ok as it binds the prev par
-% \fi
- \doif{\headparameter\c!aligntitle}\v!float\indent
- \global\precedingstructurelevel\currentheadlevel
- \fi}
-
-\settrue\autoheadbreak % todo: \vspacing[category:8] == keep_together
-
-\def\dopreventbreakafterheadauto % used after \c!before
- {\ifconditional\autoheadbreak
- \vspacing[\v!samepage-\currentheadlevel]%
+ \strc_sectioning_handle_page_nop
+ \edef\p_aligntitle{\headparameter\c!aligntitle}%
+ \ifx\p_aligntitle\v!float
+ \headparameter\c!before\relax
+ \indent
+ \else
+ \page_otr_command_flush_side_floats
+ \headparameter\c!before\relax
+ \fi
+ \global\c_strc_sectioniong_preceding_level\currentheadlevel
\fi}
-\def\dopreventbreakafterheadspec#1% see enumerations etc
- {\ifconditional\autoheadbreak
- \vspacing[\v!samepage-\the\numexpr\currentheadlevel+1\relax]% todo #1
+\unexpanded\def\strc_sectioning_prevent_page_break#1% see strc-con
+ {\ifconditional\c_strc_sectioning_auto_break
+ \vspacing[\v!samepage-\the\numexpr\currentheadlevel+\ifx#1\empty\plusone\else#1\fi\relax]%
\fi}
-\def\dohandlepagebreakX{\dopreventbreakafterheadspec} % no \let so we can redefine
-
-% we do support negative numbers but it can have side effects that we won't
-% catch
+% We do support negative numbers but it can have side effects that we won't catch:
%
% \chapter{some} \setupheadnumber[chapter][3] \chapter{more}
% \setupheadnumber[section][8] \section{b} \section{c} \setupheadnumber[section][-1] \section{d}
@@ -810,22 +1063,22 @@
% experimental
-\newconditional\c_strc_sections_auto_levels
+\newconditional\c_strc_sectioning_auto_levels
\appendtoks
- \settrue\c_strc_sections_auto_levels
+ \settrue\c_strc_sectioning_auto_levels
\to \everyenableelements
-\def\setautostructurelevel
- {\ifconditional\c_strc_sections_auto_levels
+\unexpanded\def\strc_sectioning_initialize_autolevel
+ {\ifconditional\c_strc_sectioning_auto_levels
\ctxcommand{autonextstructurelevel(\number\currentheadlevel)}%
- \global\setfalse\c_strc_sections_auto_levels
+ \global\setfalse\c_strc_sectioning_auto_levels
\fi}
-\def\triggerautostructurelevel
- {\global\settrue\c_strc_sections_auto_levels}
+\unexpanded\def\triggerautostructurelevel
+ {\global\settrue\c_strc_sectioning_auto_levels}
-\def\finalizeautostructurelevels
+\unexpanded\def\finalizeautostructurelevels
{\ctxcommand{autofinishstructurelevels()}}
\unexpanded\def\finalizeautostructurelevel
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index de1da677a..f1a9cfabc 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -2431,15 +2431,14 @@
%D \macros
%D {makestrutofbox}
%D
-%D This macro sets the dimensions of a box to those of a
-%D strut.
+%D This macro sets the dimensions of a box to those of a strut.
\def\domakestrutofbox
{\ht\c_boxes_register\strutht
\dp\c_boxes_register\strutdp
\wd\c_boxes_register\zeropoint}
-\unexpanded\def\makestrutofbox
+\unexpanded\def\makestrutofbox % not used
{\afterassignment\domakestrutofbox\c_boxes_register}
%D \macros
diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv
index 0bda688fa..6c71fa0d1 100644
--- a/tex/context/base/syst-ini.mkiv
+++ b/tex/context/base/syst-ini.mkiv
@@ -11,16 +11,14 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D We used to load plain \TEX\ in a special way, but redefining
-%D a couple of primitives so that for instance font loading was
-%D ignored. For those interested, this loader is found in
-%D \type {syst-tex.tex}. Some of the comment's are Don Knuth's
-%D and more of it can be found in the plain \TEX\ format.
-
-%D Characters can have special states, that can be triggered
-%D by setting their category coded. Some are preset, others
-%D are to be set as soon as possible, otherwise we cannot
-%D define any useful macros.
+%D We used to load plain \TEX\ in a special way, but redefining a couple of
+%D primitives so that for instance font loading was ignored. For those interested,
+%D this loader is found in \type {syst-tex.tex}. Some of the comment's are Don
+%D Knuths and more of it can be found in the plain \TEX\ format.
+%D
+%D Characters can have special states, that can be triggered by setting their
+%D category coded. Some are preset, others are to be set as soon as possible,
+%D otherwise we cannot define any useful macros.
%catcode`\^^@ = 9 % ascii null is ignored
%catcode`\\ = 0 % backslash is TeX escape character
@@ -58,8 +56,7 @@
\catcode`\^^Z=9
-%D It makes sense to know what engine we're running so let's
-%D try to deduce it.
+%D It makes sense to know what engine we're running so let's try to deduce it.
\chardef\unknownengine = 0
\chardef\pdftexengine = 1
@@ -117,16 +114,15 @@
}
\fi
-%D \ETEX\ has a not so handy way of telling you the version number,
-%D i.e. the revision number has a period in it:
+%D \ETEX\ has a not so handy way of telling you the version number, i.e. the revision
+%D number has a period in it:
\long\def\gobbleoneargument#1{} % will be defined later on anyway
\mathchardef\etexversion = \numexpr\eTeXversion*100+\expandafter\gobbleoneargument\eTeXrevision\relax
-%D First we define a simplified version of the \CONTEXT\
-%D protection mechanism. Later we will implement a better
-%D variant.
+%D First we define a simplified version of the \CONTEXT\ protection mechanism.
+%D Later we will implement a better variant.
\def\unprotect
{\edef\protect
@@ -154,18 +150,16 @@
%D
%D No comment.
-%D Allocation of registers is done slightly different than in plain
-%D \TEX. First of all we use different reserved counters. We also
-%D don't implement a family handler because users are not supposed
-%D to implement their own math. We reserve the lowest 31 registers
-%D for scratch purposes. Keep in mind that in the core engine
-%D some registers are reserved: counters 0 upto 9, and counter 255.
+%D Allocation of registers is done slightly different than in plain \TEX. First of
+%D all we use different reserved counters. We also don't implement a family handler
+%D because users are not supposed to implement their own math. We reserve the lowest
+%D 31 registers for scratch purposes. Keep in mind that in the core engine some
+%D registers are reserved: counters 0 upto 9, and counter 255.
%D
-%D As with plain \TEX\ we recommend that macro designers always use
-%D \type {\global} assignments with respect to registers numbered 1,
-%D 3, 5 \unknown\ 31, and always non||\type {\global} assignments
-%D with respect to registers 0, 2, 4, \unknown\ 30. This will prevent
-%D \quote {save stack buildup} that might otherwise occur.
+%D As with plain \TEX\ we recommend that macro designers always use \type {\global}
+%D assignments with respect to registers numbered 1, 3, 5 \unknown\ 31, and always
+%D non||\type {\global} assignments with respect to registers 0, 2, 4, \unknown\ 30.
+%D This will prevent \quote {save stack buildup} that might otherwise occur.
%D
%D We reserve some registers for special (management) purposes:
@@ -217,11 +211,10 @@
\dimendef \dimen@i = 1 % global only
\dimendef \dimen@ii = 2
-%D So, effectively we start allocating from 256 and upwards. The
-%D inserts sit in the range 128 upto 254. Page numbers use the
-%D counters 0 upto 9 and the pagebox is 255. Users can use the
-%D scratch registers upto 31 without problem but all others are
-%D reserved.
+%D So, effectively we start allocating from 256 and upwards. The inserts sit in the
+%D range 128 upto 254. Page numbers use the counters 0 upto 9 and the pagebox is
+%D 255. Users can use the scratch registers upto 31 without problem but all others
+%D are reserved.
\let\wlog\gobbleoneargument % Let's get rid of this one.
@@ -259,12 +252,11 @@
%newlinechar=10 \def\outputnewlinechar{\rawcharacter{10}}
\newlinechar=10 \edef\outputnewlinechar{^^J}
-%D One reason to start high with allocation is that it permits us to
-%D allocate consecutive ranges more easily, for instance if for \MPLIB\
-%D we want to allocate a continuous range of boxes. It also permits us
-%D to do a proper upward allocation for inserts. The current code
-%D evolved from code that dealt with older engines but as all engines
-%D now provide many registers we removed all traces.
+%D One reason to start high with allocation is that it permits us to allocate
+%D consecutive ranges more easily, for instance if for \MPLIB\ we want to allocate a
+%D continuous range of boxes. It also permits us to do a proper upward allocation
+%D for inserts. The current code evolved from code that dealt with older engines but
+%D as all engines now provide many registers we removed all traces.
\ifdefined\writestatus \else
\normalprotected\def\writestatus#1#2{\immediate\write16{#1: #2}}
@@ -291,29 +283,27 @@
\fi\fi
#1#2#3#4#5}
-%D Since the number of chars exceed 256 now, we can use \type
-%D {\chardef} instead of the more limited \type {\mathchardef}.
+%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of
+%D the more limited \type {\mathchardef}.
\ifnum\texengine>\pdftexengine
\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register}
\normalprotected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register}
\fi
-%D Attributes are something very \LUATEX. In \CONTEXT\ you are not
-%D supposed to use the attributes directly but always allocate then
-%D first. For instance attribute~0 is reserved for special purposes
-%D (this might change). Attributes in the range 128-1023 are private
-%D and should not be touched.
+%D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use
+%D the attributes directly but always allocate then first. For instance attribute~0
+%D is reserved for special purposes (this might change). Attributes in the range
+%D 128-1023 are private and should not be touched.
\ifnum\texengine=\luatexengine
\let\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone
\normalprotected\def\newattribute{\syst_basics_allocate\c_syst_min_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register}
\fi
-%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a
-%D trick to force strings instead of tokens that take more memory.
-%D It's a trick to trick to force strings. This macro is never used
-%D in \CONTEXT.
+%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force
+%D strings instead of tokens that take more memory. It's a trick to trick to force
+%D strings. This macro is never used in \CONTEXT.
\normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
@@ -323,8 +313,8 @@
%D scratchbox,
%D scratchtoks}
%D
-%D We now define a few scratch registers, so that successive
-%D loads at least have some available.
+%D We now define a few scratch registers, so that successive loads at least have
+%D some available.
\newcount \scratchcounter \newcount \globalscratchcounter
\newdimen \scratchdimen \newdimen \globalscratchdimen
@@ -374,6 +364,11 @@
\newcount\scratchmx
\newcount\scratchmy
+\newdimen\scratchleftskip
+\newdimen\scratchrightskip
+\newdimen\scratchtopskip
+\newdimen\scratchbottomskip
+
%D More allocations:
\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt
@@ -438,8 +433,8 @@
\def\doubleexpandafter{\expandafter\expandafter\expandafter}
\def\tripleexpandafter{\expandafter\doubleexpandafter\expandafter}
-%D We prefer the more readable variant than in plain
-%D \TEX. User should only use \type {\emptybox}:
+%D We prefer the more readable variant than in plain \TEX. User should only
+%D use \type {\emptybox}:
\newbox\voidbox % public
@@ -464,8 +459,8 @@
\hfuzz \maxdimen
\vfuzz \maxdimen}
-%D Some expected plain variants follow. We don't reuse registers
-%D because we don't want clashes.
+%D Some expected plain variants follow. We don't reuse registers because we
+%D don't want clashes.
\newdimen\p@ \p@ \onepoint
\newcount\m@ne \m@ne \minusone
@@ -479,8 +474,8 @@
\newbox \voidb@x
\newtoks \toks@
-%D We define \type {\newif} a la plain \TEX, but will
-%D redefine it later. As Knuth says:
+%D We define \type {\newif} a la plain \TEX, but will redefine it later. As
+%D Knuth says:
%D
%D \startnarrower
%D And here's a different sort of allocation: for example,
@@ -489,8 +484,7 @@
%D \newif\iffoo
%D \stoptyping
%D
-%D creates \type {\footrue}, \type {\foofalse} to go
-%D with \type {\iffoo}.
+%D creates \type {\footrue}, \type {\foofalse} to go with \type {\iffoo}.
%D \stopnarrower
\normalprotected\def\newif#1%
@@ -518,8 +512,8 @@
\ifdefined\htdp \else \def\htdp#1{\dimexpr\ht#1+\dp#1\relax} \fi
-%D The catcode constants will be redefined in later catcode
-%D related modules but they can be used in the same way.
+%D The catcode constants will be redefined in later catcode related modules
+%D but they can be used in the same way.
\chardef\escapecatcode = 0
\chardef\begingroupcatcode = 1
@@ -566,13 +560,12 @@
\chardef\scrollmodecode = 2
\chardef\errorstopmodecode = 3
-%D Constants to be used with \type {\lastnodetype}. The \type
-%D {\lastnodetype} primitive is \ETEX\ compliant. The valid range is
-%D still -1 .. 15 and glyph nodes have number 0 (used to be char
-%D node) and ligature nodes are mapped to 7. That way macro packages
-%D can use the same symbolic names as in traditional \ETEX. Keep in
-%D mind that the internal node numbers are different and that there
-%D are more node types that 15.
+%D Constants to be used with \type {\lastnodetype}. The \type {\lastnodetype}
+%D primitive is \ETEX\ compliant. The valid range is still -1 .. 15 and glyph nodes
+%D have number 0 (used to be char node) and ligature nodes are mapped to 7. That way
+%D macro packages can use the same symbolic names as in traditional \ETEX. Keep in
+%D mind that the internal node numbers are different and that there are more node
+%D types that 15.
\chardef\charnodecode = 0
\chardef\hlistnodecode = 1
@@ -591,8 +584,8 @@
\chardef\unsetnodecode = 14
\chardef\mathsnodecode = 15
-%D Constants to be used with \type {\currentiftype}. I wonder if
-%D we will ever use these in \CONTEXT.
+%D Constants to be used with \type {\currentiftype}. I wonder if we will ever
+%D use these in \CONTEXT.
\chardef\charifcode = 1
\chardef\catifcode = 2
@@ -615,11 +608,11 @@
\chardef\csnameifcode = 19
\chardef\fontcharifcode = 20
-%D Of course we want even bigger log files, so we copied this
-%D from the \ETEX\ source files.
+%D Of course we want even bigger log files, so we copied this from the \ETEX\
+%D source files.
%D
-%D When watching such logs, beware of nasty side effects of
-%D \type {\scantokens}, as in:
+%D When watching such logs, beware of nasty side effects of \type {\scantokens},
+%D as in:
%D
%D \starttyping
%D \bgroup
@@ -680,14 +673,13 @@
\ifdefined\normalinput \else \let\normalinput\input \fi
-%D We don't like outer commands, and we always want access
-%D to the original \type {\input} primitive.
+%D We don't like outer commands, and we always want access to the original
+%D \type {\input} primitive.
\let\normalouter\outer \def\outer{} % no longer \relax
-%D To circumvent dependencies, we can postpone certain
-%D initializations to dumping time, by appending them to the
-%D \type {\everydump} token register.
+%D To circumvent dependencies, we can postpone certain initializations to
+%D dumping time, by appending them to the \type {\everydump} token register.
\ifdefined\normaldump \else \let\normaldump\dump \fi
@@ -708,11 +700,10 @@
%D settrue, setfalse,
%D ifconditional,then}
%D
-%D \TEX's lacks boolean variables, although the \PLAIN\ format
-%D implements \type{\newif}. The main disadvantage of this
-%D scheme is that it takes three hash table entries. A more
-%D memory saving alternative is presented here. A conditional
-%D is defined by:
+%D \TEX's lacks boolean variables, although the \PLAIN\ format implements \type
+%D {\newif}. The main disadvantage of this scheme is that it takes three hash table
+%D entries. A more memory saving alternative is presented here. A conditional is
+%D defined by:
%D
%D \starttyping
%D \newconditional\doublesided
@@ -738,9 +729,8 @@
%D \def\setfalse#1{\let#1=\iffalse}
%D \stoptyping
%D
-%D Such an implementation gives problems with nested
-%D conditionals. The next implementation is about as fast
-%D and just as straightforward:
+%D Such an implementation gives problems with nested conditionals. The next
+%D implementation is about as fast and just as straightforward:
\let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef
\let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef
@@ -756,8 +746,8 @@
%D \macros
%D {newmacro,setnewmacro,newfraction}
%D
-%D Let's be complete and also introduce some definers. These are
-%D not mandate but handy for grepping.
+%D Let's be complete and also introduce some definers. These are not mandate
+%D but handy for grepping.
\normalprotected\def\newmacro #1{\let#1\empty}
\normalprotected\def\setnewmacro#1{\let#1}
@@ -766,17 +756,15 @@
\normalprotected\def\newfraction#1{\let#1\!!plusone}
-%D It would be handy to have a primitive \unless\ifcase because
-%D then we could use nicer values. Anyhow, this conditional code
-%D used to be in the \type {syst-aux} module but is now promoted
-%D to here.
+%D It would be handy to have a primitive \unless\ifcase because then we could
+%D use nicer values. Anyhow, this conditional code used to be in the \type
+%D {syst-aux} module but is now promoted to here.
%D \macros
%D {ifzeropt}
%D
-%D The next macro is both cosmetic and byte saving. It is
-%D pretty \type{\if}||safe too. It can be used in cases
-%D like:
+%D The next macro is both cosmetic and byte saving. It is pretty \type
+%D {\if}||safe too. It can be used in cases like:
%D
%D \starttyping
%D \ifzeropt \somedimen ... \else ... \fi
@@ -849,9 +837,8 @@
\def\empty{}
\def\null {\hbox{}}
-%D The following two might be overloaded later on but some modules need
-%D then earlier. These functionality is reflected in the name and will not
-%D change.
+%D The following two might be overloaded later on but some modules need then
+%D earlier. These functionality is reflected in the name and will not change.
\bgroup
\catcode`\^^M=\activecatcode%
@@ -868,16 +855,15 @@
\let\endoflinetoken=^^M
-%D Also needed might be a simple loop structure and we borrow
-%D plain \TEX's one as it is often expected to be present and
-%D it is about the fastest you can get. Beware: this macro
-%D does not support nested loops. We use a namespace prefix
-%D \type {@@pln}.
+%D Also needed might be a simple loop structure and we borrow plain \TEX's one
+%D as it is often expected to be present and it is about the fastest you can
+%D get. Beware: this macro does not support nested loops. We use a namespace
+%D prefix \type {@@pln}.
\long\def\loop#1\repeat{\long\def\@@plnbody{#1}\@@plniterate} % might go
-%D The following makes \type {\loop} \unknown\ \type {\if}
-%D \unknown\ \type {\repeat} skippable (clever trick):
+%D The following makes \type {\loop} \unknown\ \type {\if} \unknown\ \type
+%D {\repeat} skippable (clever trick):
\let\repeat\fi % so both \loop and \repeat are reserved words!
@@ -897,23 +883,22 @@
\def\@@plniterate{\@@plnbody\expandafter\@@plniterate\else\fi}
-%D We don't define a real output routine yet but at least get rid
-%D of pages:
+%D We don't define a real output routine yet but at least get rid of pages:
\output{\shipout\box\normalpagebox}
-%D Although we don't add pagenumbers yet we alias the default
-%D register used for counting pages:
+%D Although we don't add pagenumbers yet we alias the default register used
+%D for counting pages:
\countdef\pageno=0 \pageno=1 % first page is number 1
-%D Beside the raw counter \type {\pageno} the \type {\folio}
-%D macro provides the value.
+%D Beside the raw counter \type {\pageno} the \type {\folio} macro provides
+%D the value.
\def\folio{\the\pageno} % kind of expected and therefore reserved
-%D The following registers are kind of standard and (for the moment)
-%D we define them here. This might change.
+%D The following registers are kind of standard and (for the moment) we define
+%D them here. This might change.
\newskip \bigskipamount \bigskipamount = 12pt plus 4pt minus 4pt
\newskip \medskipamount \medskipamount = 6pt plus 2pt minus 2pt
@@ -948,9 +933,8 @@
\spanomit \advance\mscount\minusone
\repeat}
-%D The next section deals with selective definitions in
-%D later modules. One can of course use the \type {\texengine}
-%D number that we defined earlier instead.
+%D The next section deals with selective definitions in later modules. One can of
+%D course use the \type {\texengine} number that we defined earlier instead.
\bgroup \obeylines
\gdef\pickupSOMETEX#1%
@@ -982,19 +966,19 @@
\fi
%D \macros
-%D {bindprimitive}
+%D {bindprimitive}
%D
-%D We can remap primitives (which is needed because of changes in
-%D for instance \PDFTEX).
+%D We can remap primitives (which is needed because of changes in for instance
+%D \PDFTEX).
\def\bindprimitive#1 #2 % new old
{\ifcsname#1\endcsname \else \ifcsname#2\endcsname
\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname
\fi \fi}
-%D Because \XETEX\ also implements some \PDFTEX\ functionality, we take
-%D care of this here instead of a dedicated module. Later modules need
-%D to handle the undefined cases.
+%D Because \XETEX\ also implements some \PDFTEX\ functionality, we take care of this
+%D here instead of a dedicated module. Later modules need to handle the undefined
+%D cases.
%D These messy checks will disappear.
@@ -1052,8 +1036,8 @@
\newif\ifproductionrun
-%D We need to make sure that we start up in \DVI\ mode, so,
-%D after testing for running \PDFTEX, we default to \DVI.
+%D We need to make sure that we start up in \DVI\ mode, so, after testing for running
+%D \PDFTEX, we default to \DVI.
\ifx\pdftexversion\undefined \newcount\pdfoutput \fi \pdfoutput=0
@@ -1099,15 +1083,14 @@
\let\synctex\undefined \newcount\synctex
-%D We get rid of the funny \TEX\ offset defaults of one
-%D inch by setting them to zero.
+%D We get rid of the funny \TEX\ offset defaults of one inch by setting them to zero.
-\voffset \zeropoint \newdimen\voffset % prevent messing up
-\hoffset \zeropoint \newdimen\hoffset % prevent messing up
+\voffset\zeropoint \let\voffset\relax \newdimen\voffset % prevent messing up
+\hoffset\zeropoint \let\hoffset\relax \newdimen\hoffset % prevent messing up
-%D While cleaning this code up a bit I was listening to Heather
-%D Nova's \CD\ Redbird. The first song on that \CD\ ends with
-%D a few lines suitable for ending this initialization module:
+%D While cleaning this code up a bit I was listening to Heather Nova's \CD\ Redbird.
+%D The first song on that \CD\ ends with a few lines suitable for ending this
+%D initialization module:
%D
%D \startlines
%D And there's so much I can do for you
@@ -1120,7 +1103,6 @@
%D Come inside
%D \stoplines
%D
-%D So let's see what \TEX\ can do now that we've opened up
-%D the basic machinery.
+%D So let's see what \TEX\ can do now that we've opened up the basic machinery.
\protect \endinput