Markup construction in Scheme - GNU LilyPond
Description: GNU LilyPond

Next: How markups work internally, Up: Markup programmer interface

#### 11.2.1 Markup construction in Scheme

The `markup` macro builds markup expressions in Scheme while providing a LilyPond-like syntax. For example,

    (markup #:column (#:line (#:bold #:italic "hello" #:raise 0.4 "world")
                      #:bigger #:line ("foo" "bar" "baz")))

is equivalent to:

    \markup \column { \line { \bold \italic "hello" \raise #0.4 "world" }
                      \bigger \line { foo bar baz } }

This example exposes the main translation rules between regular LilyPond markup syntax and Scheme markup syntax, which are summed up is this table:

> LilyPond | Scheme
> `\markup markup1 }` | `(markup markup1)`
> `\markup { markup1 markup2 ... }` | `(markup markup1 markup2 ... )`
> `\command` | `#:command`
> `\variable` | `variable`
> `\center-align { ... }` | `#:center-align ( ... )`
> `string` | `"string"`
> `#scheme-arg` | `scheme-arg`

Besides, the whole scheme language is accessible inside the `markup` macro: thus, one may use function calls inside `markup` in order to manipulate character strings for instance. This proves useful when defining new markup commands (see Markup command definition).

##### Bugs

One can not feed the `#:line` (resp `#:center`, `#:column`) command with a variable or the result of a function call. Example:

    (markup #:line (fun-that-returns-markups))

is invalid. One should use the `make-line-markup` (resp., `make-center-markup` or `make-column-markup`) function instead,

    (markup (make-line-markup (fun-that-returns-markups)))

This page is for LilyPond-2.8.8 (stable-branch).

Other languages: English.
Using automatic language selection.