3 %% defined later, in a closure
4 #(define-public
(add-toc-item
! markup-symbol text
)
6 #(define-public
(toc-items
)
9 #(let
((toc-item-list
(list
)))
11 (lambda
(markup-symbol text
)
12 (let
((label
(gensym
"toc")))
14 (cons
(list label markup-symbol text
)
16 (make-music
'EventChord
19 'elements
(list
(make-music
'LabelEvent
20 'page-label label
))))))
21 (set
! toc-items
(lambda
()
22 (reverse toc-item-list
))))
25 tocTitleMarkup
= \markup \huge \column {
26 \fill-line
{ \null "Table of Contents" \null }
29 tocItemMarkup
= \markup \fill-line
{
30 \fromproperty #'toc
:text
\fromproperty #'toc
:page
34 #(define-markup-list-command
(table-of-contents layout props
) ()
35 ( _i
"Outputs the table of contents, using the paper variable
36 @code{tocTitleMarkup} for its title, then the list of lines
37 built using the @code{tocItem} music function
38 Usage: @code{\\markuplines \\table-of-contents}" )
39 (cons
(interpret-markup layout props
40 (ly
:output-def-lookup layout
'tocTitleMarkup
))
41 (space-lines
(chain-assoc-get
'baseline-skip props
)
42 (map
(lambda
(toc-item
)
43 (let
((label
(car toc-item
))
44 (toc-markup
(cadr toc-item
))
45 (text
(caddr toc-item
)))
48 (cons
(list
(cons
'toc
:page
49 (markup
#:page-ref label
"XXX" "?"))
50 (cons
'toc
:text text
))
52 (ly
:output-def-lookup layout toc-markup
))))
56 #(define-music-function
(parser location text
) (markup?
)
57 "Add a line to the table of content, using the @code{tocItemMarkup} paper
59 (add-toc-item
! 'tocItemMarkup text
))