Folks,
I would like to write a markup function that can either accept a markup or a markup list as an argument. The code below works fine, reporting ``` bar: (#<procedure flat-markup (layout props)>) baz: 1 bar: ((#<procedure sharp-markup (layout props)>) (#<procedure sharp-markup (layout props)>)) baz: 1 ``` as expected. (The `baz` argument is inserted in the demo code to avoid interference with LilyPond's special handling of a markup function's last argument, which can be either a markup or a markup list, for example, `\bold foo` or `\bold { foo bar }`.) However, if I activate the commented-out code, LilyPond aborts with ``` error: syntax error, unexpected MARKUP_FUNCTION \markup \fooEither \flat #1 ``` It seems to me that this is a limitation built into LilyPond's parser, and it is not possible to do what I would like to achieve, probably due to the above-mentioned special handling of the last argument. Has someone more insight? Werner ====================================================================== \version "2.24.0" #(define-markup-command (foo layout props bar baz) (markup? number?) (ly:message "bar: ~a" bar) (ly:message "baz: ~a" baz) (interpret-markup layout props bar)) \markup \foo \flat #1 #(define-markup-command (fooList layout props bar baz) (markup-list? number?) (ly:message "bar: ~a" bar) (ly:message "baz: ~a" baz) (interpret-markup layout props (car bar))) \markup \fooList { \sharp \sharp } #1 % #(define (markup-or-markup-list? x) % (or (markup? x) (markup-list? x))) % % #(define-markup-command (fooEither layout props bar baz) % (markup-or-markup-list? number?) % (ly:message "bar: ~a" bar) % (ly:message "baz: ~a" baz) % (interpret-markup layout props (if (markup-list? bar) (car bar) bar))) % % \markup \fooEither \flat #1 % \markup \fooEither { \sharp \sharp } #1