lilypond-user
[Top][All Lists]
Advanced

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

Re: \with-url relative link?


From: Jean Abou Samra
Subject: Re: \with-url relative link?
Date: Mon, 05 Aug 2024 21:44:21 +0200
User-agent: Evolution 3.52.3 (3.52.3-1.fc40)

Le lundi 05 août 2024 à 11:18 -0700, l t a écrit :
> Hi,
> Wondering if it is possible to have lilypond produce a working relative url
> link on a pdf, where, if I had a file in the same directory as the outputted
> PDF, I could do something like this:
> \markup  { \with-url  #"test.mid" }
> or
> \markup  { \with-url  #"./test.mid" } 
> or
> \markup  { \with-url  #"/test.mid" }
> 
> The first one sort of works while still viewing the output within Frescobaldi
> (although the actual directory it searches was different than what I 
> expected),
> but none work in the final PDF output.


You cannot get a relative link into the PDF output. I just checked
the PDF 1.7 specification and I was surprised to find that the PDF
format supports it (I didn't check whether common PDF readers actually
understand it), but LilyPond has no support for outputting that.

On the other hand, you can do

\markup \with-url "file:///home/you/absolute/path/to/file.mid"

for an absolute path. You can automate adding the absolute path
of the directory that contains the current input file using a simple
variant of the \withRelativeDir command that was added in version 2.25.12:

\version "2.24.4"

fileURL =
#(define-scheme-function (file-name) (string?)
   (let* ((input-file (car (ly:input-file-line-char-column (*location*))))
          (input-dir (dirname input-file)))
     (string-append "file://" input-dir file-name-separator-string file-name)))

\markup \with-url \fileURL "mystery-principle.v" "foo"


This doesn't give a true relative URL, because it will keep pointing to the
original target even if you move the PDF file around, but might be good enough
for your use case.

Best
Jean

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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