Support multiple alternative titles in headerToTOC function
This update allows the alttitle header field to accept a list of alternative titles instead of a single value. Each title in the list is processed and added to the table of contents as an alternative title, enhancing flexibility and usability.
This commit is contained in:
parent
f0f4b0c180
commit
a61becaf5e
@ -286,11 +286,10 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
|
|||||||
))
|
))
|
||||||
(let*
|
(let*
|
||||||
(
|
(
|
||||||
(extractedheadervars (extract-and-check-vars-from-header header '(title starttext alttitle altalttitle categorytitle categories authors)))
|
(extractedheadervars (extract-and-check-vars-from-header header '(title starttext alttitle categorytitle categories authors)))
|
||||||
(title (assq-ref extractedheadervars 'title))
|
(title (assq-ref extractedheadervars 'title))
|
||||||
(starttext (assq-ref extractedheadervars 'starttext))
|
(starttext (assq-ref extractedheadervars 'starttext))
|
||||||
(alttitle (assq-ref extractedheadervars 'alttitle))
|
(alttitle (assq-ref extractedheadervars 'alttitle))
|
||||||
(altalttitle (assq-ref extractedheadervars 'altalttitle))
|
|
||||||
(categorytitle (assq-ref extractedheadervars 'categorytitle))
|
(categorytitle (assq-ref extractedheadervars 'categorytitle))
|
||||||
(categories (assq-ref extractedheadervars 'categories))
|
(categories (assq-ref extractedheadervars 'categories))
|
||||||
(authors (assq-ref extractedheadervars 'authors))
|
(authors (assq-ref extractedheadervars 'authors))
|
||||||
@ -300,8 +299,12 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
|
|||||||
(if categories (add-category-index-item! (string-tokenize categories) 'indexItemMarkup (cons (list (cons 'rawtext (if categorytitle categorytitle title))) '()) label))
|
(if categories (add-category-index-item! (string-tokenize categories) 'indexItemMarkup (cons (list (cons 'rawtext (if categorytitle categorytitle title))) '()) label))
|
||||||
(if authors (add-author-index-item! (all-author-ids authors) 'indexItemMarkup (cons (list (cons 'rawtext (if categorytitle categorytitle title))) '()) label))
|
(if authors (add-author-index-item! (all-author-ids authors) 'indexItemMarkup (cons (list (cons 'rawtext (if categorytitle categorytitle title))) '()) label))
|
||||||
(if starttext (add-to-toc! starttext (cons (list (cons 'rawtext starttext) (cons 'alternative #t)) '())))
|
(if starttext (add-to-toc! starttext (cons (list (cons 'rawtext starttext) (cons 'alternative #t)) '())))
|
||||||
(if alttitle (add-to-toc! alttitle (cons (list (cons 'rawtext alttitle) (cons 'alternative #t)) '())))
|
(if alttitle
|
||||||
(if altalttitle (add-to-toc! altalttitle (cons (list (cons 'rawtext altalttitle) (cons 'alternative #t)) '())))
|
(if (list? alttitle)
|
||||||
|
(for-each (lambda (alt)
|
||||||
|
(add-to-toc! alt (cons (list (cons 'rawtext alt) (cons 'alternative #t)) '())))
|
||||||
|
alttitle)
|
||||||
|
(add-to-toc! alttitle (cons (list (cons 'rawtext alttitle) (cons 'alternative #t)) '()))))
|
||||||
(if title (add-to-toc! title (cons (list (cons 'rawtext title)) '())) #{ #})
|
(if title (add-to-toc! title (cons (list (cons 'rawtext title)) '())) #{ #})
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user