[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replacing a certain character sequence in lyrics
From: |
Thomas Morley |
Subject: |
Re: Replacing a certain character sequence in lyrics |
Date: |
Fri, 20 Apr 2018 22:52:41 +0200 |
2018-04-20 17:53 GMT+02:00 Simon Albrecht <address@hidden>:
> Hello everybody,
>
> I have a favour to ask from any LilyPond-Guile crack on the list, because I
> couldn’t quite figure it out myself: (technical requirement here, rationale
> in PS.)
>
> For a scholarly edition project, I’d like to have a global boolean variable
> and a toplevel music function that goes through all lyric syllables and
> replaces (for example) two apostrophes "’’" with either a single apostrophe
> "’" or nothing, depending on the value of that global switch variable. How
> could such a music function be done?
>
> Best, Simon
>
> PS. The reason behind this is: Haydn’s „Jahreszeiten“ use a lot of
> apostrophes in the original German text; some of them seem weird to the
> modern eye and don’t help understanding, while others are perfectly normal.
> I would like to be able to easily switch between modernising spelling in
> that regard or just leaving it as is, and I figured the way to go would be
> coding the ‘weird’ ones as double apostrophes and having a
> toplevel-music-function deal with them.
Probably:
\version "2.19.81"
#(define my-replacement-alist
'(
("foo" . "Is")
("bar" . "this")
("buzz" . "what")
("ding" . "you")
("dong" . "want?")
("’’" . "’")
))
tst =
#(define-music-function (mus)(ly:music?)
(music-map
(lambda (m)
(if (music-is-of-type? m 'lyric-event)
(let ((txt (ly:music-property m 'text)))
(if (string? txt)
(begin
(ly:music-set-property! m 'text
(make-replace-markup my-replacement-alist txt))
m)
m))
m))
mus))
\tst
<<
\new Voice = "v" { c'4 d' e' f' g'1 }
\new Lyrics \lyricsto "v" { ’’foo bar buzz ding dong’’ }
>>
Cheers,
Harm