Refactor author-format function
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
			
		||||
#(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)))
 | 
			
		||||
    (if author
 | 
			
		||||
      ((ly:output-def-lookup layout 'authorFormat)
 | 
			
		||||
      (author-format-function
 | 
			
		||||
        noDetails
 | 
			
		||||
        (assoc-ref author "name")
 | 
			
		||||
        (assoc-ref author "trail_name")
 | 
			
		||||
@@ -29,14 +29,17 @@
 | 
			
		||||
        (assoc-ref song key)
 | 
			
		||||
        (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)
 | 
			
		||||
    (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)
 | 
			
		||||
    (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)
 | 
			
		||||
    (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)
 | 
			
		||||
    (string-append
 | 
			
		||||
@@ -50,8 +53,7 @@
 | 
			
		||||
 | 
			
		||||
  (define (format-authors authorIds)
 | 
			
		||||
    (map (lambda (authorId)
 | 
			
		||||
      (format-author
 | 
			
		||||
        layout
 | 
			
		||||
      (default-author-format
 | 
			
		||||
        authorId
 | 
			
		||||
        (if (member authorId referencedAuthors)
 | 
			
		||||
          #t
 | 
			
		||||
 
 | 
			
		||||
@@ -209,7 +209,7 @@
 | 
			
		||||
      #(make-on-the-fly-markup
 | 
			
		||||
        (lambda (layout props m)
 | 
			
		||||
          (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))
 | 
			
		||||
    \vspace #.4
 | 
			
		||||
  }
 | 
			
		||||
@@ -317,7 +317,7 @@ headerToTOC = #(define-music-function (parser location header label) (ly:book? s
 | 
			
		||||
            (ly:string-substitute "\"" "\\\"" field))
 | 
			
		||||
          "\"")))
 | 
			
		||||
  (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 crlf-regex (ly:make-regex "\r\n"))
 | 
			
		||||
  (define para-sep-regex (ly:make-regex "\n[ \t\n]*\n[ \t\n]*"))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user