lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: markup to string function?


From: Jan-Peter Voigt
Subject: Re: markup to string function?
Date: Thu, 27 Jan 2011 14:58:18 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7

Hello Reinhold,

I'm a bit in a hurry, so this is not finished but an idea:

I thought of my fine conversation about extracting lyrics with Jakob Lund a few days ago. I understand that markups are also lists and the strings are somewhere in this tree-list-structure.

This doesn't get you the desired result, but perhaps you can finish this.
--snip--
\version "2.12.3"

#(define (markup->string m)
        (let ((res ""))
             (map (lambda (x)
                          (display "> ")(display x)(display "\n")
(if (list? x)(set! res (string-append res (markup->string x))))
                          (if (string? x)(set! res (string-append res x)))
                          (display "! ")(display res)(display "\n")
                          res)
                  m) res))

ttt = \markup {
  \normal-text hallo \bold { welt }
}

#(display (markup->string ttt))

\header {
  title = \ttt
}
\relative c' {
  c
}
--snip--
With this bunch of displays, you see what is in the markup. There is a string concatenated, but it will leave all blanks so this "hallo welt" will get "hallowelt".
Just inserting blanks doesn't care about concats ...

Best regards,
Jan-Peter


On 26.01.2011 16:32, Reinhold Kainhofer wrote:
I'm currently implementing PDF metadata (DOCINFO extracted from the \header
fields) as well as PDF hyperlinks to given labels in the score. For both I
would need to extract a pure-string representation of a given markup. E.g.,
the title header field might be a markup:

\header{
   title = \markup { \italic "Title of " \bold \concat {"the" " " "piece"} }
}

Now, given that markup, I need a function that extracts only the text (in this
case "Title of the piece"). Is there anything like that already available in
lilypond?

If not, do you have any idea about the easiest way to implement this? It's
safe to ignore all graphical markup functions, but there are so many text
markup functions that I can not easily handle each of them manually...

Any ideas?

Thanks,
Reinhold




reply via email to

[Prev in Thread] Current Thread [Next in Thread]