Le vendredi 07 avril 2023 à 13:11 -0400, Ken Ledeen a écrit :
> Hi All,  
> Thanks to Jean Abou Samra I can now create \markup that goes to a place in a 
> youtube video.
> 
> These are of the form:
> 
> fis4^\markup \with-url#"[https://youtu.be.](https://youtu.be.)..?t=SEC" {ref} 
> where "SEC" is replaced with the number of seconds in from the start.
> 
> I would like to create a function to simplify things so instead of having the 
> entire URL repeated everywhere, would have something that looks like
> 
> fis4^\mymk "215". 
> 
> So far, I remain entirely confused about creating a new markup command.  I 
> won't bother describing my many failed attempts.  I am clearly missing some 
> basic concepts. I have no problem creating scheme functions to do various 
> manipulations, but extending the markup function has eluded me.
> 
> Any guidance would be most appreciated!    


Try

```
\version "2.24.1"

mymk =
#(define-scheme-function (sec) (index?)
   #{
     \markup \with-url
       #(format #f "https://youtu.be/blablabla?t=~a"; sec)
       #(number->string sec)
   #})

{
  fis4^\mymk 215
}
```

Note that this is a regular syntax function returning a markup (defined with 
define-scheme-function) rather than a markup command, but you can also define a 
markup command if you wish:

```
\version "2.24.1"

#(define-markup-command (mymk layout props sec) (index?)
   (interpret-markup
    layout props
    #{
      \markup \with-url
        #(format #f "https://youtu.be/blablabla?t=~a"; sec)
        #(number->string sec)
    #}))

{
  fis4^\markup \mymk #215
}
```


Note that you have to enter `\markup` mode to use markup commands.

Markup mode is quite different from the normal mode (for example, `\markup b1` 
just writes “b1”, while in normal mode, also called “notes mode”, “b1” is a B 
whole note; this is also the reason why you have to put a `#` before `215` when 
calling the markup command). Syntax functions and markup command have different 
use cases, but in this particular instance it happens that both can be used 
without a lot of difference.

Best,

Jean

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

Reply via email to