summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-lev.mkvi
blob: b3ec2a2d5a42dbcde6e95e9dbe00fb9b326ea123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%D \module
%D   [       file=strc-lev,
%D        version=2010.09.23,
%D          title=\CONTEXT\ Structure Macros,
%D       subtitle=Automatic Levels,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Structure Macros / Automatic Levels}

%D This module is the result of a discussion between Alan Braslau and
%D me. I used to have a private (\MKII) module for this but the new
%D structure code in \MKIV\ is more suitable for this so now we have
%D it as core functionality. For the moment this an experiment that
%D Alan and I conduct so it might evolve.

\registerctxluafile{strc-lev}{1.001}

\unprotect

\unexpanded\def\definesectionlevels{\dodoubleargument\strc_levels_define}
\unexpanded\def\startsectionlevel  {\dosingleempty   \strc_levels_start }

\unexpanded\def\strc_levels_define[#category][#list]{\ctxcommand{definesectionlevels("#category","#list")}}
\unexpanded\def\strc_levels_start        [#category]{\ctxcommand{startsectionlevel("#category")}}
\unexpanded\def\stopsectionlevel                    {\ctxcommand{stopsectionlevel()}}

\unexpanded\def\nostarthead{\dotripleargument\strc_levels_start_nop} % used at the lua end
\unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end

\unexpanded\def\strc_levels_start[#category]%
  {\doifassignmentelse{#category}
     {\ctxcommand{startsectionlevel("\v!default")}[#category]}
     {\ctxcommand{startsectionlevel("#category")}}}

\unexpanded\def\strc_levels_start_nop[#category][#settings][#userdata]%
  {\blank
   \noindentation{\tttf[start missing section level #category]}
   \blank}

\unexpanded\def\strc_levels_stop_nop[#category]%
  {\blank
   \noindentation{\tttf[stop missing section level #category]}
   \blank}

\definesectionlevels
  [\v!default]
  [\v!chapter,
   \v!section,
   \v!subsection,
   \v!subsubsection,
   \v!subsubsubsection,
   \v!subsubsubsubsection]


\let\definestructurelevels\definesectionlevels
\let\startstructurelevel  \startsectionlevel
\let\stopstructurelevel   \stopsectionlevel

\protect \endinput

% \starttext
%
% \definehead[xxxxxxsection][subsubsection]
% \setuphead [xxxxxxsection][color=red]
%
% \definesectionlevels[main][chapter,section,subsection,subsubsection]
% \definesectionlevels[next][chapter,section,subsection,xxxxxxsection]
%
% \startsectionlevel [main] [title=first top level]
%
%     \startsectionlevel [main] [title=first lower level]
%         \startsectionlevel [main] [title=second lower level]
%             \startsectionlevel [main] [title=third lower level]
%                 test
%             \stopsectionlevel
%         \stopsectionlevel
%     \stopsectionlevel
%
%     \startsectionlevel [main] [title=first lower level]
%         \startsectionlevel [main] [title=second lower level]
%             \startsectionlevel [next] [title=third lower level]
%                 test
%             \stopsectionlevel
%         \stopsectionlevel
%     \stopsectionlevel
%
% \stopsectionlevel
%
% \stoptext