From bbd6d44455884bba716ccdc1fe373a59cff42616 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Sun, 11 Jan 2026 19:32:47 +0100 Subject: [PATCH] Autorensystem flexibilisiert --- .../base/default_songinfo_style.ily | 108 ++++++++++++++- .../base/footer_with_songinfo.ily | 127 +++++------------- 2 files changed, 140 insertions(+), 95 deletions(-) diff --git a/private_includes/base/default_songinfo_style.ily b/private_includes/base/default_songinfo_style.ily index cd7abf4..89ba594 100644 --- a/private_includes/base/default_songinfo_style.ily +++ b/private_includes/base/default_songinfo_style.ily @@ -2,8 +2,8 @@ poetPrefix = "Worte:" composerPrefix = "Weise:" compositionPrefix = "Satz:" - adaptionTextPrefix = "Bearbeitung Text:" - adaptionMusicPrefix = "Bearbeitung Musik:" + adaptionTextPrefix = "Bearbeitung:" + adaptionMusicPrefix = "Bearbeitung:" poetAndComposerEqualPrefix = "Worte und Weise:" voicePrefix = "Stimme:" versePrefix = "Strophe:" @@ -12,6 +12,7 @@ pronunciationPrefix = "Aussprache:" interludePrefix = "Zwischenspiel:" bridgePrefix = "Bridge:" + author-joiner = #(lambda (author-list) (string-join author-list ", ")) authorFormat = #(lambda (noDetails name trail_name birth_year death_year organization) @@ -31,6 +32,105 @@ "" ))) + authorContributionFormat = + #(lambda* (render-contribution-group render-partial-contribution-group #:key + (poetIds '()) + (translatorIds '()) + (versePoetData '()) + (composerIds '()) + (verseComposerData '()) + (voiceComposerData '()) + (compositionIds '()) + (adaptionTextIds '()) + (adaptionMusicIds '()) + (bridgeIds '()) + (interludeIds '()) + (year_text #f) + (year_translation #f) + (year_melody #f) + (year_composition #f) + (year_adaption_text #f) + (year_adaption_music #f) + (poetAndComposerEqualPrefix "") + (poetPrefix "") + (composerPrefix "") + (translationPrefix "") + (pronunciationPrefix "") + (compositionPrefix "") + (adaptionTextPrefix "") + (adaptionMusicPrefix "") + (bridgePrefix "") + (interludePrefix "")) + (if (and + (equal? poetIds composerIds) + (null? translatorIds) + (null? versePoetData) + (null? verseComposerData) + (null? voiceComposerData) + (null? compositionIds) + (null? adaptionTextIds) + (null? adaptionMusicIds) + (null? bridgeIds) + (null? interludeIds)) + (list + (join-present (list + (render-contribution-group poetAndComposerEqualPrefix poetIds) + (if (equal? year_text year_melody) year_text (join-present (list year_text year_melody) "/")) + ) ", ") + #f) + (list + (if (and (null? poetIds) (null? versePoetData) (null? translatorIds)) #f + (string-append + poetPrefix + " " + (join-present (list + (join-present (list + (render-contribution-group "" poetIds) + year_text + ) ", ") + (render-partial-contribution-group 'versePrefix versePoetData) + (join-present (list + (render-contribution-group adaptionTextPrefix adaptionTextIds) + year_adaption_text + ) ", ") + (join-present (list + (render-contribution-group translationAuthorPrefix translatorIds) + year_translation + ) ", ") + ) "; ") + )) + (if (and + (null? composerIds) + (null? compositionIds) + (null? adaptionMusicIds) + (null? verseComposerData) + (null? voiceComposerData) + (null? bridgeIds) + (null? interludeIds)) #f + (string-append + composerPrefix + " " + (join-present (list + (join-present (list + (render-contribution-group "" composerIds) + year_melody + ) ", ") + (render-partial-contribution-group 'versePrefix verseComposerData) + (render-partial-contribution-group 'voicePrefix voiceComposerData) + (join-present (list + (render-contribution-group compositionPrefix compositionIds) + year_composition + ) ", ") + (join-present (list + (render-contribution-group adaptionMusicPrefix adaptionMusicIds) + year_adaption_music + ) ", ") + (render-contribution-group bridgePrefix bridgeIds) + (render-contribution-group interludePrefix interludeIds) + ) "; ") + ))))) + + songinfoMarkup = #(make-on-the-fly-markup (lambda (layout props m) @@ -45,13 +145,15 @@ (year_melody (chain-assoc-get 'songinfo:year_melody props #f)) (poet-with-year (if (and poet-maybe-with-composer year_text) (string-append poet-maybe-with-composer ", " year_text) poet-maybe-with-composer)) (composer-with-year (if (and composer year_melody) (string-append composer ", " year_melody) composer)) + (concat-markupped-strings (lambda (text) + (ly:regex-replace (ly:make-regex "(\\S+)(\\\\\\w+(?:\\s+\\[^\\{\\s]*|\\s*\\{[^\\}]*\\}))(\\S*)") text "\\concat {" 1 "\\line {" 2 "}" 3 "}"))) (string-with-paragraphs->markuplist (lambda (prefix text) (if text (apply append (map (lambda (paragraph) (make-wordwrap-internal-markup-list #t - #{ \markuplist { $(ly:parser-include-string paragraph) } #})) + #{ \markuplist { $(ly:parser-include-string (concat-markupped-strings paragraph)) } #})) (ly:regex-split (ly:make-regex "\r?\n[ \t\r\n]*\n[ \t\r\n]*") (string-append prefix text)))) '()))) (poet-and-composer-markup-list diff --git a/private_includes/base/footer_with_songinfo.ily b/private_includes/base/footer_with_songinfo.ily index 5514ef0..787d6f7 100644 --- a/private_includes/base/footer_with_songinfo.ily +++ b/private_includes/base/footer_with_songinfo.ily @@ -30,6 +30,9 @@ (lambda (a b) (< (cadr a) (cadr b)))) (list))) +#(define (join-present items joiner) + (string-join (filter (lambda (item) (and (string? item) (not (string-null? (string-trim-both item))))) items) joiner)) + #(define-markup-command (print-songinfo layout props) () (define (songinfo-from songId key) (let ((song (if (defined? 'SONG_DATA) (assoc-ref SONG_DATA songId) #f))) @@ -74,11 +77,7 @@ (define (render-contribution-group contributionPrefix authorIds) (if (null? authorIds) "" - (string-append contributionPrefix " " (string-join (format-authors authorIds) ", "))) - ) - - (define (join-present items joiner) - (string-join (filter (lambda (item) (and (string? item) (not (string-null? (string-trim-both item))))) items) joiner) + (string-append contributionPrefix " " ((ly:output-def-lookup layout 'author-joiner) (format-authors authorIds)))) ) (define (render-partial-contribution-group prefixLookup authorData) @@ -94,93 +93,37 @@ (define (poet-and-composer-from-authors authors) (if authors - (let ( - (poetIds (find-author-ids-by 'text authors)) - (translatorIds (find-author-ids-by 'translation authors)) - (versePoetData (find-author-id-with-part-numbers 'verse authors)) - (composerIds (find-author-ids-by 'melody authors)) - (verseComposerData (find-author-id-with-part-numbers 'meloverse authors)) - (voiceComposerData (find-author-id-with-part-numbers 'voice authors)) - (compositionIds (find-author-ids-by 'composition authors)) - (adaptionTextIds (find-author-ids-by 'adaption_text authors)) - (adaptionMusicIds (find-author-ids-by 'adaption_music authors)) - (bridgeIds (find-author-ids-by 'bridge authors)) - (interludeIds (find-author-ids-by 'interlude authors)) - (year_text (chain-assoc-get 'header:year_text props #f)) - (year_translation (chain-assoc-get 'header:year_translation props #f)) - (year_melody (chain-assoc-get 'header:year_melody props #f)) - (year_composition (chain-assoc-get 'header:year_composition props #f)) - (year_adaption_text (chain-assoc-get 'header:year_adaption_text props #f)) - (year_adaption_music (chain-assoc-get 'header:year_adaption_music props #f)) - ) - (if (and - (equal? poetIds composerIds) - (null? translatorIds) - (null? versePoetData) - (null? verseComposerData) - (null? voiceComposerData) - (null? compositionIds) - (null? adaptionTextIds) - (null? adaptionMusicIds) - (null? bridgeIds) - (null? interludeIds)) - (list - (join-present (list - (render-contribution-group (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) poetIds) - (if (equal? year_text year_melody) year_text (join-present (list year_text year_melody) "/")) - ) ", ") - #f) - (list - (if (and (null? poetIds) (null? versePoetData) (null? translatorIds)) #f - (string-append - (ly:output-def-lookup layout 'poetPrefix) - " " - (join-present (list - (join-present (list - (render-contribution-group "" poetIds) - year_text - ) ", ") - (render-partial-contribution-group 'versePrefix versePoetData) - (join-present (list - (render-contribution-group (ly:output-def-lookup layout 'translationAuthorPrefix) translatorIds) - year_translation - ) ", ") - (join-present (list - (render-contribution-group (ly:output-def-lookup layout 'adaptionTextPrefix) adaptionTextIds) - year_adaption_text - ) ", ") - ) "; ") - )) - (if (and - (null? composerIds) - (null? compositionIds) - (null? adaptionMusicIds) - (null? verseComposerData) - (null? voiceComposerData) - (null? bridgeIds) - (null? interludeIds)) #f - (string-append - (ly:output-def-lookup layout 'composerPrefix) - " " - (join-present (list - (join-present (list - (render-contribution-group "" composerIds) - year_melody - ) ", ") - (render-partial-contribution-group 'versePrefix verseComposerData) - (render-partial-contribution-group 'voicePrefix voiceComposerData) - (join-present (list - (render-contribution-group (ly:output-def-lookup layout 'compositionPrefix) compositionIds) - year_composition - ) ", ") - (join-present (list - (render-contribution-group (ly:output-def-lookup layout 'adaptionMusicPrefix) adaptionMusicIds) - year_adaption_music - ) ", ") - (render-contribution-group (ly:output-def-lookup layout 'bridgePrefix) bridgeIds) - (render-contribution-group (ly:output-def-lookup layout 'interludePrefix) interludeIds) - ) "; ") - ))))) + ((ly:output-def-lookup layout 'authorContributionFormat) + render-contribution-group + render-partial-contribution-group + #:poetIds (find-author-ids-by 'text authors) + #:translatorIds (find-author-ids-by 'translation authors) + #:versePoetData (find-author-id-with-part-numbers 'verse authors) + #:composerIds (find-author-ids-by 'melody authors) + #:verseComposerData (find-author-id-with-part-numbers 'meloverse authors) + #:voiceComposerData (find-author-id-with-part-numbers 'voice authors) + #:compositionIds (find-author-ids-by 'composition authors) + #:adaptionTextIds (find-author-ids-by 'adaption_text authors) + #:adaptionMusicIds (find-author-ids-by 'adaption_music authors) + #:bridgeIds (find-author-ids-by 'bridge authors) + #:interludeIds (find-author-ids-by 'interlude authors) + #:year_text (chain-assoc-get 'header:year_text props #f) + #:year_translation (chain-assoc-get 'header:year_translation props #f) + #:year_melody (chain-assoc-get 'header:year_melody props #f) + #:year_composition (chain-assoc-get 'header:year_composition props #f) + #:year_adaption_text (chain-assoc-get 'header:year_adaption_text props #f) + #:year_adaption_music (chain-assoc-get 'header:year_adaption_music props #f) + #:poetAndComposerEqualPrefix (ly:output-def-lookup layout 'poetAndComposerEqualPrefix) + #:poetPrefix (ly:output-def-lookup layout 'poetPrefix) + #:composerPrefix (ly:output-def-lookup layout 'composerPrefix) + #:translationPrefix (ly:output-def-lookup layout 'translationPrefix) + #:pronunciationPrefix (ly:output-def-lookup layout 'pronunciationPrefix) + #:compositionPrefix (ly:output-def-lookup layout 'compositionPrefix) + #:adaptionTextPrefix (ly:output-def-lookup layout 'adaptionTextPrefix) + #:adaptionMusicPrefix (ly:output-def-lookup layout 'adaptionMusicPrefix) + #:bridgePrefix (ly:output-def-lookup layout 'bridgePrefix) + #:interludePrefix (ly:output-def-lookup layout 'interludePrefix) + ) (list #f #f) ) )