lilypond-user
[Top][All Lists]
Advanced

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

Re: A Javascript test code for modifying ties and slurs with mouse


From: Paolo Prete
Subject: Re: A Javascript test code for modifying ties and slurs with mouse
Date: Sun, 15 Dec 2019 01:38:10 +0100

Hello Aaron,

I understand that it is potentially dangerous because this is not API but we are accessing it like API. However, looking at the code, svg-end is referenced only inside its def file (framework-svg.scm), as a dummy append to the output file:

http://git.savannah.gnu.org/gitweb/?p=lilypond.git;a=blob;f=scm/framework-svg.scm;h=2e35c9f98618721236773410751266217195e253;hb=0ea52e08bde09001641931246ee42b1f3b02b7f5

Then we can ask the maintainer of the file to add a 2-lines-of-code function for a proper override, and meanwhile use your solution without any problem/risk. What do you think?

On Sun, Dec 15, 2019 at 12:38 AM Aaron Hill <address@hidden> wrote:
On 2019-12-14 6:16 am, Paolo Prete wrote:
> However, how can I make it work for multiple pages output?

Another approach would be to modify how LilyPond generates SVG output,
so that the script in question is inserted just before the closing
</svg> element:

%%%%
\version "2.19.83"

svg-script = #(define-void-function (body) (string?)
   (let* ((mod (resolve-module '(scm framework-svg)))
          (svg-end (module-ref mod 'svg-end #f)))
     (if (procedure? svg-end)
       (module-define! mod 'svg-end (lambda () (string-join
         (list "<script type=\"text/_javascript_\"><![CDATA["
               body "]]></script>" (svg-end)) "\n"))))))

\svg-script #"// TODO: Insert script here."
%%%%

This is improved in that no \markup is required.  This injection of
content happens at a point after LilyPond has processed each page of
music, so there are no unintended side-effects to the layout.

However, the above kludge modifies an undocumented, underlying
mechanism.  As such, this would be a case of "just because you can does
not necessarily mean you should".

As has been suggested, perhaps the best option would be to post-process
the SVG output from outside LilyPond.


-- Aaron Hill


reply via email to

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