erlaube Umbrüche in Versen nach angegebenen Texten

This commit is contained in:
tux 2023-10-29 22:54:10 +01:00
parent f0010c7746
commit 9de2869750

View File

@ -103,9 +103,24 @@
(interpret-markup layout props
(make-size-box-to-box-markup #f #t (make-stanza-raw-markup arg) (make-stanza-raw-markup "x"))))
#(define (handle-custom-newlines custom-verse-breaks text)
(if (null? custom-verse-breaks)
text
(let make-custom-linebreaks
((break-words custom-verse-breaks)
(newtext (ly:regex-replace (ly:make-regex "\n") text " ")))
(if (null? break-words)
newtext
(make-custom-linebreaks
(cdr break-words)
(ly:regex-replace
(ly:make-regex (string-append "(" (ly:regex-replace (ly:make-regex "(.)") (car break-words) "(?:\\(?" 1 "| *,[^,)]+\\)" 1 ")") "(?: *,[^,)]+\\))?)(.*)$"))
newtext
1 "\n" 2))))))
% Kompletten Vers mit Akkorden
#(define-markup-command (chordverse layout props stanza verse) (markup? string?)
#:properties ((intraverse-vspace 0))
#:properties ((intraverse-vspace 0)(custom-verse-breaks '()))
"Vers mit Akkorden"
(let* ((fromto (chain-assoc-get 'transposition props #f))
(transp (if fromto
@ -116,18 +131,18 @@
(markup #:override `(baseline-skip . ,(+ intraverse-vspace songTextLineHeigth)) #:anchor-x-between #:stanza stanza
(make-wrap-newline-markup
(ly:regex-replace (ly:make-regex "\\(( *)([^,()]*)( *),([^)]*)\\)")
(ly:regex-replace (ly:make-regex "(([^ \n]*\\([^()]*,[^()]+\\)[^ \n(]*)+)") verse " \\concat { " 1 " } ")
(ly:regex-replace (ly:make-regex "(([^ \n]*\\([^()]*,[^()]+\\)[^ \n(]*)+)") (handle-custom-newlines custom-verse-breaks verse) " \\concat { " 1 " } ")
"\\textup \\line { \"" 1 "\" " 2 " \"" 3 "\" } \\score { \\transposable " transp " \\chords { s4 " 4 " } \\layout { \\verselayout } }")
)
))))
% Kompletter Vers aus dem Akkorde entfernt werden
#(define-markup-command (nochordverse layout props stanza verse) (markup? string?)
#:properties ((intraverse-vspace 0))
#:properties ((intraverse-vspace 0)(custom-verse-breaks '()))
"Vers ohne Akkorde"
(interpret-markup layout props
(markup #:override `(baseline-skip . ,(+ intraverse-vspace 3.0)) #:anchor-x-between #:stanza stanza
#:wrap-newline (ly:regex-replace (ly:make-regex "\\(([^,]*),([^)]*)\\)") verse 1)
#:wrap-newline (ly:regex-replace (ly:make-regex "\\(([^,]*),([^)]*)\\)") (handle-custom-newlines custom-verse-breaks verse) 1)
)
)
)