[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-devel
Subject: Re: extracting markup texts for braille
From: Maurits Lamers via Discussions on LilyPond development <lilypond-devel () gnu ! org>
Date: 2024-04-01 21:28:51
Message-ID: db782574-db83-4bfc-a9e6-1fa0b968b549 () weidestraat ! nl
[Download RAW message or body]
Hi Aaron,
That is a great suggestion. Thanks a lot!
I have been playing around with it and noticed that in order to keep the
order of the generated braille identical to the Lilypond code, I would
need to also override the top-level-score-handler, and possibly others
to keep track of the order of the top level elements. Is that something
that could possibly cause issues in the future?
One additional question: I would like to keep the newlines, as that will
keep the braille close to what is printed in the PDF. The solution I
came up with is
%%%%
#(set! (markup-function-as-string-method line-markup)
(lambda (layout props markup)
(string-append (string-trim-both (markup->string markup)
char-set:whitespace) "\n")
)
)
%%%%
I would like to know whether such a solution is acceptable, or whether
there is a better way to achieve the same.
What I did notice: with the example you gave earlier, I keep getting a
space at the beginning of the second line. I tried to use the
string-trim-both function to get rid of it, but for unclear reasons that
space doesn't get removed.
cheers
Maurits
Op 01-04-2024 om 16:15 schreef Aaron Hill:
> On 2024-04-01 3:47 am, Maurits Lamers via Discussions on LilyPond
> development wrote:
>> Hey all,
>>
>> I also asked this question on the lilypond-user mailing list, but I
>> gather it is a rather complex question for that list. As you might be
>> aware, I have been working on a braille extension for Lilypond which
>> (based on the music info extraction example) renders Lilypond scores
>> into music braille.
>>
>> While the listener system works great for extracting musical
>> information, it doesn't provide any methods to extract text inserted
>> outside of the music context.
>>
>> In my specific case, I am trying to convert a songbook, which has the
>> format of printing one verse of a song with the music notation, and
>> with the remainder of the song text as \markup text blocks below the
>> music.
>>
>> Is there any way that I could extract this text in order to include
>> it with the generated braille? The preferred solution should be as
>> transparent as the listener system is for the musical information.
>>
>> Thanks in advance!
>
>
> Easiest option would probably be to tie into the `toplevel-text-handler`:
>
> %%%%
> \version "2.25.13"
>
> #(let ((original-proc toplevel-text-handler))
> (set! toplevel-text-handler (lambda (markup)
> (format #t "~a\n" (markup->string markup))
> (original-proc markup))))
>
> \markup \column {
> \line { \bold { Lorem ipsum } dolor sit amet, }
> \line { \italic consectetur adipiscing elit. }
> }
> %%%%
>
>
> -- Aaron Hill
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic