![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sun, 20 Jan 2013, Henning Hraban Ramm wrote:
Am 2013-01-20 um 17:57 schrieb Aditya Mahajan:
Now, I'd like my lilypond sections/buffers to have different names than just numbers; I'd prefer some unique IDs or even manually set names to be able to re-order them without the need of re-compiling. I.e. if I change the order of songs in my songbook, all LilyPond snippets must get recalculated, even if they didn’t change.
Does
\startlilypond[name=one] .... \stoplilypond
what you are looking for? (see the docs for how this behaves behind the scenes)
Oh, so simple? Great, that’s exactly what I meant. Since I would normally set [name=\currentcomponent], can I make that default?
Unfortunately no. The name key is reset at every `\startexternalfilter`; otherwise it will be difficult to mix `name=....` with normal usage.
There are some more enhancements that I’d like to implement, e.g. checking the resulting files if there are several pages or using single notelines to let ConTeXt do the page breaking (like lilypond-book does with LaTeX). I guess that would be as simple as replacing my \readPDFfile with some Lua code - can you give me a hint how to do that?
See grph-inc.*. I'll post an example later on how to handle single page and multipage pdfs differently.
Thanks, handling of multipage PDFs might help, but I’d try a different approach: LilyPond can generate EPS/PDF for single note systems and writes the number of them into a simple text file. I’d parse that with Lua and place all those small PDFs. I just need a clue how I must define t-filter’s "readcommand" as a Lua function.
Something like this: \def\ParseLilypondFile#1% % #1 is the name of the output file {\ctxlua{thirddata.parselilypondfile("#1")} \startluacode thirddata = thirddata or {} function thirddata.parselilypondfile(name) --- parse "name" file as you wish and --- generate approapriate context(...) commands --- to write back to ConTeXt end \stopluacode \defineexternalfilter[lilypond] [ ..... readcommand=\ParseLilypondFile, .... ] Aditya