chapter toc
This commit is contained in:
@@ -132,6 +132,37 @@
|
||||
author-index-hash)
|
||||
(lambda (a b) (string-ci<? (car a) (car b))))))))
|
||||
|
||||
% code for chapter index
|
||||
% Anders als bei Kategorien/Autoren ergibt sich die Kapitelzugehoerigkeit nicht
|
||||
% aus dem Song-Header, sondern aus dem \songsChapter, das dem Song vorangeht
|
||||
% (in book_include.ily als Header-Feld chapterref an jeden Song gehaengt).
|
||||
% Die Kapitel behalten hier ihre Auftritts-Reihenfolge (nicht alphabetisch),
|
||||
% ebenso die Songs innerhalb eines Kapitels ihre Song-Reihenfolge.
|
||||
#(define*-public (add-chapter-index-item! chapter markup-symbol textoptions #:optional label) #f)
|
||||
#(define-public (chapter-index-items) #f)
|
||||
|
||||
#(let ((chapter-index-hash (make-hash-table))
|
||||
(chapter-order '()))
|
||||
(set! add-chapter-index-item!
|
||||
(lambda* (chapter markup-symbol textoptions #:optional (label (gensym "index")))
|
||||
(let* ((chaptersym (string->symbol chapter))
|
||||
(existing (hashq-ref chapter-index-hash chaptersym #f))
|
||||
(chapterlist (or existing
|
||||
(begin
|
||||
(set! chapter-order (cons chaptersym chapter-order))
|
||||
(list (list label 'indexChapterMarkup `(((combine-with-next . #t) (rawtext . ,chapter))))))))
|
||||
)
|
||||
(hashq-set! chapter-index-hash chaptersym
|
||||
(cons (list label markup-symbol textoptions) chapterlist)))
|
||||
(make-music 'EventChord
|
||||
'page-marker #t
|
||||
'page-label label
|
||||
'elements (list (make-music 'LabelEvent
|
||||
'page-label label)))))
|
||||
(set! chapter-index-items (lambda ()
|
||||
(append-map (lambda (chaptersym) (reverse (hashq-ref chapter-index-hash chaptersym (list))))
|
||||
(reverse chapter-order)))))
|
||||
|
||||
|
||||
#(define-markup-command (with-link-symbol-ref layout props symbol arg)
|
||||
(symbol? markup?)
|
||||
@@ -215,6 +246,11 @@
|
||||
(make-null-markup))
|
||||
\vspace #.4
|
||||
}
|
||||
indexChapterMarkup = \markup \override #'(baseline-skip . 1.5) \left-column {
|
||||
\vspace #1
|
||||
\sans \bold \fontsize #3 \fromproperty #'index:text
|
||||
\vspace #.4
|
||||
}
|
||||
}
|
||||
|
||||
#(define (prepare-item-markup items layout)
|
||||
@@ -247,7 +283,8 @@
|
||||
(let ((items (case index-type
|
||||
((alphabetical) index-items)
|
||||
((categories) category-index-items)
|
||||
((authors) author-index-items)))
|
||||
((authors) author-index-items)
|
||||
((chapters) chapter-index-items)))
|
||||
(title (interpret-markup layout props title-markup)))
|
||||
(cons title
|
||||
(interpret-markup-list layout props
|
||||
@@ -294,7 +331,7 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
|
||||
))
|
||||
(let*
|
||||
(
|
||||
(extractedheadervars (extract-and-check-vars-from-header header '(title starttext alttitle categorytitle categories authors songnumber)))
|
||||
(extractedheadervars (extract-and-check-vars-from-header header '(title starttext alttitle categorytitle categories authors songnumber chapterref)))
|
||||
(title (assq-ref extractedheadervars 'title))
|
||||
(starttext (assq-ref extractedheadervars 'starttext))
|
||||
(alttitle (assq-ref extractedheadervars 'alttitle))
|
||||
@@ -302,12 +339,14 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
|
||||
(categories (assq-ref extractedheadervars 'categories))
|
||||
(authors (assq-ref extractedheadervars 'authors))
|
||||
(songnumber (assq-ref extractedheadervars 'songnumber))
|
||||
(chapterref (assq-ref extractedheadervars 'chapterref))
|
||||
(textoptions (lambda (text alternative) `(((rawtext . ,text) (alternative . ,alternative) (songnumber . ,songnumber)))))
|
||||
(add-to-toc! (lambda (toctitle alternative)
|
||||
(add-index-item! 'indexItemMarkup (textoptions toctitle alternative) toctitle label)))
|
||||
)
|
||||
(if categories (add-category-index-item! (string-tokenize categories) 'indexItemMarkup (textoptions (if categorytitle categorytitle title) #f) label))
|
||||
(if authors (add-author-index-item! (all-author-ids authors) 'indexItemMarkup (textoptions (if categorytitle categorytitle title) #f) label))
|
||||
(if chapterref (add-chapter-index-item! chapterref 'indexItemMarkup (textoptions (if categorytitle categorytitle title) #f) label))
|
||||
(if starttext (add-to-toc! starttext #t))
|
||||
(if alttitle
|
||||
(if (list? alttitle)
|
||||
|
||||
Reference in New Issue
Block a user