Thanks Urs and Elaine for your appreciation.
Note that the same algo I wrote with (relatively) short code can be applied for many other properties as well (for example: extra-offset) which are painful to control through the trial and error method...
I'll be on #irc (channel #lilypond) in the next days, so I can talk easily there with any (welcome) collaborator. My nickname is 'paolopr'.
Before integrating the script into Frescobaldi, I would like to conclude the standalone part.
First of all, I need to add with Lilypond a <script> tag to the svg file just before the ending </svg> tag in the following way:
1)
....
<script xlink:href="">
</svg>
OR in the following way:
2)
....
<script>
<![CDATA[
..._javascript_ code...
]]>
</script>
</svg>
With method 2) I have a 100% Lilypond solution, and the produced svg is ready do be used for modifying slurs, without having to integrate the script manually
I searched in the API, but could not find any function for doing that.
To Eliane: note that you don't have to make a HTML document for that, nor to rename to ".html" the ".svg" file. Just add the <script> tag as I explained (note the xlink:href property) before the end </svg> tag., and open the file with a normal browser.
As soon as we fix points 1) and 2) I can write a how-to, which will be very short.
Best,
P
Great, I was unaware of that capability of SVGs to link to scripts.
Which means that integration is trivial.
Here is an example script to create the svg, post-process it to insert the link, then open it in a browser:
#!/usr/local/bin/bash
# Usage: buildLilyEasySlurs.sh file-base-name
FILE_BASE_NAME="lily-easy-slurs"
if [ "$1" != "" ]; then
FILE_BASE_NAME=$1
fi
SVG="$FILE_BASE_NAME.svg"
LILYPOND="$FILE_BASE_NAME.ly"
if [ -e "$SVG" ]; then
rm $SVG
fi
lilypond -dbackend=svg $LILYPOND
perl -p -i -e 's|</svg>||' $SVG
echo "<script xlink:href="" >> $SVG
echo "</svg>" >> $SVG
open -a "Google Chrome" $SVG
Of course, opening the browser from the command line syntax will vary with your OS and browser; this above works for Chrome on mac.
Thanks,
Elaine Alt
415 . 341 .4954 "Confusion is highly underrated"
address@hidden Producer ~ Composer ~ Instrumentalist ~ Educator
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-