strc-doc.lua /size: 40 Kb    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
strc-doc
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to strc-doc.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
-- todo: associate counter with head
10
-- we need to better split the lua/tex end
11
-- we need to freeze and document this module
12 13
-- keep this as is:
14
--
15
-- in section titles by default a zero aborts, so there we need: sectionset=bagger with \definestructureprefixset [bagger] [section-2,section-4] []
16
-- in lists however zero's are ignored, so there numbersegments=2:4 gives result
17 18
local
next
,
type
,
tonumber
,
select
=
next
,
type
,
tonumber
,
select
19
local
find
,
match
=
string
.
find
,
string
.
match
20
local
concat
,
fastcopy
,
insert
,
remove
=
table
.
concat
,
table
.
fastcopy
,
table
.
insert
,
table
.
remove
21
local
sortedhash
,
sortedkeys
=
table
.
sortedhash
,
table
.
sortedkeys
22
local
max
,
min
=
math
.
max
,
math
.
min
23
local
allocate
,
mark
,
accesstable
=
utilities
.
storage
.
allocate
,
utilities
.
storage
.
mark
,
utilities
.
tables
.
accesstable
24
local
setmetatableindex
=
table
.
setmetatableindex
25
local
lpegmatch
,
P
,
C
=
lpeg
.
match
,
lpeg
.
P
,
lpeg
.
C
26 27
local
catcodenumbers
=
catcodes
.
numbers
28
local
ctxcatcodes
=
catcodenumbers
.
ctxcatcodes
29
local
variables
=
interfaces
.
variables
30 31
local
implement
=
interfaces
.
implement
32 33
local
v_last
=
variables
.
last
34
local
v_first
=
variables
.
first
35
local
v_previous
=
variables
.
previous
36
local
v_next
=
variables
.
next
37
local
v_auto
=
variables
.
auto
38
local
v_strict
=
variables
.
strict
39
local
v_all
=
variables
.
all
40
local
v_positive
=
variables
.
positive
41
local
v_current
=
variables
.
current
42 43
local
trace_sectioning
=
false
trackers
.
register
(
"
structures.sectioning
"
,
function
(
v
)
trace_sectioning
=
v
end
)
44
local
trace_details
=
false
trackers
.
register
(
"
structures.details
"
,
function
(
v
)
trace_details
=
v
end
)
45 46
local
report_structure
=
logs
.
reporter
(
"
structure
"
,
"
sectioning
"
)
47
local
report_used
=
logs
.
reporter
(
"
structure
"
)
48 49
local
context
=
context
50
local
commands
=
commands
51 52
local
structures
=
structures
53
local
helpers
=
structures
.
helpers
54
local
documents
=
structures
.
documents
55
local
sections
=
structures
.
sections
56
local
lists
=
structures
.
lists
57
local
counters
=
structures
.
counters
58
local
sets
=
structures
.
sets
59
local
tags
=
structures
.
tags
60 61
local
processors
=
typesetters
.
processors
62
local
applyprocessor
=
processors
.
apply
63
local
startapplyprocessor
=
processors
.
startapply
64
local
stopapplyprocessor
=
processors
.
stopapply
65
local
strippedprocessor
=
processors
.
stripped
66 67
local
convertnumber
=
converters
.
convert
68 69
local
ctx_convertnumber
=
context
.
convertnumber
70
local
ctx_sprint
=
context
.
sprint
71
local
ctx_finalizeauto
=
context
.
finalizeautostructurelevel
72 73
-- -- -- document -- -- --
74 75
local
data
-- the current state
76 77
function
documents
.
initialize
(
)
78
data
=
allocate
{
-- whole data is marked
79
numbers
=
{
}
,
80
forced
=
{
}
,
81
ownnumbers
=
{
}
,
82
status
=
{
}
,
83
checkers
=
{
}
,
84
depth
=
0
,
85
blocks
=
{
}
,
86
block
=
"
"
,
87
}
88
documents
.
data
=
data
89
end
90 91
function
documents
.
reset
(
)
92
data
.
numbers
=
{
}
93
data
.
forced
=
{
}
94
data
.
ownnumbers
=
{
}
95
data
.
status
=
{
}
96
-- data.checkers = { }
97
data
.
depth
=
0
98
end
99 100
documents
.
initialize
(
)
101 102
-- -- -- components -- -- --
103 104
function
documents
.
preset
(
numbers
)
105
local
nofnumbers
=
#
numbers
106
local
ownnumbers
=
{
}
107
data
.
numbers
=
numbers
108
data
.
ownnumbers
=
ownnumbers
109
data
.
depth
=
nofnumbers
110
for
i
=
1
,
nofnumbers
do
111
ownnumbers
[
i
]
=
"
"
112
end
113
sections
.
setnumber
(
nofnumbers
,
"
-1
"
)
114
end
115 116
-- -- -- sections -- -- --
117 118
-- This is just a quick way to have access to prefixes and the numbers (section entry in a ref)
119
-- is not the list entry. An alternative is to use the list index of the last numbered section. In
120
-- that case we should check a buse of the current structure.
121 122
local
collected
=
allocate
(
)
123
local
tobesaved
=
allocate
(
)
124 125
sections
.
collected
=
collected
126
sections
.
tobesaved
=
tobesaved
127 128
-- We have to save this mostly redundant list because we can have (rare)
129
-- cases with own numbers that don't end up in the list so we get out of
130
-- sync when we use (*).
131 132
local
function
initializer
(
)
133
collected
=
sections
.
collected
134
tobesaved
=
sections
.
tobesaved
135
end
136 137
job
.
register
(
'
structures.sections.collected
'
,
tobesaved
,
initializer
)
138 139
local
registered
=
sections
.
registered
or
allocate
(
)
140
sections
.
registered
=
registered
141 142
storage
.
register
(
"
structures/sections/registered
"
,
registered
,
"
structures.sections.registered
"
)
143 144
local
function
update
(
name
,
level
,
section
)
145
for
k
,
v
in
next
,
registered
do
146
if
k
~
=
name
and
v
.
coupling
=
=
name
then
147
report_structure
(
"
updating section level %a to level of %a
"
,
k
,
name
)
148
context
.
doredefinehead
(
k
,
name
)
149
update
(
k
,
level
,
section
)
150
end
151
end
152
end
153 154
function
sections
.
register
(
name
,
specification
)
155
registered
[
name
]
=
specification
156
local
level
=
specification
.
level
157
local
section
=
specification
.
section
158
update
(
name
,
level
,
section
)
159
end
160 161
function
sections
.
currentid
(
)
162
return
#
tobesaved
163
end
164 165
local
lastsaved
=
0
166 167
function
sections
.
save
(
sectiondata
)
168
local
sectiondata
=
helpers
.
simplify
(
sectiondata
)
-- maybe done earlier
169
local
numberdata
=
sectiondata
.
numberdata
170
local
ntobesaved
=
#
tobesaved
171
if
not
numberdata
or
sectiondata
.
metadata
.
nolist
then
172
-- stay
173
else
174
ntobesaved
=
ntobesaved
+
1
175
tobesaved
[
ntobesaved
]
=
numberdata
176
if
not
collected
[
ntobesaved
]
then
177
collected
[
ntobesaved
]
=
numberdata
178
end
179
end
180
lastsaved
=
ntobesaved
181
return
ntobesaved
182
end
183 184
function
sections
.
currentsectionindex
(
)
185
return
lastsaved
-- only for special controlled situations
186
end
187 188
-- See comment above (*). We cannot use the following space optimization:
189
--
190
-- function sections.load()
191
-- setmetatableindex(collected,nil)
192
-- local lists = lists.collected
193
-- for i=1,#lists do
194
-- local list = lists[i]
195
-- local metadata = list.metadata
196
-- if metadata and metadata.kind == "section" and not metadata.nolist then
197
-- local numberdata = list.numberdata
198
-- if numberdata then
199
-- collected[#collected+1] = numberdata
200
-- end
201
-- end
202
-- end
203
-- sections.load = functions.dummy
204
-- end
205
--
206
-- table.setmetatableindex(collected, function(t,i)
207
-- sections.load()
208
-- return collected[i] or { }
209
-- end)
210 211
sections
.
verbose
=
true
212 213
local
sectionblockdata
=
sections
.
sectionblockdata
or
{
}
214
sections
.
sectionblockdata
=
sectionblockdata
215 216
local
levelmap
=
sections
.
levelmap
or
{
}
217
sections
.
levelmap
=
levelmap
218
levelmap
.
block
=
-1
219 220
storage
.
register
(
"
structures/sections/levelmap
"
,
sections
.
levelmap
,
"
structures.sections.levelmap
"
)
221 222
function
sections
.
setlevel
(
name
,
level
)
-- level can be number or parent (=string)
223
local
l
=
tonumber
(
level
)
224
if
not
l
then
225
l
=
levelmap
[
level
]
226
end
227
if
l
and
l
>
0
then
228
levelmap
[
name
]
=
l
229
else
230
-- error
231
end
232
end
233 234
function
sections
.
getlevel
(
name
)
235
return
levelmap
[
name
]
or
0
236
end
237 238
table
.
setmetatableindex
(
sectionblockdata
,
"
table
"
)
239 240
function
sections
.
setblock
(
name
,
settings
)
241
local
block
=
name
or
data
.
block
or
"
unknown
"
-- can be used to set the default
242
data
.
block
=
block
243
sectionblockdata
[
block
]
=
settings
244
return
block
245
end
246 247
local
jobvariables
=
job
.
variables
248
local
pushed_order
=
{
}
249
local
pushed_done
=
{
}
250 251
jobvariables
.
tobesaved
.
sectionblockorder
=
pushed_order
252 253
-- function sections.order()
254
-- return jobvariables.collected.sectionblockorder or pushed_order -- so we have a first pass list too
255
-- end
256 257
function
sections
.
setinitialblock
(
default
)
258
local
order
=
jobvariables
.
collected
.
sectionblockorder
or
pushed_order
259
local
name
=
#
order
>
0
and
order
[
1
]
or
default
or
"
bodypart
"
260
context
.
setsectionblock
{
name
}
261
-- interfaces.setmacro("currentsectionblock",name)
262
-- sections.setblock(name,{})
263
end
264 265
function
sections
.
pushblock
(
name
,
settings
)
266
counters
.
check
(
0
)
-- we assume sane usage of \page between blocks
267
local
block
=
name
or
data
.
block
268
insert
(
data
.
blocks
,
block
)
269
data
.
block
=
block
270
sectionblockdata
[
block
]
=
settings
271
documents
.
reset
(
)
272
if
not
pushed_done
[
name
]
then
273
pushed_done
[
name
]
=
true
274
local
nofpushed
=
#
pushed_order
+
1
275
pushed_order
[
nofpushed
]
=
name
276
end
277
return
block
278
end
279 280
function
sections
.
popblock
(
)
281
local
block
=
remove
(
data
.
blocks
)
or
data
.
block
282
data
.
block
=
block
283
documents
.
reset
(
)
284
return
block
285
end
286 287
local
function
getcurrentblock
(
)
288
return
data
.
block
or
data
.
blocks
[
#
data
.
blocks
]
or
"
unknown
"
289
end
290 291
sections
.
currentblock
=
getcurrentblock
292 293
function
sections
.
currentlevel
(
)
294
return
data
.
depth
295
end
296 297
function
sections
.
getcurrentlevel
(
)
298
context
(
data
.
depth
)
299
end
300 301
local
saveset
=
{
}
-- experiment, see sections/tricky-001.tex
302 303
function
sections
.
setentry
(
given
)
304
-- old number
305
local
numbers
=
data
.
numbers
306
--
307
local
metadata
=
given
.
metadata
308
local
numberdata
=
given
.
numberdata
309
local
references
=
given
.
references
310
local
directives
=
given
.
directives
311
local
userdata
=
given
.
userdata
312 313
if
not
metadata
then
314
metadata
=
{
}
315
given
.
metadata
=
metadata
316
end
317
if
not
numberdata
then
318
numberdata
=
{
}
319
given
.
numberdata
=
numberdata
320
end
321
if
not
references
then
322
references
=
{
}
323
given
.
references
=
references
324
end
325 326
local
ownnumbers
=
data
.
ownnumbers
327
local
forced
=
data
.
forced
328
local
status
=
data
.
status
329
local
olddepth
=
data
.
depth
330
local
givenname
=
metadata
.
name
331
local
mappedlevel
=
levelmap
[
givenname
]
332
local
newdepth
=
tonumber
(
mappedlevel
or
(
olddepth
>
0
and
olddepth
)
or
1
)
-- hm, levelmap only works for section-*
333
local
resetset
=
directives
and
directives
.
resetset
or
"
"
334
-- local resetter = sets.getall("structure:resets",data.block,resetset)
335
-- a trick to permit userdata to overload title, ownnumber and reference
336
-- normally these are passed as argument but nowadays we provide several
337
-- interfaces (we need this because we want to be compatible)
338
if
trace_details
then
339
report_structure
(
"
name %a, mapped level %a, old depth %a, new depth %a, reset set %a
"
,
340
givenname
,
mappedlevel
,
olddepth
,
newdepth
,
resetset
)
341
end
342
if
userdata
then
343
-- kind of obsolete as we can pass them directly anyway ... NEEDS CHECKING !
344
if
userdata
.
reference
and
userdata
.
reference
~
=
"
"
then
given
.
metadata
.
reference
=
userdata
.
reference
;
userdata
.
reference
=
nil
end
345
if
userdata
.
ownnumber
and
userdata
.
ownnumber
~
=
"
"
then
given
.
numberdata
.
ownnumber
=
userdata
.
ownnumber
;
userdata
.
ownnumber
=
nil
end
346
if
userdata
.
title
and
userdata
.
title
~
=
"
"
then
given
.
titledata
.
title
=
userdata
.
title
;
userdata
.
title
=
nil
end
347
if
userdata
.
bookmark
and
userdata
.
bookmark
~
=
"
"
then
given
.
titledata
.
bookmark
=
userdata
.
bookmark
;
userdata
.
bookmark
=
nil
end
348
if
userdata
.
label
and
userdata
.
label
~
=
"
"
then
given
.
titledata
.
label
=
userdata
.
label
;
userdata
.
label
=
nil
end
349
end
350
-- so far for the trick
351
if
saveset
then
352
saveset
[
newdepth
]
=
(
resetset
~
=
"
"
and
resetset
)
or
saveset
[
newdepth
]
or
"
"
353
end
354
if
newdepth
>
olddepth
then
355
for
i
=
olddepth
+
1
,
newdepth
do
356
local
s
=
tonumber
(
sets
.
get
(
"
structure:resets
"
,
data
.
block
,
saveset
and
saveset
[
i
]
or
resetset
,
i
)
)
357
if
trace_details
then
358
report_structure
(
"
new depth %s, old depth %s, reset set %a, reset value %a, current %a
"
,
olddepth
,
newdepth
,
resetset
,
s
,
numbers
[
i
]
)
359
end
360
if
not
s
or
s
=
=
0
then
361
numbers
[
i
]
=
numbers
[
i
]
or
0
362
ownnumbers
[
i
]
=
ownnumbers
[
i
]
or
"
"
363
else
364
numbers
[
i
]
=
s
-
1
365
ownnumbers
[
i
]
=
"
"
366
end
367
status
[
i
]
=
{
}
368
end
369
elseif
newdepth
<
olddepth
then
370
for
i
=
olddepth
,
newdepth
+
1
,
-1
do
371
local
s
=
tonumber
(
sets
.
get
(
"
structure:resets
"
,
data
.
block
,
saveset
and
saveset
[
i
]
or
resetset
,
i
)
)
372
if
trace_details
then
373
report_structure
(
"
new depth %s, old depth %s, reset set %a, reset value %a, current %a
"
,
olddepth
,
newdepth
,
resetset
,
s
,
numbers
[
i
]
)
374
end
375
if
not
s
or
s
=
=
0
then
376
numbers
[
i
]
=
numbers
[
i
]
or
0
377
ownnumbers
[
i
]
=
ownnumbers
[
i
]
or
"
"
378
else
379
numbers
[
i
]
=
s
-
1
380
ownnumbers
[
i
]
=
"
"
381
end
382
status
[
i
]
=
nil
383
end
384
end
385
counters
.
check
(
newdepth
)
386
ownnumbers
[
newdepth
]
=
numberdata
.
ownnumber
or
"
"
387
numberdata
.
ownnumber
=
nil
388
data
.
depth
=
newdepth
389
-- new number
390
olddepth
=
newdepth
391
if
metadata
.
increment
then
392
local
oldn
=
numbers
[
newdepth
]
or
0
393
local
newn
=
0
394
local
fd
=
forced
[
newdepth
]
395
if
fd
then
396
if
fd
[
1
]
=
=
"
add
"
then
397
newn
=
oldn
+
fd
[
2
]
+
1
398
else
399
newn
=
fd
[
2
]
+
1
400
end
401
if
newn
<
0
then
402
newn
=
1
-- maybe zero is nicer
403
end
404
forced
[
newdepth
]
=
nil
405
if
trace_details
then
406
report_structure
(
"
old depth %a, new depth %a, old n %a, new n %a, forced %t
"
,
olddepth
,
newdepth
,
oldn
,
newn
,
fd
)
407
end
408
else
409
newn
=
oldn
+
1
410
if
trace_details
then
411
report_structure
(
"
old depth %a, new depth %a, old n %a, new n %a, increment
"
,
olddepth
,
newdepth
,
oldn
,
newn
)
412
end
413
end
414
numbers
[
newdepth
]
=
newn
415
end
416
status
[
newdepth
]
=
given
or
{
}
417
for
k
,
v
in
next
,
data
.
checkers
do
418
if
v
[
1
]
=
=
newdepth
and
v
[
2
]
then
419
v
[
2
]
(
k
)
420
end
421
end
422
numberdata
.
numbers
=
{
unpack
(
numbers
,
1
,
newdepth
)
}
423
if
not
numberdata
.
block
then
424
numberdata
.
block
=
getcurrentblock
(
)
-- also in references
425
end
426
if
#
ownnumbers
>
0
then
427
numberdata
.
ownnumbers
=
fastcopy
(
ownnumbers
)
-- { unpack(ownnumbers) }
428
end
429
if
trace_details
then
430
report_structure
(
"
name %a, numbers % a, own numbers % a
"
,
givenname
,
numberdata
.
numbers
,
numberdata
.
ownnumbers
)
431
end
432
if
not
references
.
block
then
433
references
.
block
=
getcurrentblock
(
)
-- also in numberdata
434
end
435
local
tag
=
references
.
tag
or
tags
.
getid
(
metadata
.
kind
,
metadata
.
name
)
436
if
tag
and
tag
~
=
"
"
and
tag
~
=
"
?
"
then
437
references
.
tag
=
tag
438
end
439
local
setcomponent
=
structures
.
references
.
setcomponent
440
if
setcomponent
then
441
setcomponent
(
given
)
-- might move to the tex end
442
end
443
references
.
section
=
sections
.
save
(
given
)
444
-- given.numberdata = nil
445
end
446 447
function
sections
.
reportstructure
(
)
448
if
sections
.
verbose
then
449
local
numbers
=
data
.
numbers
450
local
ownnumbers
=
data
.
ownnumbers
451
local
status
=
data
.
status
452
local
depth
=
data
.
depth
453
local
d
=
status
[
depth
]
454
local
o
=
concat
(
ownnumbers
,
"
.
"
,
1
,
depth
)
455
local
n
=
(
numbers
and
concat
(
numbers
,
"
.
"
,
1
,
min
(
depth
,
#
numbers
)
)
)
or
0
456
local
t
=
d
.
titledata
.
title
457
local
l
=
t
or
"
"
458
local
t
=
(
l
~
=
"
"
and
l
)
or
t
or
"
[no title]
"
459
local
m
=
d
.
metadata
.
name
460
if
o
and
not
find
(
o
,
"
^%.*$
"
)
then
461
report_structure
(
"
%s @ level %i : (%s) %s -> %s
"
,
m
,
depth
,
n
,
o
,
t
)
462
elseif
d
.
directives
and
d
.
directives
.
hidenumber
then
463
report_structure
(
"
%s @ level %i : (%s) -> %s
"
,
m
,
depth
,
n
,
t
)
464
else
465
report_structure
(
"
%s @ level %i : %s -> %s
"
,
m
,
depth
,
n
,
t
)
466
end
467
end
468
end
469 470
-- function sections.setnumber(depth,n)
471
-- local forced, depth, new = data.forced, depth or data.depth, tonumber(n) or 0
472
-- if type(n) == "string" then
473
-- if find(n,"^[%+%-]") then
474
-- forced[depth] = { "add", new }
475
-- else
476
-- forced[depth] = { "set", new }
477
-- end
478
-- else
479
-- forced[depth] = { "set", new }
480
-- end
481
-- end
482 483
function
sections
.
setnumber
(
depth
,
n
)
484
data
.
forced
[
depth
or
data
.
depth
]
=
{
485
type
(
n
)
=
=
"
string
"
and
find
(
n
,
"
^[%+%-]
"
)
and
"
add
"
or
"
set
"
,
486
tonumber
(
n
)
or
0
487
}
488
end
489 490
function
sections
.
numberatdepth
(
depth
)
491
return
data
.
numbers
[
tonumber
(
depth
)
or
sections
.
getlevel
(
depth
)
or
0
]
or
0
492
end
493 494
function
sections
.
numbers
(
)
495
return
data
.
numbers
496
end
497 498
function
sections
.
matchingtilldepth
(
depth
,
numbers
,
parentnumbers
)
499
local
dn
=
parentnumbers
or
data
.
numbers
500
local
ok
=
false
501
for
i
=
1
,
depth
do
502
if
dn
[
i
]
=
=
numbers
[
i
]
then
503
ok
=
true
504
else
505
return
false
506
end
507
end
508
return
ok
509
end
510 511
function
sections
.
getnumber
(
depth
)
-- redefined later ...
512
context
(
data
.
numbers
[
depth
]
or
0
)
513
end
514 515
function
sections
.
set
(
key
,
value
)
516
data
.
status
[
data
.
depth
]
[
key
]
=
value
-- may be nil for a reset
517
end
518 519
function
sections
.
cct
(
)
520
local
metadata
=
data
.
status
[
data
.
depth
]
.
metadata
521
context
(
metadata
and
metadata
.
catcodes
or
ctxcatcodes
)
522
end
523 524
-- this one will become: return catcode, d (etc)
525 526
function
sections
.
structuredata
(
depth
,
key
,
default
,
honorcatcodetable
)
-- todo: spec table and then also depth
527
if
depth
then
528
depth
=
levelmap
[
depth
]
or
tonumber
(
depth
)
529
end
530
if
not
depth
or
depth
=
=
0
then
531
depth
=
data
.
depth
532
end
533
local
data
=
data
.
status
[
depth
]
534
local
d
535
if
data
then
536
if
find
(
key
,
"
.
"
,
1
,
true
)
then
537
d
=
accesstable
(
key
,
data
)
538
else
539
d
=
data
.
titledata
540
d
=
d
and
d
[
key
]
541
end
542
end
543
if
d
and
type
(
d
)
~
=
"
table
"
then
544
if
honorcatcodetable
=
=
true
or
honorcatcodetable
=
=
v_auto
then
545
local
metadata
=
data
.
metadata
546
local
catcodes
=
metadata
and
metadata
.
catcodes
547
if
catcodes
then
548
ctx_sprint
(
catcodes
,
d
)
549
else
550
context
(
d
)
551
end
552
elseif
not
honorcatcodetable
or
honorcatcodetable
=
=
"
"
then
553
context
(
d
)
554
else
555
local
catcodes
=
catcodenumbers
[
honorcatcodetable
]
556
if
catcodes
then
557
ctx_sprint
(
catcodes
,
d
)
558
else
559
context
(
d
)
560
end
561
end
562
elseif
default
then
563
context
(
default
)
564
end
565
end
566 567
function
sections
.
userdata
(
depth
,
key
,
default
)
568
if
depth
then
569
depth
=
levelmap
[
depth
]
or
tonumber
(
depth
)
570
end
571
if
not
depth
or
depth
=
=
0
then
572
depth
=
data
.
depth
573
end
574
if
depth
>
0
then
575
local
userdata
=
data
.
status
[
depth
]
576
userdata
=
userdata
and
userdata
.
userdata
577
userdata
=
(
userdata
and
userdata
[
key
]
)
or
default
578
if
userdata
then
579
context
(
userdata
)
580
end
581
end
582
end
583 584
function
sections
.
setchecker
(
name
,
level
,
command
)
-- hm, checkers are not saved
585
data
.
checkers
[
name
]
=
(
name
and
command
and
level
>
=
0
and
{
level
,
command
}
)
or
nil
586
end
587 588
function
sections
.
current
(
)
589
return
data
.
status
[
data
.
depth
]
590
end
591 592
local
function
depthnumber
(
n
)
593
local
depth
=
data
.
depth
594
if
not
n
or
n
=
=
0
then
595
n
=
depth
596
elseif
n
<
0
then
597
n
=
depth
+
n
598
end
599
return
data
.
numbers
[
n
]
or
0
600
end
601 602
sections
.
depthnumber
=
depthnumber
603 604
function
sections
.
autodepth
(
numbers
)
605
for
i
=
#
numbers
,
1
,
-1
do
606
if
numbers
[
i
]
~
=
0
then
607
return
i
608
end
609
end
610
return
0
611
end
612 613
--
614 615
function
structures
.
currentsectionnumber
(
)
-- brr, namespace wrong
616
local
sc
=
sections
.
current
(
)
617
return
sc
and
sc
.
numberdata
618
end
619 620
-- \dorecurse{3} {
621
-- \chapter{Blabla} \subsection{bla 1 1} \subsection{bla 1 2}
622
-- \section{bla 2} \subsection{bla 2 1} \subsection{bla 2 2}
623
-- }
624 625
-- sign=all => also zero and negative
626
-- sign=positive => also zero
627
-- sign=hang => llap sign
628 629
-- this can be a local function
630 631
local
function
process
(
index
,
numbers
,
ownnumbers
,
criterium
,
separatorset
,
conversion
,
conversionset
,
entry
,
result
,
preceding
,
done
,
language
)
632
-- todo: too much (100 steps)
633
local
number
=
numbers
and
(
numbers
[
index
]
or
0
)
634
local
ownnumber
=
ownnumbers
and
ownnumbers
[
index
]
or
"
"
635
if
number
>
criterium
or
(
ownnumber
~
=
"
"
)
then
636
local
block
=
(
entry
.
block
~
=
"
"
and
entry
.
block
)
or
sections
.
currentblock
(
)
-- added
637
if
preceding
then
638
local
separator
=
sets
.
get
(
"
structure:separators
"
,
block
,
separatorset
,
preceding
,
"
.
"
)
639
if
separator
then
640
if
result
then
641
result
[
#
result
+
1
]
=
strippedprocessor
(
separator
)
642
else
643
applyprocessor
(
separator
)
644
end
645
end
646
preceding
=
false
647
end
648
if
result
then
649
if
ownnumber
~
=
"
"
then
650
result
[
#
result
+
1
]
=
ownnumber
651
elseif
conversion
and
conversion
~
=
"
"
then
-- traditional (e.g. used in itemgroups) .. inherited!
652
result
[
#
result
+
1
]
=
convertnumber
(
conversion
,
number
,
language
)
653
else
654
local
theconversion
=
sets
.
get
(
"
structure:conversions
"
,
block
,
conversionset
,
index
,
"
numbers
"
)
655
result
[
#
result
+
1
]
=
convertnumber
(
theconversion
,
number
,
language
)
656
end
657
else
658
if
ownnumber
~
=
"
"
then
659
applyprocessor
(
ownnumber
)
660
elseif
conversion
and
conversion
~
=
"
"
then
-- traditional (e.g. used in itemgroups)
661
ctx_convertnumber
(
conversion
,
number
)
662
else
663
local
theconversion
=
sets
.
get
(
"
structure:conversions
"
,
block
,
conversionset
,
index
,
"
numbers
"
)
664
local
data
=
startapplyprocessor
(
theconversion
)
665
ctx_convertnumber
(
data
or
"
numbers
"
,
number
)
666
stopapplyprocessor
(
)
667
end
668
end
669
return
index
,
true
670
else
671
return
preceding
or
false
,
done
672
end
673
end
674 675
-- kind : section number prefix
676 677
function
sections
.
typesetnumber
(
entry
,
kind
,
...
)
678
--
679
-- Maybe the hiding becomes an option .. after all this test was there
680
-- for a reason, but for now we have this:
681
--
682
-- if entry and entry.hidenumber ~= true then
683
if
entry
then
684
local
separatorset
=
"
"
685
local
conversionset
=
"
"
686
local
conversion
=
"
"
687
local
groupsuffix
=
"
"
688
local
stopper
=
"
"
689
local
starter
=
"
"
690
local
connector
=
"
"
691
local
set
=
"
"
692
local
segments
=
"
"
693
local
criterium
=
"
"
694
local
language
=
"
"
695
for
d
=
1
,
select
(
"
#
"
,
...
)
do
696
local
data
=
select
(
d
,
...
)
-- can be multiple parametersets
697
if
data
then
698
if
separatorset
=
=
"
"
then
separatorset
=
data
.
separatorset
or
"
"
end
699
if
conversionset
=
=
"
"
then
conversionset
=
data
.
conversionset
or
"
"
end
700
if
conversion
=
=
"
"
then
conversion
=
data
.
conversion
or
"
"
end
701
if
groupsuffix
=
=
"
"
then
groupsuffix
=
data
.
groupsuffix
or
"
"
end
702
if
stopper
=
=
"
"
then
stopper
=
data
.
stopper
or
"
"
end
703
if
starter
=
=
"
"
then
starter
=
data
.
starter
or
"
"
end
704
if
connector
=
=
"
"
then
connector
=
data
.
connector
or
"
"
end
705
if
set
=
=
"
"
then
set
=
data
.
set
or
"
"
end
706
if
segments
=
=
"
"
then
segments
=
data
.
segments
or
"
"
end
707
if
criterium
=
=
"
"
then
criterium
=
data
.
criterium
or
"
"
end
708
if
language
=
=
"
"
then
language
=
data
.
language
or
"
"
end
709
end
710
end
711
if
separatorset
=
=
"
"
then
separatorset
=
"
default
"
end
712
if
conversionset
=
=
"
"
then
conversionset
=
"
default
"
end
-- not used
713
if
conversion
=
=
"
"
then
conversion
=
nil
end
714
if
groupsuffix
=
=
"
"
then
groupsuffix
=
nil
end
715
if
stopper
=
=
"
"
then
stopper
=
nil
end
716
if
starter
=
=
"
"
then
starter
=
nil
end
717
if
connector
=
=
"
"
then
connector
=
nil
end
718
if
set
=
=
"
"
then
set
=
"
default
"
end
719
if
segments
=
=
"
"
then
segments
=
nil
end
720
if
language
=
=
"
"
then
language
=
nil
end
721
--
722
if
criterium
=
=
v_strict
then
723
criterium
=
0
724
elseif
criterium
=
=
v_positive
then
725
criterium
=
-1
726
elseif
criterium
=
=
v_all
then
727
criterium
=
-1000000
728
else
729
criterium
=
0
730
end
731
--
732
local
firstprefix
=
0
733
local
lastprefix
=
16
-- too much, could max found level
734
if
segments
=
=
v_current
then
735
firstprefix
=
data
.
depth
736
lastprefix
=
firstprefix
737
elseif
segments
then
738
local
f
,
l
=
match
(
tostring
(
segments
)
,
"
^(.-):(.+)$
"
)
739
if
l
=
=
"
*
"
or
l
=
=
v_all
then
740
l
=
100
-- new
741
end
742
if
f
and
l
then
743
-- 0:100, chapter:subsubsection
744
firstprefix
=
tonumber
(
f
)
or
sections
.
getlevel
(
f
)
or
0
745
lastprefix
=
tonumber
(
l
)
or
sections
.
getlevel
(
l
)
or
100
746
else
747
-- 3, section
748
local
fl
=
tonumber
(
segments
)
or
sections
.
getlevel
(
segments
)
-- generalize
749
if
fl
then
750
firstprefix
=
fl
751
lastprefix
=
fl
752
end
753
end
754
end
755
--
756
local
numbers
=
entry
.
numbers
757
local
ownnumbers
=
entry
.
ownnumbers
758
if
numbers
then
759
local
done
=
false
760
local
preceding
=
false
761
--
762
local
result
=
kind
=
=
"
direct
"
and
{
}
763
if
result
then
764
connector
=
false
765
end
766
--
767
local
prefixlist
=
set
and
sets
.
getall
(
"
structure:prefixes
"
,
"
"
,
set
)
-- "" == block
768
if
starter
then
769
if
result
then
770
result
[
#
result
+
1
]
=
strippedprocessor
(
starter
)
771
else
772
applyprocessor
(
starter
)
773
end
774
end
775
if
prefixlist
and
(
kind
=
=
"
section
"
or
kind
=
=
"
prefix
"
or
kind
=
=
"
direct
"
)
then
776
-- find valid set (problem: for sectionnumber we should pass the level)
777
-- no holes
778
local
b
=
1
779
local
e
=
#
prefixlist
780
local
bb
=
0
781
local
ee
=
0
782
-- find last valid number
783
for
k
=
e
,
b
,
-1
do
784
local
prefix
=
prefixlist
[
k
]
785
local
index
=
sections
.
getlevel
(
prefix
)
or
k
786
if
index
>
=
firstprefix
and
index
<
=
lastprefix
then
787
local
number
=
numbers
and
numbers
[
index
]
788
if
number
then
789
local
ownnumber
=
ownnumbers
and
ownnumbers
[
index
]
or
"
"
790
if
number
>
0
or
(
ownnumber
~
=
"
"
)
then
791
break
792
else
793
e
=
k
-1
794
end
795
end
796
end
797
end
798
-- find valid range
799
for
k
=
b
,
e
do
800
local
prefix
=
prefixlist
[
k
]
801
local
index
=
sections
.
getlevel
(
prefix
)
or
k
802
if
index
>
=
firstprefix
and
index
<
=
lastprefix
then
803
local
number
=
numbers
and
numbers
[
index
]
804
if
number
then
805
local
ownnumber
=
ownnumbers
and
ownnumbers
[
index
]
or
"
"
806
if
number
>
0
or
(
ownnumber
~
=
"
"
)
then
807
if
bb
=
=
0
then
808
bb
=
k
809
end
810
ee
=
k
811
elseif
criterium
>
=
0
then
812
bb
=
0
813
ee
=
0
814
end
815
else
816
break
817
end
818
end
819
end
820
-- print valid range
821
for
k
=
bb
,
ee
do
822
local
prefix
=
prefixlist
[
k
]
823
local
index
=
sections
.
getlevel
(
prefix
)
or
k
824
if
index
>
=
firstprefix
and
index
<
=
lastprefix
then
825
preceding
,
done
=
process
(
index
,
numbers
,
ownnumbers
,
criterium
,
separatorset
,
conversion
,
conversionset
,
entry
,
result
,
preceding
,
done
,
language
)
826
end
827
end
828
else
829
-- also holes check
830
for
index
=
firstprefix
,
lastprefix
do
831
preceding
,
done
=
process
(
index
,
numbers
,
ownnumbers
,
criterium
,
separatorset
,
conversion
,
conversionset
,
entry
,
result
,
preceding
,
done
,
language
)
832
end
833
end
834
--
835
if
done
then
836
if
connector
and
kind
=
=
'
prefix
'
then
837
if
result
then
838
-- can't happen as we're in 'direct'
839
else
840
applyprocessor
(
connector
)
841
end
842
else
843
if
groupsuffix
and
kind
~
=
"
prefix
"
then
844
if
result
then
845
result
[
#
result
+
1
]
=
strippedprocessor
(
groupsuffix
)
846
else
847
applyprocessor
(
groupsuffix
)
848
end
849
end
850
if
stopper
then
851
if
result
then
852
result
[
#
result
+
1
]
=
strippedprocessor
(
stopper
)
853
else
854
applyprocessor
(
stopper
)
855
end
856
end
857
end
858
end
859
return
result
-- a table !
860
else
861
-- report_structure("error: no numbers")
862
end
863
end
864
end
865 866
function
sections
.
title
(
)
867
local
sc
=
sections
.
current
(
)
868
if
sc
then
869
helpers
.
title
(
sc
.
titledata
.
title
,
sc
.
metadata
)
870
end
871
end
872 873
function
sections
.
findnumber
(
depth
,
what
)
-- needs checking (looks wrong and slow too)
874
local
data
=
data
.
status
[
depth
or
data
.
depth
]
875
if
not
data
then
876
return
877
end
878
local
references
=
data
.
references
879
if
not
references
then
880
return
881
end
882
local
index
=
references
.
section
883
local
collected
=
sections
.
collected
884
local
sectiondata
=
collected
[
index
]
885
if
sectiondata
and
sectiondata
.
hidenumber
~
=
true
then
-- can be nil
886
local
quit
=
what
=
=
v_previous
or
what
=
=
v_next
887
if
what
=
=
v_first
or
what
=
=
v_previous
then
888
for
i
=
index
-1
,
1
,
-1
do
889
local
s
=
collected
[
i
]
890
if
s
then
891
local
n
=
s
.
numbers
892
if
#
n
=
=
depth
and
n
[
depth
]
and
n
[
depth
]
~
=
0
then
893
sectiondata
=
s
894
if
quit
then
895
break
896
end
897
elseif
#
n
<
depth
then
898
break
899
end
900
end
901
end
902
elseif
what
=
=
v_last
or
what
=
=
v_next
then
903
for
i
=
index
+
1
,
#
collected
do
904
local
s
=
collected
[
i
]
905
if
s
then
906
local
n
=
s
.
numbers
907
if
#
n
=
=
depth
and
n
[
depth
]
and
n
[
depth
]
~
=
0
then
908
sectiondata
=
s
909
if
quit
then
910
break
911
end
912
elseif
#
n
<
depth
then
913
break
914
end
915
end
916
end
917
end
918
return
sectiondata
919
end
920
end
921 922
function
sections
.
finddata
(
depth
,
what
)
923
local
data
=
data
.
status
[
depth
or
data
.
depth
]
924
if
not
data
then
925
return
926
end
927
local
references
=
data
.
references
928
if
not
references
then
929
return
930
end
931
local
index
=
references
.
listindex
932
if
not
index
then
933
return
934
end
935
local
collected
=
structures
.
lists
.
collected
936
local
quit
=
what
=
=
v_previous
or
what
=
=
v_next
937
if
what
=
=
v_first
or
what
=
=
v_previous
then
938
for
i
=
index
-1
,
1
,
-1
do
939
local
s
=
collected
[
i
]
940
if
not
s
then
941
break
942
elseif
s
.
metadata
.
kind
=
=
"
section
"
then
-- maybe check on name
943
local
n
=
s
.
numberdata
.
numbers
944
if
#
n
=
=
depth
and
n
[
depth
]
and
n
[
depth
]
~
=
0
then
945
data
=
s
946
if
quit
then
947
break
948
end
949
elseif
#
n
<
depth
then
950
break
951
end
952
end
953
end
954
elseif
what
=
=
v_last
or
what
=
=
v_next
then
955
for
i
=
index
+
1
,
#
collected
do
956
local
s
=
collected
[
i
]
957
if
not
s
then
958
break
959
elseif
s
.
metadata
.
kind
=
=
"
section
"
then
-- maybe check on name
960
local
n
=
s
.
numberdata
.
numbers
961
if
#
n
=
=
depth
and
n
[
depth
]
and
n
[
depth
]
~
=
0
then
962
data
=
s
963
if
quit
then
964
break
965
end
966
elseif
#
n
<
depth
then
967
break
968
end
969
end
970
end
971
end
972
return
data
973
end
974 975
function
sections
.
internalreference
(
sectionname
,
what
)
-- to be used in pagebuilder (no marks used)
976
local
r
=
type
(
sectionname
)
=
=
"
number
"
and
sectionname
or
registered
[
sectionname
]
977
if
r
then
978
local
data
=
sections
.
finddata
(
r
.
level
,
what
)
979
return
data
and
data
.
references
and
data
.
references
.
internal
980
end
981
end
982 983
function
sections
.
fullnumber
(
depth
,
what
)
984
local
sectiondata
=
sections
.
findnumber
(
depth
,
what
)
985
if
sectiondata
then
986
sections
.
typesetnumber
(
sectiondata
,
'
section
'
,
sectiondata
)
987
end
988
end
989 990
function
sections
.
getnumber
(
depth
,
what
)
-- redefined here
991
local
sectiondata
=
sections
.
findnumber
(
depth
,
what
)
992
local
askednumber
=
0
993
if
sectiondata
then
994
local
numbers
=
sectiondata
.
numbers
995
if
numbers
then
996
askednumber
=
numbers
[
depth
]
or
0
997
end
998
end
999
context
(
askednumber
)
1000
end
1001 1002
-- maybe handy
1003 1004
function
sections
.
showstructure
(
)
1005 1006
local
tobesaved
=
structures
.
lists
.
tobesaved
1007 1008
if
not
tobesaved
then
1009
return
1010
end
1011 1012
local
levels
=
setmetatableindex
(
"
table
"
)
1013
local
names
=
setmetatableindex
(
"
table
"
)
1014 1015
report_used
(
)
1016
report_used
(
"
sections
"
)
1017
for
i
=
1
,
#
tobesaved
do
1018
local
si
=
tobesaved
[
i
]
1019
local
md
=
si
.
metadata
1020
if
md
and
md
.
kind
=
=
"
section
"
then
1021
local
level
=
md
.
level
1022
local
name
=
md
.
name
1023
local
numbers
=
si
.
numberdata
.
numbers
1024
local
title
=
si
.
titledata
.
title
1025
report_used
(
"
%i : %-10s %-20s %s
"
,
level
,
concat
(
numbers
,
"
.
"
)
,
name
,
title
)
1026
levels
[
level
]
[
name
]
=
true
1027
names
[
name
]
[
level
]
=
true
1028
end
1029
end
1030
report_used
(
)
1031
report_used
(
"
levels
"
)
1032
for
level
,
list
in
sortedhash
(
levels
)
do
1033
report_used
(
"
%s : % t
"
,
level
,
sortedkeys
(
list
)
)
1034
end
1035
report_used
(
)
1036
report_used
(
"
names
"
)
1037
for
name
,
list
in
sortedhash
(
names
)
do
1038
report_used
(
"
%-10s : % t
"
,
name
,
sortedkeys
(
list
)
)
1039
end
1040
report_used
(
)
1041
end
1042 1043
-- experimental
1044 1045
local
levels
=
{
}
1046 1047
local
function
autonextstructurelevel
(
level
)
1048
if
level
>
#
levels
then
1049
for
i
=
#
levels
+
1
,
level
do
1050
levels
[
i
]
=
false
1051
end
1052
else
1053
for
i
=
level
,
#
levels
do
1054
if
levels
[
i
]
then
1055
ctx_finalizeauto
(
)
1056
levels
[
i
]
=
false
1057
end
1058
end
1059
end
1060
levels
[
level
]
=
true
1061
end
1062 1063
local
function
autofinishstructurelevels
(
)
1064
for
i
=
1
,
#
levels
do
1065
if
levels
[
i
]
then
1066
ctx_finalizeauto
(
)
1067
end
1068
end
1069
levels
=
{
}
1070
end
1071 1072
implement
{
1073
name
=
"
autonextstructurelevel
"
,
1074
actions
=
autonextstructurelevel
,
1075
arguments
=
"
integer
"
,
1076
}
1077 1078
implement
{
1079
name
=
"
autofinishstructurelevels
"
,
1080
actions
=
autofinishstructurelevels
,
1081
}
1082 1083
-- interface (some are actually already commands, like sections.fullnumber)
1084 1085
implement
{
1086
name
=
"
depthnumber
"
,
1087
actions
=
{
depthnumber
,
context
}
,
1088
arguments
=
"
integer
"
,
1089
}
1090 1091
implement
{
name
=
"
structurenumber
"
,
actions
=
sections
.
fullnumber
}
1092
implement
{
name
=
"
structuretitle
"
,
actions
=
sections
.
title
}
1093 1094
implement
{
name
=
"
structurevariable
"
,
actions
=
sections
.
structuredata
,
arguments
=
{
false
,
"
string
"
}
}
1095
implement
{
name
=
"
structureuservariable
"
,
actions
=
sections
.
userdata
,
arguments
=
{
false
,
"
string
"
}
}
1096
implement
{
name
=
"
structurecatcodedget
"
,
actions
=
sections
.
structuredata
,
arguments
=
{
false
,
"
string
"
,
false
,
true
}
}
1097
implement
{
name
=
"
structuregivencatcodedget
"
,
actions
=
sections
.
structuredata
,
arguments
=
{
false
,
"
string
"
,
false
,
"
integer
"
}
}
1098
implement
{
name
=
"
structureautocatcodedget
"
,
actions
=
sections
.
structuredata
,
arguments
=
{
false
,
"
string
"
,
false
,
"
string
"
}
}
1099 1100
implement
{
name
=
"
namedstructurevariable
"
,
actions
=
sections
.
structuredata
,
arguments
=
"
2 strings
"
}
1101
implement
{
name
=
"
namedstructureuservariable
"
,
actions
=
sections
.
userdata
,
arguments
=
"
2 strings
"
}
1102 1103
implement
{
name
=
"
setstructurelevel
"
,
actions
=
sections
.
setlevel
,
arguments
=
"
2 strings
"
}
1104
implement
{
name
=
"
getstructurelevel
"
,
actions
=
sections
.
getcurrentlevel
,
arguments
=
"
string
"
}
1105
implement
{
name
=
"
setstructurenumber
"
,
actions
=
sections
.
setnumber
,
arguments
=
{
"
integer
"
,
"
string
"
}
}
-- string as we support +-
1106
implement
{
name
=
"
getstructurenumber
"
,
actions
=
sections
.
getnumber
,
arguments
=
"
integer
"
}
1107
implement
{
name
=
"
getsomestructurenumber
"
,
actions
=
sections
.
getnumber
,
arguments
=
{
"
integer
"
,
"
string
"
}
}
1108
implement
{
name
=
"
getfullstructurenumber
"
,
actions
=
sections
.
fullnumber
,
arguments
=
"
integer
"
}
1109
implement
{
name
=
"
getsomefullstructurenumber
"
,
actions
=
sections
.
fullnumber
,
arguments
=
{
"
integer
"
,
"
string
"
}
}
1110
implement
{
name
=
"
getspecificstructuretitle
"
,
actions
=
sections
.
structuredata
,
arguments
=
{
"
string
"
,
"
'titledata.title'
"
,
false
,
"
string
"
}
}
1111 1112
implement
{
name
=
"
reportstructure
"
,
actions
=
sections
.
reportstructure
}
1113
implement
{
name
=
"
showstructure
"
,
actions
=
sections
.
showstructure
}
1114 1115
implement
{
1116
name
=
"
registersection
"
,
1117
actions
=
sections
.
register
,
1118
arguments
=
{
1119
"
string
"
,
1120
{
1121
{
"
coupling
"
}
,
1122
{
"
section
"
}
,
1123
{
"
level
"
,
"
integer
"
}
,
1124
{
"
parent
"
}
,
1125
}
1126
}
1127
}
1128 1129
implement
{
1130
name
=
"
setsectionentry
"
,
1131
actions
=
sections
.
setentry
,
1132
arguments
=
{
1133
{
1134
{
"
references
"
,
{
1135
{
"
internal
"
,
"
integer
"
}
,
1136
{
"
block
"
}
,
1137
{
"
backreference
"
}
,
1138
{
"
prefix
"
}
,
1139
{
"
reference
"
}
,
1140
}
1141
}
,
1142
{
"
directives
"
,
{
1143
{
"
resetset
"
}
1144
}
1145
}
,
1146
{
"
metadata
"
,
{
1147
{
"
kind
"
}
,
1148
{
"
name
"
}
,
1149
{
"
catcodes
"
,
"
integer
"
}
,
1150
{
"
coding
"
}
,
1151
{
"
xmlroot
"
}
,
1152
{
"
xmlsetup
"
}
,
1153
{
"
nolist
"
,
"
boolean
"
}
,
1154
{
"
increment
"
}
,
1155
}
1156
}
,
1157
{
"
titledata
"
,
{
1158
{
"
label
"
}
,
1159
{
"
title
"
}
,
1160
{
"
bookmark
"
}
,
1161
{
"
marking
"
}
,
1162
{
"
list
"
}
,
1163
}
1164
}
,
1165
{
"
numberdata
"
,
{
1166
{
"
block
"
}
,
1167
{
"
hidenumber
"
,
"
boolean
"
}
,
1168
{
"
separatorset
"
}
,
1169
{
"
conversionset
"
}
,
1170
{
"
conversion
"
}
,
1171
{
"
starter
"
}
,
1172
{
"
stopper
"
}
,
1173
{
"
set
"
}
,
1174
{
"
segments
"
}
,
1175
{
"
ownnumber
"
}
,
1176
{
"
language
"
}
,
1177
{
"
criterium
"
}
,
1178
}
,
1179
}
,
1180
{
"
userdata
"
}
,
1181
}
1182
}
1183
}
1184 1185
-- os.exit()
1186 1187
implement
{
1188
name
=
"
setsectionblock
"
,
1189
actions
=
sections
.
setblock
,
1190
arguments
=
{
"
string
"
,
{
{
"
bookmark
"
}
}
}
1191
}
1192 1193
implement
{
1194
name
=
"
setinitialsectionblock
"
,
1195
actions
=
sections
.
setinitialblock
,
1196
arguments
=
"
string
"
,
1197
-- onlyonce = true,
1198
}
1199 1200
implement
{
1201
name
=
"
pushsectionblock
"
,
1202
actions
=
sections
.
pushblock
,
1203
arguments
=
{
"
string
"
,
{
{
"
bookmark
"
}
}
}
1204
}
1205 1206
implement
{
1207
name
=
"
popsectionblock
"
,
1208
actions
=
sections
.
popblock
,
1209
}
1210