blob: c3fd5ab57d0ab3c236728d03350c65035e316bd3 (
about) (
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
|
\version "2.19.22"
%% defined later, in a closure
#(define-public (add-toc-item! markup-symbol text)
#f)
#(define-public (toc-items)
#f)
#(let ((toc-item-list (list)))
(call-after-session (lambda () (set! toc-item-list '())))
(set! add-toc-item!
(lambda (markup-symbol text)
(let ((label (gensym "toc")))
(set! toc-item-list
(cons (list label markup-symbol text)
toc-item-list))
(make-music 'EventChord
'page-marker #t
'page-label label
'elements (list (make-music 'LabelEvent
'page-label label))))))
(set! toc-items (lambda ()
(reverse toc-item-list))))
\paper {
tocTitleMarkup = \markup \huge \column {
\fill-line { \null "Table of Contents" \null }
\null
}
tocItemMarkup = \markup \fill-line {
\fromproperty #'toc:text \fromproperty #'toc:page
}
}
tocItemWithDotsMarkup = \markup \fill-with-pattern #1 #RIGHT .
\fromproperty #'toc:text \fromproperty #'toc:page
#(define-markup-list-command (table-of-contents layout props) ()
( _i "Outputs the table of contents, using the paper variable
@code{tocTitleMarkup} for its title, then the list of lines
built using the @code{tocItem} music function
Usage: @code{\\markuplist \\table-of-contents}" )
(cons (interpret-markup layout props
(ly:output-def-lookup layout 'tocTitleMarkup))
(space-lines (chain-assoc-get 'baseline-skip props)
(map (lambda (toc-item)
(let ((label (car toc-item))
(toc-markup (cadr toc-item))
(text (caddr toc-item)))
(interpret-markup
layout
(cons (list (cons 'toc:page
(markup #:with-link label #:page-ref label "XXX" "?"))
(cons 'toc:text (markup #:with-link label text))
(cons 'toc:label label))
props)
(ly:output-def-lookup layout toc-markup))))
(toc-items)))))
tocItem =
#(define-music-function (text) (markup?)
"Add a line to the table of content, using the @code{tocItemMarkup} paper
variable markup"
(add-toc-item! 'tocItemMarkup text))
|