[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
implicitly running a lilypond script through a python script before comp
From: |
Joseph Chrestien |
Subject: |
implicitly running a lilypond script through a python script before compilation |
Date: |
Sun, 1 May 2016 20:48:18 +0000 |
Hi all,
I know this is going to sound strange: is it possible (or even imaginable) to
run a Python code snippet from "within" Lilypond code at compile time?
This is my situation: I am currently using a custom extension of the "Column
markup" Frescobaldi snippet, to print verses below a staff. So far, so good
(just discovered these snippets - very nice indeed!), but I am compiling quite
a large library I am afraid I might want to change some details in the snippet
as time goes by. Currently, that would mean highlight-clicking every single ly
file.
I am interested if anybody has a clue in how I can tweak Lily configs (if
possible) so that my input script (A) would be automatically submitted to (say)
a Python script called `verse-markup` located in the right folder and would be
*implicitly* transformed into script (B). [See below]
I had a vague idea I could change the Frescobaldi execute path so that the
script (invisibly) first goes to Python before being submitted to Lilypond in
the "script B" form - does that seem any good? Has anyone already done it, who
could give me a tip?
Thanks!
Joseph
PS. or maybe a magic "\include pysnippets.ly" command ? that would be absolute
dream :)
------------------------------------------
Script A: what I want in my script window
------------------------------------------
\score { \relative c'' { c2 g4 e c1 } }
%!%!%!snippet:verse-markup%!%!%!
This is my first verse
La la la la la
This is my second verse
Lo lo lo lo lo
%!%!%!end-snippet%!%!%!
------------------------------------------
Script B: what I want Lilypond to read at compile time and change to PDF
------------------------------------------
\score { \relative c'' { c2 g4 e c1 } }
\markup{
\line { This is my first verse }
\line { La la la la la }
\line { This is my second verse }
\line { Lo lo lo lo lo }
% I know this markup doesn't work but it made it simple ;-)
}
------------------------------------------
Snippet: something like this should be saved in a nearby folder
------------------------------------------
text = '\n'.join(r'\line { %s }' % l for l in text.splitlines())
if state[-1] != 'markup':
text = '\\markup {\n%s\n}' % text
- implicitly running a lilypond script through a python script before compilation,
Joseph Chrestien <=