fix categories and authors index

This commit is contained in:
2025-09-19 18:47:26 +02:00
parent 90feb6dfbb
commit a01e95f31d

View File

@@ -56,11 +56,11 @@
#(let ((index-item-list (list))) #(let ((index-item-list (list)))
(set! add-index-item! (set! add-index-item!
(lambda* (markup-symbol text sorttext #:optional (label (gensym "index"))) (lambda* (markup-symbol textoptions sorttext #:optional (label (gensym "index")))
(set! index-item-list (set! index-item-list
;; We insert index items sorted from the beginning on and do ;; We insert index items sorted from the beginning on and do
;; not sort them later - this saves pretty much computing time ;; not sort them later - this saves pretty much computing time
(insert-alphabetical-sorted! (list label markup-symbol text (insert-alphabetical-sorted! (list label markup-symbol textoptions
;; this crazy hack is necessary because lilypond depends on guile 1.8 atm ;; this crazy hack is necessary because lilypond depends on guile 1.8 atm
;; and so the cool unicode conversion functions cannot be used ;; and so the cool unicode conversion functions cannot be used
(ly:string-substitute " " "" (ly:string-substitute " " ""
@@ -92,20 +92,20 @@
(cons (car ilist) (insert-alphabetical-sorted! iitem (cdr ilist)))))) (cons (car ilist) (insert-alphabetical-sorted! iitem (cdr ilist))))))
% code for category index % code for category index
#(define*-public (add-category-index-item! categories markup-symbol text #:optional label) #f) #(define*-public (add-category-index-item! categories markup-symbol textoptions #:optional label) #f)
#(define-public (category-index-items) #f) #(define-public (category-index-items) #f)
#(let ((category-index-hash (make-hash-table))) #(let ((category-index-hash (make-hash-table)))
(set! add-category-index-item! (set! add-category-index-item!
(lambda* (categories markup-symbol text #:optional (label (gensym "index"))) (lambda* (categories markup-symbol textoptions #:optional (label (gensym "index")))
(for-each (lambda (category) (for-each (lambda (category)
(let* ((catsym (string->symbol category)) (let* ((catsym (string->symbol category))
(catlist (hashq-ref category-index-hash catsym (catlist (hashq-ref category-index-hash catsym
(list (list label 'indexCategoryMarkup category))))) (list (list label 'indexCategoryMarkup `(((rawtext . ,category))))))))
(if (assq catsym category-names) (if (assq catsym category-names)
(hashq-set! category-index-hash catsym (hashq-set! category-index-hash catsym
(cons (list label markup-symbol text) catlist)) (cons (list label markup-symbol textoptions) catlist))
(ly:error "song: <~a> category ~a is not defined!" (markup->string text) category)))) (ly:error "song: <~a> category ~a is not defined!" (markup->string (chain-assoc-get 'rawtext textoptions)) category))))
categories) categories)
(make-music 'EventChord (make-music 'EventChord
'page-marker #t 'page-marker #t
@@ -121,13 +121,13 @@
#(let ((author-index-hash (make-hash-table))) #(let ((author-index-hash (make-hash-table)))
(set! add-author-index-item! (set! add-author-index-item!
(lambda* (authorIDs markup-symbol text #:optional (label (gensym "index"))) (lambda* (authorIDs markup-symbol textoptions #:optional (label (gensym "index")))
(for-each (lambda (authorID) (for-each (lambda (authorID)
(let* ((authorsym (string->symbol authorID)) (let* ((authorsym (string->symbol authorID))
(authorlist (hashq-ref author-index-hash authorsym (authorlist (hashq-ref author-index-hash authorsym
(list (list label 'indexAuthorMarkup authorID))))) (list (list label 'indexAuthorMarkup `(((rawtext . ,authorID))))))))
(hashq-set! author-index-hash authorsym (hashq-set! author-index-hash authorsym
(cons (list label markup-symbol text) authorlist)) (cons (list label markup-symbol textoptions) authorlist))
)) ))
authorIDs) authorIDs)
(make-music 'EventChord (make-music 'EventChord