I suggest to update code and picture of the snippet  "Adding Links to objects".

Changes:

* Update link URLs to a more current version of the documentation

* Fix link for accidental

#(define (add-link url-strg)
  (lambda (grob)
    (let* ((stil (ly:grob-property grob 'stencil)))
      (if (ly:stencil? stil)
        (begin
          (let* (
             (x-ext (ly:stencil-extent stil X))
             (y-ext (ly:stencil-extent stil Y))
             (url-expr (list 'url-link url-strg `(quote ,x-ext) `(quote ,y-ext)))
             (new-stil (ly:stencil-add
                 (ly:make-stencil url-expr x-ext y-ext) stil)))
          (ly:grob-set-property! grob 'stencil new-stil)))
        #f))))

%%%% test

urlI =
"http://lilypond.org/doc/v2.20/Documentation/notation/writing-pitches";

urlII =
"http://lilypond.org/doc/v2.20/Documentation/notation/rhythms";

urlIII =
"http://lilypond.org/doc/v2.20/Documentation/notation/note-heads";

urlIV =
"http://lilypond.org/doc/v2.20/Documentation/notation/beams";

urlV =
"http://lilypond.org/doc/v2.20/Documentation/notation/note-head-styles";

urlVI =
"http://lilypond.org/doc/v2.20/Documentation/notation/writing-pitches";

\relative c' {
  \key cis \minor

  \once \override Staff.Clef.color = #green
  \once \override Staff.Clef.after-line-breaking =
    #(add-link urlI)

  \once \override Staff.TimeSignature.color = #green
  \once \override Staff.TimeSignature.after-line-breaking =
    #(add-link urlII)

  \once \override NoteHead.color = #green
  \once \override NoteHead.after-line-breaking =
    #(add-link urlIII)

  cis'1
  \once \override Beam.color = #green
  \once \override Beam.after-line-breaking =
    #(add-link urlIV)
  cis8 dis e fis gis2
  <gis,
   \tweak Accidental.color #green
   \tweak Accidental.after-line-breaking #(add-link urlVI)
   \tweak color #green
   \tweak after-line-breaking #(add-link urlV)
   \tweak style #'harmonic
   bis
   dis
   fis
  >1
  <cis, cis' e>
}

Now with colored accidental and link on the accidental:

Before:

--
Johannes Feulner
Tel: +49 721 33500158  johannes.feul...@scorio.com

scorio GmbH  Bonhoefferweg 3   76327 Pfinztal
Geschäftsführer Johannes Feulner
Sitz der Gesellschaft Karlsruhe
Amtsgericht Mannheim HRB 713486

_______________________________________________
bug-lilypond mailing list
bug-lilypond@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to