lilypond-devel
[Top][All Lists]
Advanced

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

Re: output-attributes in 2.20.0


From: Richard Shann
Subject: Re: output-attributes in 2.20.0
Date: Sun, 02 Aug 2020 17:39:36 +0100

On Sun, 2020-08-02 at 14:32 +0200, David Kastrup wrote:
> Richard Shann <richard@rshann.plus.com> writes:
> 
> > I'm trying to get the annotated SVG output that enables playback
> > with a
> > scrolling LilyPond score working in 2.20.
> > 
> > In the changes http://lilypond.org/doc/v2.20/Documentation/changes/
> > inde
> > x.html I read:
> > 
> > "A new output-attributes grob property is now used for svg output
> > instead of the id grob property. It allows multiple attributes to
> > be
> > defined as an association list. For example, #'((id . 123) (class .
> > foo) (data-whatever . “bar”)) will produce the following group tag
> > in
> > an SVG file: <g id=“123” class=“foo” data-whatever=“bar”> … </g>"
> > 
> > but I see that the convert-ly changes this:
> > 
> > \override NoteHead.id = #note-id
> > 
> > to this:
> > 
> > \override Score.NoteHead.output-attributes.id = #note-id
> > 
> > which is not an alist.
> 
> Why would output-attributes not be an alist?
> 
> > Moreover, in the code I'm using 
> > (http://git.savannah.gnu.org/gitweb/?p=denemo.git;a=blob;f=actions/
> > lilypond/live-
> > score.ily;h=5a9d22fe5efe89e9f63a087177d206eab63109f0;hb=HEAD) 
> > note-id is a procedure returning a string, which seems to be
> > acceptable to the 2.18 SVG generator while the 2.20 version gives
> > an
> > error message:
> > 
> > Unsupported SCM value for format: #<procedure note-id (grob)>
> 
> Callbacks are not supported for subproperties.
> 
> > and the output in the SVG is an empty string:
> > 
> > <g id="">
> > 
> > while with 2.18
> > 
> > the output was (for example)
> > 
> > <g id="Note-7-2">
> > 
> > where "Note-7-2" is the return value for the particular grob - the
> > line
> > 7 column 2 location information.
> > 
> > What's more, if I write an alist value (following the documentation
> > above)
> 
> You are not following the documentation.  You are presuming that the
> documentation is wrong, substitute what you consider a correction,
> and
> the result does not work.
> 
> > \override Score.NoteHead.output-attributes.id = #'((id . "foo"))
> > 
> > I get the error:
> > 
> > Unsupported SCM value for format: ((id . foo))
> 
> Because you set output-attributes to ((id . ((id . "foo")))) rather
> than
> to ((id . "foo")).
> 
> > So what should output-attributes.id be set to - can it take a
> > procedure
> > as id could in 2.18?
> 
> output-attributes can take a procedure (which must return a complete
> alist).  id doesn't.

Thank you. By "output-attributes can take a procedure" I guessed you
might mean "can be set equal to a procedure", although I haven't found
where that is documented (*), so I set

\override Score.NoteHead.output-attributes = #note-id

and re-defined the procedure note-id to be

#(define (note-id grob) 
   (let* ((origin (ly:input-file-line-char-column
                   (ly:event-property (ly:grob-property grob 'cause) 'origin)))
           (value  (string-concatenate 
                                (list 
                                  "Note-" 
                                  (ly:format "~a-~a"
                                        (cadr origin)
                                        (caddr origin))))))  
                   
  (cons (cons 'id  value) '())))

and all is well. There is some more elegant syntax for the alist, but
I'll stop while I'm ahead.

Richard Shann

(*) The documentation says
"SVG output can optionally contain metadata for graphical objects
(grobs) like note heads, rests, etc. This metadata can be standard SVG
attributes like id and class, or non-standard custom attributes.
Specify the attributes and their values by overriding a grob’s output-
attributes property with a Scheme association list (alist). The values
can be numbers, strings, or symbols. For example: "

I suggest

"SVG output can optionally contain metadata for graphical objects
(grobs) like note heads, rests, etc. This metadata can be standard SVG
attributes like id and class, or non-standard custom attributes.
Specify the attributes and their values by overriding a grob’s output-
attributes property with a Scheme association list (alist) or a
procedure returning an alist. The values can be numbers, strings, or
symbols. For example:" 






reply via email to

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