strc-lev.mkvi /size: 3634 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=strc-lev,
3%D        version=2010.09.23,
4%D          title=\CONTEXT\ Structure Macros,
5%D       subtitle=Automatic Levels,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Structure Macros / Automatic Levels}
15
16%D This module is the result of a discussion between Alan Braslau and
17%D me. I used to have a private (\MKII) module for this but the new
18%D structure code in \MKIV\ is more suitable for this so now we have
19%D it as core functionality. For the moment this an experiment that
20%D Alan and I conduct so it might evolve.
21
22\registerctxluafile{strc-lev}{}
23
24\unprotect
25
26\unexpanded\def\definesectionlevels{\dodoubleargument\strc_levels_define}
27\unexpanded\def\startsectionlevel  {\dosingleempty   \strc_levels_start_section}
28\unexpanded\def\startsubjectlevel  {\dosingleempty   \strc_levels_start_subject}
29
30\unexpanded\def\strc_levels_define[#category][#list]{\clf_definesectionlevels{#category}{#list}}
31\unexpanded\def\stopsectionlevel                    {\clf_stopsectionlevel}
32\unexpanded\def\stopsubjectlevel                    {\clf_stopsectionlevel}
33
34\unexpanded\def\nostarthead{\dotripleargument\strc_levels_start_nop} % used at the lua end
35\unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end
36
37\unexpanded\def\strc_levels_start_section[#category]%
38  {\doifelseassignment{#category}%
39     {\clf_startsectionlevel\plusone{\v!default}{\currentnamedsection}[#category]}%
40     {\clf_startsectionlevel\plusone {#category}{\currentnamedsection}}}
41
42\unexpanded\def\strc_levels_start_subject[#category]%
43  {\doifelseassignment{#category}%
44     {\clf_startsectionlevel\plustwo{\v!default}{\currentnamedsection}[#category]}%
45     {\clf_startsectionlevel\plustwo {#category}{\currentnamedsection}}}
46
47\unexpanded\def\strc_levels_start_nop[#category][#settings][#userdata]%
48  {\blank
49   \noindentation{\tttf[start missing section level #category]}
50   \blank}
51
52\unexpanded\def\strc_levels_stop_nop[#category]%
53  {\blank
54   \noindentation{\tttf[stop missing section level #category]}
55   \blank}
56
57\definesectionlevels
58  [\v!default]
59  [{\v!chapter,\v!title},
60   {\v!section,\v!subject},
61   {\v!subsection,\v!subsubject},
62   {\v!subsubsection,\v!subsubsubject},
63   {\v!subsubsubsection,\v!subsubsubject},
64   {\v!subsubsubsubsection,\v!subsubsubject}]
65
66\let\definestructurelevels\definesectionlevels
67\let\startstructurelevel  \startsectionlevel
68\let\stopstructurelevel   \stopsectionlevel
69
70\protect \endinput
71
72% \starttext
73%
74% \definehead[xxxxxxsection][subsubsection]
75% \setuphead [xxxxxxsection][color=red]
76%
77% \definesectionlevels[main][chapter,section,subsection,subsubsection]
78% \definesectionlevels[next][chapter,section,subsection,xxxxxxsection]
79%
80% \startsectionlevel [main] [title=first top level]
81%
82%     \startsectionlevel [main] [title=first lower level]
83%         \startsectionlevel [main] [title=second lower level]
84%             \startsectionlevel [main] [title=third lower level]
85%                 test
86%             \stopsectionlevel
87%         \stopsectionlevel
88%     \stopsectionlevel
89%
90%     \startsectionlevel [main] [title=first lower level]
91%         \startsectionlevel [main] [title=second lower level]
92%             \startsectionlevel [next] [title=third lower level]
93%                 test
94%             \stopsectionlevel
95%         \stopsectionlevel
96%     \stopsectionlevel
97%
98% \stopsectionlevel
99%
100% \stoptext
101
102