diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-num.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-num.mkiv | 110 |
1 files changed, 75 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-num.mkiv b/Master/texmf-dist/tex/context/base/strc-num.mkiv index 9f6733a6cbd..5b5aebe7dc8 100644 --- a/Master/texmf-dist/tex/context/base/strc-num.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-num.mkiv @@ -39,21 +39,26 @@ % todo: better inheritane system -\definesystemvariable {nn} - -\def\setupstructurecountering{\dodoubleempty\getparameters[\??nn]} +\unexpanded\def\setupstructurecountering{\dodoubleempty\getparameters[\??nn]} \setupstructurecountering [\c!way=\v!by\v!chapter, -% \c!blockway=, -% \c!prefixstopper=, -\c!prefixconnector=., -\c!prefixsegments=\thenamedstructurecounterlevel\currentstructurecounter, -\c!start=0, -\c!state=\v!start, +% \c!blockway=, +% \c!prefixstarter=, +% \c!prefixstopper=, + \c!prefixconnector=., + \c!prefixsegments=\thenamedstructurecounterlevel\currentstructurecounter, + \c!start=0, + \c!state=\v!start, \c!prefix=\v!yes, \c!state=\v!start] +\setupstructurecountering + [\c!prefixsegments=\autostructureprefixsegments\sharedstructurecounterparameter] + +\def\autostructureprefixsegments#1% todo: \c!prefixsegments=\v!auto + {2:\thenamedstructureheadlevel{\ctxlua{structure.sections.way("#1\c!way","\v!by")}}} + % \letvalue{\??nn\s!empty}\empty \def\structurecounterparameter#1#2% @@ -76,13 +81,22 @@ #1% \fi} +\def\sharedstructurecounterparameter#1% + {\csname + \ifcsname\??nn#1\endcsname + \??nn#1% + \else + \s!empty + \fi + \endcsname} + +\let\numberingparameter\sharedstructurecounterparameter + % \def\structurecounterparameter #1#2{\csname\dostructurecounterparameter{\??nn#1}#2\endcsname} % \def\dostructurecounterparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dostructurecounterparentparameter\csname#1\s!number\endcsname#2\fi} % \def\dostructurecounterparentparameter#1#2{\ifx#1\relax\s!empty\else\dostructurecounterparameter#1#2\fi} -% - -\def\definestructurecounter +\unexpanded\def\definestructurecounter {\dodoubleempty\dodefinestructurecounter} \def\dodefinestructurecounter[#1][#2]% @@ -101,7 +115,7 @@ {\getparameters[\??nn#1][\c!number=#2]% \docheckstructurecountersetup{#1}} -\def\setupstructurecounter +\unexpanded\def\setupstructurecounter {\dodoubleargument\dosetupstructurecounter} \def\dosetupstructurecounter[#1][#2]% @@ -189,7 +203,7 @@ \ctxlua{structure.counters.add("\@@thestructurecounter{#1}",1,1)}} \def\doincrementsubstructurecounter[#1][#2]% - {\docheckstructurecounterbypage{#1} + {\docheckstructurecounterbypage{#1}% \ctxlua{structure.counters.add("\@@thestructurecounter{#1}",#2,1)}} \def\convertedstructurecounter @@ -205,6 +219,7 @@ separatorset = "\structurecounterparameter{#1}\c!prefixseparatorset", conversion = "\structurecounterparameter{#1}\c!prefixconversion", conversionset = "\structurecounterparameter{#1}\c!prefixconversionset", + starter = \!!bs\structurecounterparameter{#1}\c!prefixstarter\!!es, stopper = \!!bs\structurecounterparameter{#1}\c!prefixstopper\!!es, set = "\structurecounterparameter{#1}\c!prefixset", segments = "\structurecounterparameter{#1}\c!prefixsegments", @@ -215,6 +230,7 @@ separatorset = "\structurecounterparameter{#1}\c!numberseparatorset", conversion = \!!bs\structurecounterparameter{#1}\c!numberconversion\!!es, conversionset = "\structurecounterparameter{#1}\c!numberconversionset", + starter = \!!bs\structurecounterparameter{#1}\c!numberstarter\!!es, stopper = \!!bs\structurecounterparameter{#1}\c!numberstopper\!!es, segments = "\structurecounterparameter{#1}\c!numbersegments", type = "\structurecounterparameter{#1}\c!type", @@ -232,7 +248,8 @@ separatorset = "\structurecounterparameter{#1}\c!prefixseparatorset", conversion = "\structurecounterparameter{#1}\c!prefixconversion", conversionset = "\structurecounterparameter{#1}\c!prefixconversionset", - stopper = \!!bs\structurecounterparameter{#1}\c!prefixstopper\!!es, + % starter = \!!bs\structurecounterparameter{#1}\c!prefixstarter\!!es, + % stopper = \!!bs\structurecounterparameter{#1}\c!prefixstopper\!!es, set = "\structurecounterparameter{#1}\c!prefixset", segments = "\structurecounterparameter{#1}\c!prefixsegments", connector = \!!bs\structurecounterparameter{#1}\c!prefixconnector\!!es, @@ -242,6 +259,7 @@ separatorset = "\structurecounterparameter{#1}\c!numberseparatorset", conversion = \!!bs\structurecounterparameter{#1}\c!numberconversion\!!es, conversionset = "\structurecounterparameter{#1}\c!numberconversionset", + starter = \!!bs\structurecounterparameter{#1}\c!numberstarter\!!es, stopper = \!!bs\structurecounterparameter{#1}\c!numberstopper\!!es, segments = "\structurecounterparameter{#1}\c!numbersegments", type = "#2", @@ -249,7 +267,7 @@ )}% \endgroup} -\def\convertedsubstructurecounter +\unexpanded\def\convertedsubstructurecounter {\dotripleempty\doconvertedsubstructurecounter} \def\doconvertedsubstructurecounter[#1][#2][#3]% #2 can be n or n:m @@ -306,7 +324,7 @@ % funny, here, todo: these are the defaults -\def\setupnumbering +\unexpanded\def\setupnumbering {\dodoubleempty\getparameters[\??nr]} \setupnumbering @@ -314,17 +332,6 @@ \c!blockway=, \c!state=\v!start] -\def\numberingparameter#1{\csname\??nr#1\endcsname} - -% \c!prefixconnector=., -% \c!stopper=, - -% \c!prefix=\v!no, -% \c!prefixconnector=., -% \c!way=bychapter, -% \c!prefixsegments=2:2, - - %D Helpers: % call: @@ -347,10 +354,16 @@ \def\dostructurecountercomponent#1#2#3#4#5#6#7[#8][#9]% {\begingroup % - #2[#8]% + #2[\s!haslevel=1,#8]% \edef\hasstructurecountercaption{#3\s!hascaption}% - \edef\hasstructurecountertitle{#3\s!hastitle}% - \edef\hasstructurecounternumber{#3\s!hasnumber}% + \edef\hasstructurecountertitle {#3\s!hastitle}% + \edef\hasstructurecounternumber {#3\s!hasnumber}% + \edef\hasstructurecounterlevel {#3\s!haslevel}% + % + \edef\askedprefixsegments{#3\c!prefixsegments}% + \ifx\askedprefixsegments\v!auto + \edef\askedprefixsegments{\autostructureprefixsegments#3}% + \fi % \edef\currentname{#3\c!name}% \ifx\currentname\empty @@ -363,8 +376,8 @@ % \doif{#3\c!title}\v!none{\setfalse\hasstructurecountercaption\setfalse\hasstructurecounternumber}% will become obsolete % - \ifx\hasstructurecounternumber\v!yes - \incrementstructurecounter[\currentcounter]% + \ifx\hasstructurecounternumber\v!yes % here due to previous test but best in callers + \doincrementsubstructurecounter[\currentcounter][\hasstructurecounterlevel]% \fi % \ifx\hasstructurecountercaption\v!yes @@ -421,7 +434,8 @@ conversion = \!!bs#3\c!prefixconversion\!!es, conversionset = "#3\c!prefixconversionset", set = "#3\c!prefixset", - segments = "#3\c!prefixsegments", + % segments = "#3\c!prefixsegments", + segments = "\askedprefixsegments", connector = \!!bs#3\c!prefixconnector\!!es, }, numberdata = { @@ -429,6 +443,7 @@ separatorset = "#3\c!numberseparatorset", conversion = \!!bs#3\c!numberconversion\!!es, conversionset = "#3\c!numberconversionset", + starter = \!!bs#3\c!numberstarter\!!es, stopper = \!!bs#3\c!numberstopper\!!es, segments = "#3\c!numbersegments", }, @@ -440,11 +455,15 @@ \xdef\laststructurecountersynchronize{\ctxlatelua{structure.lists.enhance(\laststructurecounternumber)}}% \else \glet\laststructurecounternumber \relax - \glet\laststructurecounterattribute \relax + \glet\laststructurecounterattribute \attributeunsetvalue \glet\laststructurecountersynchronize\relax \fi \endgroup} +\let\laststructurecounternumber \relax +\let\laststructurecounterattribute \relax +\let\laststructurecountersynchronize\relax + \def\dostructurecountersetup#1#2% name \someparameter {\setupstructurecounter [#1] @@ -456,6 +475,7 @@ \c!prefixseparatorset=#2\c!prefixseparatorset, \c!prefixconversion=#2\c!prefixconversion, \c!prefixconversionset=#2\c!prefixconversionset, + \c!prefixstarter=#2\c!prefixstarter, \c!prefixstopper=#2\c!prefixstopper, \c!prefixset=#2\c!prefixset, \c!prefixsegments=#2\c!prefixsegments, @@ -465,7 +485,27 @@ \c!numberseparatorset=#2\c!numberseparatorset, \c!numberconversion=#2\c!numberconversion, \c!numberconversionset=#2\c!numberconversionset, + \c!numberstarter=#2\c!numberstarter, \c!numberstopper=#2\c!numberstopper, \c!numbersegments=#2\c!numbersegments]} +\def\presetstructurecountersetup#1#2% \setupcommand \someparameter + {#1% + [\c!way =#2\c!way, + \c!prefix =#2\c!prefix, + \c!prefixseparatorset =#2\c!prefixseparatorset, + \c!prefixconversion =#2\c!prefixconversion, + \c!prefixconversionset=#2\c!prefixconversionset, + \c!prefixstarter =#2\c!prefixstarter, + \c!prefixstopper =#2\c!prefixstopper, + \c!prefixsegments =#2\c!prefixsegments, + \c!prefixset =#2\c!prefixset, + \c!prefixconnector =#2\c!prefixconnector, + \c!numberseparatorset =#2\c!numberseparatorset, + \c!numberconversion =#2\c!numberconversion, + \c!numberconversionset=#2\c!numberconversionset, + \c!numberstarter =#2\c!numberstarter, + \c!numberstopper =#2\c!numberstopper, + \c!numbersegments =#2\c!numbersegments]} + \protect \endinput |