add json parser for structured data like AUTHOR_DATA and SONG_DATA
This commit is contained in:
@ -1,13 +1,19 @@
|
||||
#(define-markup-command (print-songinfo layout props) ()
|
||||
(define (songinfo-from songId key)
|
||||
(let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f)))
|
||||
(if song
|
||||
(assoc-ref song key)
|
||||
(ly:warning (ly:format "song with id ~a not found" songId)))))
|
||||
|
||||
(define (format-author authorId)
|
||||
(let ((author (if (defined? 'AUTHORS) (assq-ref AUTHORS authorId) #f)))
|
||||
(let ((author (if (defined? 'AUTHOR_DATA) (assoc-ref AUTHOR_DATA authorId) #f)))
|
||||
(if author
|
||||
(markup
|
||||
#:override (cons 'author:name (assq-ref author 'name))
|
||||
#:override (cons 'author:trail_name (assq-ref author 'trail_name))
|
||||
#:override (cons 'author:birth_year (assq-ref author 'birth_year))
|
||||
#:override (cons 'author:death_year (assq-ref author 'death_year))
|
||||
#:override (cons 'author:organization (assq-ref author 'organization))
|
||||
#:override (cons 'author:name (assoc-ref author "name"))
|
||||
#:override (cons 'author:trail_name (assoc-ref author "trail_name"))
|
||||
#:override (cons 'author:birth_year (assoc-ref author "birth_year"))
|
||||
#:override (cons 'author:death_year (assoc-ref author "death_year"))
|
||||
#:override (cons 'author:organization (assoc-ref author "organization"))
|
||||
(ly:output-def-lookup layout 'authorMarkup))
|
||||
(ly:warning (ly:format "author with id ~a not found" authorId)))))
|
||||
|
||||
@ -22,9 +28,10 @@
|
||||
|
||||
(interpret-markup layout props
|
||||
(if (chain-assoc-get 'page:is-bookpart-last-page props #f)
|
||||
(let* ((poetId (chain-assoc-get 'header:poetId props #f))
|
||||
(composerId (chain-assoc-get 'header:composerId props #f))
|
||||
(poet-and-composer-same (eq? poetId composerId)))
|
||||
(let* ((songId (chain-assoc-get 'header:songId props #f))
|
||||
(poetId (chain-assoc-get 'header:poetId props (if songId (songinfo-from songId "poet") #f)))
|
||||
(composerId (chain-assoc-get 'header:composerId props (if songId (songinfo-from songId "composer") #f)))
|
||||
(poet-and-composer-same (equal? poetId composerId)))
|
||||
(let (
|
||||
(blockwidth (* (chain-assoc-get 'header:songinfo-size-factor props 0.9) (ly:output-def-lookup layout 'line-width)))
|
||||
(infotext (chain-assoc-get 'header:songinfo props #f))
|
||||
|
Reference in New Issue
Block a user