Refactor author-format function
This commit is contained in:
parent
e6725b84d4
commit
a368a3c589
@ -1,8 +1,8 @@
|
|||||||
#(use-modules (ice-9 receive))
|
#(use-modules (ice-9 receive))
|
||||||
#(define (format-author layout authorId noDetails)
|
#(define (format-author author-format-function authorId noDetails)
|
||||||
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
||||||
(if author
|
(if author
|
||||||
((ly:output-def-lookup layout 'authorFormat)
|
(author-format-function
|
||||||
noDetails
|
noDetails
|
||||||
(assoc-ref author "name")
|
(assoc-ref author "name")
|
||||||
(assoc-ref author "trail_name")
|
(assoc-ref author "trail_name")
|
||||||
@ -29,14 +29,17 @@
|
|||||||
(assoc-ref song key)
|
(assoc-ref song key)
|
||||||
(ly:warning (ly:format "song with id ~a not found" songId)))))
|
(ly:warning (ly:format "song with id ~a not found" songId)))))
|
||||||
|
|
||||||
|
(define* (default-author-format authorId #:optional (noDetails #f))
|
||||||
|
(format-author (ly:output-def-lookup layout 'authorFormat) authorId noDetails))
|
||||||
|
|
||||||
(define (format-poet poetId)
|
(define (format-poet poetId)
|
||||||
(string-append (ly:output-def-lookup layout 'poetPrefix) " " (format-author layout poetId #f)))
|
(string-append (ly:output-def-lookup layout 'poetPrefix) " " (default-author-format poetId)))
|
||||||
|
|
||||||
(define (format-composer composerId)
|
(define (format-composer composerId)
|
||||||
(string-append (ly:output-def-lookup layout 'composerPrefix) " " (format-author layout composerId #f)))
|
(string-append (ly:output-def-lookup layout 'composerPrefix) " " (default-author-format composerId)))
|
||||||
|
|
||||||
(define (format-poet-and-composer authorId)
|
(define (format-poet-and-composer authorId)
|
||||||
(string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (format-author layout authorId #f)))
|
(string-append (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) " " (default-author-format authorId)))
|
||||||
|
|
||||||
(define (numbered-contribution-prefix contributionNumbers prefixLookup)
|
(define (numbered-contribution-prefix contributionNumbers prefixLookup)
|
||||||
(string-append
|
(string-append
|
||||||
@ -50,8 +53,7 @@
|
|||||||
|
|
||||||
(define (format-authors authorIds)
|
(define (format-authors authorIds)
|
||||||
(map (lambda (authorId)
|
(map (lambda (authorId)
|
||||||
(format-author
|
(default-author-format
|
||||||
layout
|
|
||||||
authorId
|
authorId
|
||||||
(if (member authorId referencedAuthors)
|
(if (member authorId referencedAuthors)
|
||||||
#t
|
#t
|
||||||
|
@ -209,7 +209,7 @@
|
|||||||
#(make-on-the-fly-markup
|
#(make-on-the-fly-markup
|
||||||
(lambda (layout props m)
|
(lambda (layout props m)
|
||||||
(interpret-markup layout props
|
(interpret-markup layout props
|
||||||
(make-justify-string-markup (format-author layout (chain-assoc-get 'index:text props #f) #f))))
|
(make-justify-string-markup (format-author (ly:output-def-lookup layout 'authorFormat) (chain-assoc-get 'index:text props #f) #f))))
|
||||||
(make-null-markup))
|
(make-null-markup))
|
||||||
\vspace #.4
|
\vspace #.4
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
|
|||||||
(ly:string-substitute "\"" "\\\"" field))
|
(ly:string-substitute "\"" "\\\"" field))
|
||||||
"\"")))
|
"\"")))
|
||||||
(define (format-authors authorIds)
|
(define (format-authors authorIds)
|
||||||
(string-join (map (lambda (authorId) (format-author layout authorId #f)) authorIds) ", "))
|
(string-join (map (lambda (authorId) (format-author (ly:output-def-lookup layout 'authorFormat) authorId #f)) authorIds) ", "))
|
||||||
(define cr-regex (ly:make-regex "\r"))
|
(define cr-regex (ly:make-regex "\r"))
|
||||||
(define crlf-regex (ly:make-regex "\r\n"))
|
(define crlf-regex (ly:make-regex "\r\n"))
|
||||||
(define para-sep-regex (ly:make-regex "\n[ \t\n]*\n[ \t\n]*"))
|
(define para-sep-regex (ly:make-regex "\n[ \t\n]*\n[ \t\n]*"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user