summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-sec.mkiv
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
committerTaco Hoekwater <taco@elvenkind.com>2011-06-01 08:54:21 +0000
commitd7ccb42582f85acf30568913610ccf4d602023fb (patch)
tree7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/strc-sec.mkiv
parent2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff)
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-sec.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-sec.mkiv387
1 files changed, 263 insertions, 124 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-sec.mkiv b/Master/texmf-dist/tex/context/base/strc-sec.mkiv
index 35927d98a00..6cb6f84c142 100644
--- a/Master/texmf-dist/tex/context/base/strc-sec.mkiv
+++ b/Master/texmf-dist/tex/context/base/strc-sec.mkiv
@@ -15,6 +15,8 @@
\unprotect
+\ifdefined \v!block \else \def\v!block{block} \fi
+
% compatibility issue:
%
% \def\setfullsectionnumber #1{}
@@ -41,25 +43,26 @@
% lua interface / names and interface might change
-\def\setstructurelevel #1#2{\ctxlua{structure.sections.setlevel("#1","#2")}} % name, level|parent
-\def\getstructurelevel #1{\ctxlua{structure.sections.getcurrentlevel("#1")}}% name
-\def\setstructurenumber #1#2{\ctxlua{structure.sections.setnumber(#1,"#2")}} % level, number (+/-)
-\def\getstructurenumber #1{\ctxlua{structure.sections.getnumber(#1)}} % level
-\def\getsomestructurenumber #1#2{\ctxlua{structure.sections.getnumber(#1,"#2")}} % level, what
-\def\getfullstructurenumber #1{\ctxlua{structure.sections.fullnumber(#1)}} % level
-\def\getsomefullstructurenumber#1#2{\ctxlua{structure.sections.fullnumber(#1,"#2")}}
-\def\getspecificstructuretitle #1{\ctxlua{structure.sections.structuredata(#1,"titledata.title",nil,"\structureheadparameter\s!catcodes")}}%
+\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 (+/-)
+\def\getstructurenumber #1{\ctxlua{structures.sections.getnumber(#1)}} % level
+\def\getsomestructurenumber #1#2{\ctxlua{structures.sections.getnumber(#1,"#2")}} % level, what
+\def\getfullstructurenumber #1{\ctxlua{structures.sections.fullnumber(#1)}} % level
+\def\getsomefullstructurenumber#1#2{\ctxlua{structures.sections.fullnumber(#1,"#2")}}
+\def\getspecificstructuretitle #1{\ctxlua{structures.sections.structuredata(#1,"titledata.title",nil,"\structureheadparameter\s!catcodes")}}%
% interface
-\def\structureheadparameter #1{\csname\dostructureheadparameter{\??nh\currentstructurehead}#1\endcsname}
-\def\structureheadparameterhash#1{\dostructureheadparameterhash {\??nh\currentstructurehead}#1}
+\def\structureheadparameter #1{\csname\dostructureheadparameter{\??nh\currentstructurehead}{#1}\endcsname}
+\def\structureheadparameterhash #1{\dostructureheadparameterhash {\??nh\currentstructurehead}{#1}}
+\def\namedstructureheadparameter#1#2{\csname\dostructureheadparameter{\??nh#1}{#2}\endcsname}
-\def\dostructureheadparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dostructureheadparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\dostructureheadparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dostructureheadparentparameterhash\csname#1\s!parent\endcsname#2\fi}
+\def\dostructureheadparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dostructureheadparentparameter \csname#1\s!parent\endcsname{#2}\fi}
+\def\dostructureheadparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dostructureheadparentparameterhash\csname#1\s!parent\endcsname{#2}\fi}
-\def\dostructureheadparentparameter #1#2{\ifx#1\relax\s!empty\else\dostructureheadparameter #1#2\fi}
-\def\dostructureheadparentparameterhash#1#2{\ifx#1\relax \else\dostructureheadparameterhash#1#2\fi}
+\def\dostructureheadparentparameter #1#2{\ifx#1\relax\s!empty\else\dostructureheadparameter #1{#2}\fi}
+\def\dostructureheadparentparameterhash#1#2{\ifx#1\relax \else\dostructureheadparameterhash#1{#2}\fi}
\def\structureheadparameterstrict#1{\csname\ifcsname\??nh\currentstructurehead#1\endcsname\??nh\currentstructurehead#1\else\s!empty\fi\endcsname}
@@ -75,28 +78,64 @@
\let\laststructuresectionname\empty
+\let\resetallstructuremarks \relax
+\let\resetcurrentstructuremarks \relax
+\let\resetcurrentstructuremarkswithpage\relax
+
+\def\resetallstructuremarks {\resetmarking[\v!section-1]} % will become option
+\def\resetcurrentstructuremarks {\resetmarking[\laststructuresectionname]} % will become option
+%def\resetcurrentstructuremarkswithpage{\resetmarking[\laststructuresectionname]} % will become option
+
+% \c!before=,
+% \c!after=,
+% \c!distance=\zeropoint,
+% \c!page=,
+% \c!header=,
+% \c!text=,
+% \c!footer=,
+% \c!numbercommand=,
+% \c!textcommand=,
+% \c!ownnumber=\v!no,
+% \c!number=\v!yes,
+% \c!file=,
+% \c!expansion=,
+% \c!grid=,
+% \c!margintext=,
+%
+% \c!xmlsetup=,
+% \s!catcodes=,
+
+\newtoks\everydefinestructuresection
+
+\appendtoks
+ % This is a rather practical default that we don't want to
+ % be part of the parent chain lookup mechanism; it's also
+ % mkii compatible. Somewhat weird that it's part of the
+ % top level structure but it will be flattened anyway.
+ \getparameters[\??nh\currentstructuresection]
+ [ \c!textstyle=\structureheadparameterstrict\c!style,
+ \c!textcolor=\structureheadparameterstrict\c!color,
+ \c!numberstyle=\structureheadparameterstrict\c!style,
+ \c!numbercolor=\structureheadparameterstrict\c!color]%
+\to \everydefinestructuresection
+
\unexpanded\def\definestructuresection[#1]%
- {\doifundefined{\??nh#1}
- {\global\advance\maxstructuredepth\plusone
- \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
- \setstructurelevel{#1}{\the\maxstructuredepth}%
-% \letvalue{\??nh#1\c!marking}\empty % ?
- %\writestatus{structure}{#1\ifx\laststructuresectionname\empty\else\space->\space\laststructuresectionname\fi}%
- \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}%
- % this is a rather practical default that we don't want to be part of the parent chain
- % lookup mechanism; it's also mkii compativle; this might become \everystructureheaddefine
- \getparameters[\??nh#1]
- [ \c!textstyle=\structureheadparameterstrict\c!style,
- \c!textcolor=\structureheadparameterstrict\c!color,
- \c!numberstyle=\structureheadparameterstrict\c!style,
- \c!numbercolor=\structureheadparameterstrict\c!color]%
- % so far for these default inheritances
- \definemarking[#1]%
- \ifnum\maxstructuredepth>\plusone
-% \normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent
- \normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child
- \fi
- \xdef\laststructuresectionname{#1}}}
+ {\ifcsname\??nh#1\endcsname
+ % redefinition is a rather fatal error
+ \else
+ \edef\currentstructuresection{#1}%
+ \global\advance\maxstructuredepth\plusone
+ \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}%
+ \setstructurelevel{#1}{\the\maxstructuredepth}%
+ \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}%
+ \the\everydefinestructuresection
+ % so far for these default inheritances
+ \definemarking[#1]%
+ \ifnum\maxstructuredepth>\plusone
+ \normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child
+ \fi
+ \xdef\laststructuresectionname{#1}%
+ \fi}
\unexpanded\def\setupstructuresection
{\dotripleempty\dosetupstructuresection}
@@ -113,10 +152,14 @@
\getparameters[\??nh#1][#2]%
\fi}
+% -2=text -1=manual 0=block 1+=structurelevel
+
\def\structuresectionlevel#1%
{\executeifdefined{\??nh#1\c!level}{-1}}
-\setvalue{\??nh block\c!level}{0} % -1 == manual
+\setvalue{\??nh\v!block\c!level}{0}
+\setvalue{\??nh\v!none \c!level}{-1}
+\setvalue{\??nh\v!text \c!level}{-2}
% head -> structurehead
@@ -166,30 +209,24 @@
\edef\currentstructureheaddefault{\structureheadparameter\c!default}%
\edef\currentstructureheadsection{\structureheadparameter\c!section}%
\edef\currentstructureheadparent
- {\??nh
- \ifx\currentstructurehead\currentstructureheaddefault
+ {\ifx\currentstructurehead\currentstructureheaddefault
\currentstructureheadsection
\else\ifx\currentstructureheaddefault\empty
\currentstructureheadsection
\else
\currentstructureheaddefault
\fi\fi}%
- \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\currentstructureheadparent]}% \setevalue{\??nh#1\s!parent}{\currentstructureheadparent}%
- \ifx\currentstructureheadsection\empty
- %\writestatus{structure}{#1->\currentstructureheadparent}%
- \else
- %\writestatus{structure}{#1->\currentstructureheadparent\space(\currentstructureheadsection)}%
- % todo: filtercommand
- \definemarking[#1][\currentstructureheadsection]%
- \definemarking[#1\v!number][#1]%
- \setupmarking[#1][\c!filtercommand=\sectionheadmarkingtitle{#1}]%
- \setupmarking[#1\c!number][\c!filtercommand=\sectionheadmarkingnumber{#1}]%
- \fi
+ \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\currentstructureheadparent]}%
+ % or just \setevalue{\??nh#1\s!parent}{\??nh\currentstructureheadparent}%
+ \definemarking[#1] [\currentstructureheadsection]%
+ \definemarking[#1\v!number][\currentstructureheadsection]%
+ \setupmarking [#1] [\c!filtercommand=\sectionheadmarkingtitle {#1}]%
+ \setupmarking [#1\c!number][\c!filtercommand=\sectionheadmarkingnumber{#1}]%
\doifundefined{\??li#1}{\definelist[#1][\c!prefix=\v!no]}% definestructurelist ?
\the\everystructureheadsetup}
-\def\sectionheadmarkingtitle #1#2{\ctxlua{structure.marks.title("#1","#2")}}
-\def\sectionheadmarkingnumber#1#2{\ctxlua{structure.marks.number("#1","#2")}}
+\def\sectionheadmarkingtitle #1#2{\ctxlua{structures.marks.title("#1","#2")}}
+\def\sectionheadmarkingnumber#1#2{\ctxlua{structures.marks.number("#1","#2")}}
\def\dodefineclonedstructurehead#1#2% class parent
{\def\currentstructurehead{#1}%
@@ -198,20 +235,19 @@
{\getparameters[\??nh#1][\c!label=#1]%
\doifundefined{\??li#1}{\definelist[#1][\c!prefix=\v!no]}}% definestructurelist ?
{\getparameters[\??nh#1][\s!parent=\??nh#2,\c!label=#1,\c!coupling=#2]%
- \definemarking[#1][#2]%
+ \definemarking[#1] [#2]%
\definemarking[#1\v!number][#2\c!number]%
\doifundefined{\??li#1}{\definelist[#1][#2][\c!prefix=\v!no]}}% definestructurelist ?
\the\everystructureheadsetup}
\appendtoks
-% \setstructurelevel\currentstructurehead{\structuresectionheadsection{\structuresectionheadcoupling\currentstructurehead}}%
\setstructurelevel\currentstructurehead{\thenamedstructureheadlevel\currentstructurehead}%
\doifelse{\structureheadparameter\c!ownnumber}\v!yes
- {\setevalue\currentstructurehead{\noexpand\dohandlestructureheadown[\currentstructurehead]}}
- {\setevalue\currentstructurehead{\noexpand\dohandlestructureheadnop[\currentstructurehead]}}%
- \setevalue{\e!next \currentstructurehead}{\noexpand\donextstructurehead [\currentstructurehead]}%
- \setevalue{\e!start\currentstructurehead}{\noexpand\dostartstructurehead[\currentstructurehead]}%
- \setevalue{\e!stop \currentstructurehead}{\noexpand\dostopstructurehead [\currentstructurehead]}%
+ {\setevalue\currentstructurehead{\dohandlestructureheadown[\currentstructurehead]}}
+ {\setevalue\currentstructurehead{\dohandlestructureheadnop[\currentstructurehead]}}%
+ \setevalue{\e!next \currentstructurehead}{\donextstructurehead [\currentstructurehead]}%
+ \setevalue{\e!start\currentstructurehead}{\dostartstructurehead[\currentstructurehead]}%
+ \setevalue{\e!stop \currentstructurehead}{\dostopstructurehead [\currentstructurehead]}%
\to \everystructureheadsetup
% todo, check if section is defined
@@ -228,36 +264,49 @@
% head construction
-\def\dohandlestructureheadown{\dodoubleempty\dodohandlestructureheadown} % [ref] {nr} {title}
-\def\dohandlestructureheadnop{\dodoubleempty\dodohandlestructureheadnop} % [ref] {title}
-\def\dostartstructurehead {\dotripleempty\dodostartstructurehead} % [settings] [userdata]
+\unexpanded\def\dohandlestructureheadown{\dodoubleempty\dodohandlestructureheadown} % [ref] {nr} {title}
+\unexpanded\def\dohandlestructureheadnop{\dodoubleempty\dodohandlestructureheadnop} % [ref] {title}
+\unexpanded\def\dostartstructurehead {\dotripleempty\dodostartstructurehead} % [settings] [userdata]
\newconditional\currentstructureown
-\def\dodohandlestructureheadown[#1][#2]#3#4%
+\newtoks\everybeforestructurehead % hook, todo: before/after keys
+\newtoks\everyafterstructurehead % hook, todo: before/after keys
+
+\unexpanded\def\dodohandlestructureheadown[#1][#2]#3#4%
{\settrue\currentstructureown
\dohandlestructurehead{#1}{\c!reference={#2},\c!ownnumber={#3},\c!title={#4}}{}} % name ref nr title --
-\def\dodohandlestructureheadnop[#1][#2]#3%
+% \unexpanded\def\dodohandlestructureheadnop[#1][#2]#3%
+% {\setfalse\currentstructureown
+% \dohandlestructurehead{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title --
+
+\unexpanded\def\dodohandlestructureheadnop[#1][#2]% for taco: [key=value] variant
{\setfalse\currentstructureown
- \dohandlestructurehead{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title --
+ \doifassignmentelse{#2}\dodohandlestructureheadnopA\dodohandlestructureheadnopB{#1}{#2}}
-\newtoks\everybeforestructurehead % hook, todo: before/after keys
-\newtoks\everyafterstructurehead % hook, todo: before/after keys
+\unexpanded\def\dodohandlestructureheadnopA#1#2%
+ {\dohandlestructurehead{#1}{#2}{}}
+
+\unexpanded\def\dodohandlestructureheadnopB#1#2#3%
+ {\dohandlestructurehead{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title --
-\def\dodostartstructurehead[#1][#2][#3]% for the moment no grouping, too annoying with page breaks
+\unexpanded\def\dodostartstructurehead[#1][#2][#3]% for the moment no grouping, too annoying with page breaks
{\setfalse\currentstructureown
%\globalpushmacro\currentstructurehead
\xdef\currentstructurehead{#1}%
+ \structureheadparameter\c!beforesection
\the\everybeforestructurehead
- \dohandlestructurehead{#1}{#2}{#3}} % name -- -- -- userdata
+ \dohandlestructurehead{#1}{#2}{#3}} % name -- -- -- userdata (we might move the tagged to here)
-\def\dostopstructurehead[#1]%
- {%\globalpopmacro\currentstructurehead
+\unexpanded\def\dostopstructurehead[#1]%
+ {\dostoptagged\dostoptagged
+ %\globalpopmacro\currentstructurehead
\xdef\currentstructurehead{#1}% recover
+ \structureheadparameter\c!aftersection
\the\everyafterstructurehead}
-\def\donextstructurehead[#1][#2][#3]%
+\unexpanded\def\donextstructurehead[#1][#2][#3]%
{\setfalse\currentstructureown
\xdef\currentstructurehead{#1}%
\dohandlestructurehead{#1}{#2}{#3}} % name -- -- -- userdata
@@ -275,22 +324,35 @@
\let\structureheadprefix\empty \def\structureheadprefixplus{+}
% When do we reset the referenceprefix? This needs to be checked. Does it work
-% at all?
+% at all? Todo: pushpop.
+
+% \def\setstructureheadreference
+% {\edef\structureheadreference {\structureheadparameter\c!reference}%
+% \edef\structureheadreferenceprefix{\structureheadparameter\c!prefix}%
+% \ifx\structureheadreferenceprefix\empty
+% \ifx\currentrefenceprefix\structureheadreferenceprefixplus
+% \setupreferenceprefix[]% yes or no? only when set by structure
+% \fi
+% \else\ifx\structureheadreferenceprefix\structureheadreferenceprefixplus
+% \ifx\structureheadreference\empty
+% \expanded{\setupreferenceprefix[\structureheadreferenceprefixplus]}%
+% \else
+% \expanded{\setupreferenceprefix[\structureheadreference]}% we assume just one reference
+% \fi
+% \else
+% \expanded{\setupreferenceprefix[\structureheadreferenceprefix]}%
+% \fi\fi}
-\def\setstructureheadreference#1% reference
- {\edef\structureheadreference{#1}%
+% pop in stopsection commands unless empty
+
+\def\setstructureheadreference
+ {\edef\structureheadreference {\structureheadparameter\c!reference}%
\edef\structureheadreferenceprefix{\structureheadparameter\c!prefix}%
\ifx\structureheadreferenceprefix\empty
- \setupreferenceprefix[]% yes or no?
- \else\ifx\structureheadreferenceprefix\structureheadreferenceprefixplus
- \ifx\structureheadreference\empty
- \setupreferenceprefix[\structureheadreferenceprefixplus]
- \else
- \setupreferenceprefix[#1]% we assume just one reference
- \fi
+ \let\structureheadreferenceprefix\referenceprefix
\else
- \setupreferenceprefix[\structureheadreferenceprefix]%
- \fi\fi}
+ \setupreferenceprefix[\structureheadreferenceprefix]% currenty no pop
+ \fi}
\setvalue{\??nh:\c!incrementnumber:\v!yes }{\settrue \structureheaddoincrement\settrue \structureheadtolist}
\setvalue{\??nh:\c!incrementnumber:\v!no }{\setfalse\structureheaddoincrement\setfalse\structureheadtolist}
@@ -314,16 +376,41 @@
% use : \currentstructureheadincrement as spec
\fi}
+% \def\setstructureheadplacement
+% {\setfalse\structureheadleaveempty
+% \settrue \structureheaddoplace
+% \setfalse\structureheadhidden
+% \processaction
+% [\structureheadparameter\c!placehead]
+% [ \v!yes=>,
+% \v!empty=>\settrue\structureheadleaveempty,
+% \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace,
+% \v!hidden=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace\settrue\structureheadhidden]}
+
+\setvalue{\??nh:\c!placehead:\v!yes}%
+ {\setfalse\structureheadleaveempty
+ \settrue \structureheaddoplace
+ \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!empty}%
+ {\settrue \structureheadleaveempty
+ \settrue \structureheaddoplace
+ \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!no}%
+ {\settrue \structureheadleaveempty
+ \setfalse\structureheaddoplace
+ \setfalse\structureheadhidden}
+
+\setvalue{\??nh:\c!placehead:\v!hidden}%
+ {\settrue \structureheadleaveempty
+ \setfalse\structureheaddoplace
+ \settrue \structureheadhidden}
+
\def\setstructureheadplacement
- {\settrue\structureheaddoplace
- \setfalse\structureheadleaveempty
- \setfalse\structureheadhidden
- \processaction
- [\structureheadparameter\c!placehead]
- [ \v!yes=>,
- \v!empty=>\settrue\structureheadleaveempty,
- \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace,
- \v!hidden=>\settrue\structureheadhidden\settrue\structureheadleaveempty\setfalse\structureheaddoplace]}
+ {\executeifdefined
+ {\??nh:\c!placehead:\structureheadparameter\c!placehead}
+ {\getvalue{\??nh:\c!placehead:\v!yes}}}
\def\setstructureheaddisplay
{\doifelsevalue{\??nh:\structureheadparameter\c!alternative}\v!horizontal
@@ -351,15 +438,38 @@
\unexpanded\def\thestructureheadsynchonization
{\pagetype[\currentstructureheadcoupling]% hm also number
- \normalexpanded{\noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}}%
\currentstructuresynchronize}
-\unexpanded\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo
+\unexpanded\def\setstructureheadmarking
+ {\normalexpanded{\noexpand\setmarking[\currentstructurehead]{\currentstructurelistnumber}}}
+% \unexpanded\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo
% \def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode!
% \unexpanded\def\fullstructureheadtitle{\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}}
-\unexpanded\def\fullstructureheadtitle{\ctxlua{structure.sections.title()}}
+\let\deepstructurenumbercommand\relax
+\let\deepstructuretitlecommand \relax
+
+\unexpanded\def\fullstructureheadnumber
+ {\edef\currentstructureheadlabeltag{\currentstructureblock\c!label}%
+ \dostarttagged\t!sectionnumber\empty
+ \labeltexts
+ {\structureheadparameter\currentstructureheadlabeltag}
+ {\ifx\deepstructurenumbercommand\relax
+ \structurenumber
+ \else
+ \normalexpanded{\noexpand\deepstructurenumbercommand{\structurenumber}}%
+ \fi}%
+ \dostoptagged}
+
+\unexpanded\def\fullstructureheadtitle
+ {\dostarttagged\t!sectiontitle\empty
+ \ifx\deepstructuretitlecommand\relax
+ \structuretitle
+ \else
+ \normalexpanded{\noexpand\deepstructuretitlecommand{\structuretitle}}%
+ \fi
+ \dostoptagged}
\let\currentstructurehead \empty
\let\currentstructureheadcoupling\empty
@@ -367,9 +477,12 @@
\let\currentstructureheadlevel \!!zerocount
\let\currentstructureheadcounter \!!zerocount
+% here we could inherit as well but it's a bit complex
+
\def\doregisterstructurehead#1#2#3% name data userdata
{\structurecomponent
- [\c!label={\structureheadparameter\c!label},
+ %[\c!label={\structureheadparameter\c!label}, % why { }
+ [\c!label={\structureheadparameter{\currentstructureblock\c!label}},
\c!incrementnumber=\ifconditional\structureheaddoincrement\v!yes\else\v!no\fi, % not that needed
\c!saveinlist=\ifconditional\structureheadtolist\v!yes\else\v!no\fi,
\c!level=\currentstructureheadlevel,
@@ -391,10 +504,11 @@
\c!sectionsegments=\structureheadparameter\c!sectionsegments,
\c!reference=\structureheadreference,
\c!referenceprefix=\structureheadreferenceprefix,
+ \c!backreference=,
\c!command=,
#2]%
[#3]%
- \reportcurrentstructure}
+ \reportcurrentstructure}
\unexpanded\def\placeheadtext {\dosingleempty\doplaceheadtext } % use with care
\unexpanded\def\placeheadnumber{\dosingleempty\doplaceheadnumber} % use with care
@@ -402,9 +516,9 @@
\ifdefined\setupheadcomponentfont \else
\unexpanded\def\setupheadcomponentfont#1#2%
- {\dosetstructureheadattributes\c!style\c!color
+ {\dontconvertfont
+ \dosetstructureheadattributes\c!style\c!color
\dosetstructureheadattributes#1#2%
- \dontconvertfont
\setupinterlinespace}
\fi
@@ -431,14 +545,14 @@
\ifdefined \else \let\presetnumberheadalternative\relax \fi
-\def\dohandlestructurehead#1#2#3% name data userdata
+\def\dohandlestructurehead#1#2#3% name data userdata (we can move #1 to the caller)
{\xdef\currentstructurehead {#1}%
\xdef\currentstructureheadcoupling{\structuresectionheadcoupling\currentstructurehead}%
\xdef\currentstructureheadsection {\structuresectionheadsection \currentstructureheadcoupling}%
\xdef\currentstructureheadlevel {\structuresectionlevel \currentstructureheadsection}%
- %writestatus\m!systems{setup: \currentstructurehead,\currentstructureheadcoupling,\currentstructureheadsection,\currentstructureheadlevel}%
+ %writestatus\m!system{setup: \currentstructurehead,\currentstructureheadcoupling,\currentstructureheadsection,\currentstructureheadlevel}%
%
- \setstructureheadreference{#3}% will change
+ \setstructureheadreference % does not do much currently
\setstructureheadincrement
\setstructureheadplacement
\setstructureheaddisplay
@@ -451,7 +565,7 @@
%
% we might remove the lower level
%
- % not here, after optional \page: \doregisterstructurehead{#1}{#2}{#3}%
+ % not here, after optional \page: \doregisterstructurehead\currentstructurehead{#2}{#3}%
%
% \xdef\currentstructureheadcounter{\currentstructurecounter}% lua call
%
@@ -467,7 +581,7 @@
\ifconditional\structureheaddoincrement
\ifconditional\structureheaddoplace
\dostructureheadspacingbeforeyes
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\let\getstructureheadtitle\fullstructureheadtitle
\ifconditional\structureheadshownumber
@@ -478,12 +592,12 @@
\fi
\dostructureheadspacingafteryes
\else\ifconditional\structureheadhidden
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\placestructureheadhidden % only something when tracing
\else
\dostructureheadspacingbeforenop % toegevoegd ivm subpaginanr / tug sheets
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\placestructureheadempty % just flush 'm
\dostructureheadspacingafternop
@@ -491,19 +605,19 @@
\else
\ifconditional\structureheaddoplace
\dostructureheadspacingbeforeyes
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\let\getstructureheadtitle\fullstructureheadtitle
\placestructureheadtext
\dostructureheadspacingafteryes
\else\ifconditional\structureheadhidden
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\placestructureheadhidden % only something when tracing
\else
% do nothing / should be vbox to 0pt
\dostructureheadspacingbeforenop
- \doregisterstructurehead{#1}{#2}{#3}% after optional \page
+ \doregisterstructurehead\currentstructurehead{#2}{#3}% after optional \page
\let\getstructureheadsyncs\thestructureheadsynchonization
\placestructureheadempty % just flush 'm
\dostructureheadspacingafternop
@@ -512,6 +626,7 @@
\flushingcolumnfloatstrue
\setfalse\ignorehandlepagebreak
% ignorespaces prevents spaces creeping in when after=\dontleavehmode
+ \dostarttagged\t!sectioncontent\empty
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
\ignorespaces
\else
@@ -521,19 +636,23 @@
% typesetting
\unexpanded\def\placestructureheadnumbertext % dummy, will be overloaded
- {\getstructureheadnumber/\getstructureheadtitle
+ {\setstructureheadmarking
+ \getstructureheadnumber/\getstructureheadtitle
\getstructureheadsyncs}
\unexpanded\def\placestructureheadtext % dummy, will be overloaded
- {\getstructureheadtitle
+ {\setstructureheadmarking
+ \getstructureheadtitle
\getstructureheadsyncs}
\unexpanded\def\placestructureheadempty % dummy, will be overloaded
- {\getstructureheadsyncs}
+ {\setstructureheadmarking
+ \getstructureheadsyncs}
\unexpanded\def\placestructureheadhidden
{\setxvalue{\currentstructurehead:sync}%
- {\noexpand\pagetype[\currentstructureheadcoupling]% hm also number
+ {\noexpand\setgvalue{\currentstructurehead:sync}{}%
+ \noexpand\pagetype[\currentstructureheadcoupling]% hm also number
\noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}%
\currentstructuresynchronize}}
@@ -562,13 +681,15 @@
\def\dostructureheadspacingbeforeyes
{\docheckstructureheadbefore
- \dohandlestructureheadpagebreak
- \structureheadparameter\c!inbetween}
+ \dohandlestructureheadpagebreakyes
+ \structureheadparameter\c!inbetween
+ \dostarttagged\t!section\currentstructurehead}
\def\dostructureheadspacingbeforenop
{\docheckstructureheadbefore
- \docheckstructureheadlayout
- \structureheadparameter\c!inbetween}
+ \dohandlestructureheadpagebreaknop
+ \structureheadparameter\c!inbetween
+ \dostarttagged\currentstructurehead\empty}
% \def\emptystructureheadcorrection
% {\ifconditional\structureheadleaveempty % inlined \emptyheadcorrection (with after=\blank)
@@ -625,17 +746,33 @@
{\doifsomething{\structureheadparameter#2}{\expanded{\setuplayouttext[#1][\c!state=\structureheadparameter#2]}}}
\donothing}
+\setvalue{\??nh:\??mk:n:\v!page }{}
+\setvalue{\??nh:\??mk:n:\v!reset}{\resetcurrentstructuremarks}
+\setvalue{\??nh:\??mk:y:\v!page }{} % to be checked: {\resetcurrentstructuremarks}
+\setvalue{\??nh:\??mk:y:\v!reset}{\resetcurrentstructuremarks}
+
\def\docheckstructureheadlayout
- {\doifsomething{\structureheadparameter\c!page}
+ {\doifelsenothing{\structureheadparameter\c!page}
+ {\getvalue{\??nh:\??mk:n:\structureheadparameter\c!marking}}
{\page[\structureheadparameter\c!page]%
+ \getvalue{\??nh:\??mk:y:\structureheadparameter\c!marking}%
\dodocheckstructureheadlayout\v!header\c!header
\dodocheckstructureheadlayout\v!text \c!text
\dodocheckstructureheadlayout\v!footer\c!footer}}
-\def\currentstructurecounter {\ctxlua{structure.sections.depthnumber(\thenamedstructureheadlevel\currentstructurehead)}}
-\def\previousstructurecounter{\ctxlua{structure.sections.depthnumber(\thenamedstructureheadlevel\currentstructurehead-1)}}
+\def\currentstructurecounter {\ctxlua{structures.sections.depthnumber(\thenamedstructureheadlevel\currentstructurehead)}}
+\def\previousstructurecounter{\ctxlua{structures.sections.depthnumber(\thenamedstructureheadlevel\currentstructurehead-1)}}
-\def\dohandlestructureheadpagebreak
+\def\dohandlestructureheadpagebreaknop
+ {\doifelse{\structureheadparameter\c!continue}\v!yes
+ {\ifnum\previousstructurecounter=\zerocount
+ \docheckstructureheadlayout
+ \else\ifnum\currentstructurecounter>\zerocount
+ \docheckstructureheadlayout
+ \fi\fi}%
+ {\docheckstructureheadlayout}}
+
+\def\dohandlestructureheadpagebreakyes
{%[[\currentstructurehead @\thenamedstructureheadlevel\currentstructurehead/prev:\previousstructurecounter/curr:\currentstructurecounter]]
\ifconditional\ignorehandlepagebreak
\setfalse\ignorehandlepagebreak
@@ -657,7 +794,7 @@
% \ifpagebreakdisabled
% \global\pagebreakdisabledfalse
% \else
- \dopreventbreakafterstructureheadauto
+% \dopreventbreakafterstructureheadauto % not ok as it binds the prev par
% \fi
\doif{\structureheadparameter\c!aligntitle}\v!float\indent
\global\precedingstructurelevel\currentstructureheadlevel
@@ -665,8 +802,10 @@
% the next one was: \somebreakmethod
-% \chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing
-\chardef\somestructureheadbreakmethod\plusthree
+
+% 0 = nothing, 1 = weighted, 2 = strict, 3 = vspacing
+
+\setnewconstant\somestructureheadbreakmethod\plusthree
% \def\dopreventbreakafterstructureheadauto % used after \c!before
% {\ifcase\somestructureheadbreakmethod