Hello all,

you can also create a small scheme function to split a string into a list of 
strings, which you can then pass to \wordwrap-lines or whatever.

Note though that this is not equivalent: \wordwrap-strings will handle the 
concept of paragraphs, which in this setting would simpy be discarded. So if 
you want to print multiple strings with \wordwrap-strings you might want to 
first concatenate the strings as different paragraphs.

See the appended file for details.

Cheers,
Valentin



Am Freitag, 14. April 2023, 00:33:06 CEST schrieb Jean Abou Samra:
> Le jeudi 13 avril 2023 à 16:20 -0600, Benjamin Bruce a écrit :
> > I think using \pad-around will work best in my case. The reason I'm using
> > \wordwrap-string is because I am passing a string via a variable. Thanks
> > for your help, and I'm glad this has resulted in an improvement to the
> > documentation :)
> You can also put the argument to `\wordwrap-lines` in a variable. For
> example:
> 
> ```
> stringArg = "aaa bbb ccccccc ddd"
> \markup \override #'(line-width . 10) \wordwrap-string \stringArg
> 
> markupListArg = \markuplist { aaa bbb cccccc ddd }
> \markuplist \override #'(line-width . 10) \wordwrap-lines \markupListArg
> ```

#(use-modules (ice-9 regex))

splitString =
#(define-scheme-function (s) (string?)
   ((@@ (lily) regexp-split) s "\\s+"))

addParagraph =
#(define-scheme-function (ml) (list?)
   (string-join ml "\n\n"))

\markup \vspace #1
\markup \large "A"

stringArg = "aaa bbb ccccccc ddd"
\markup \override #'(line-width . 10) \column {
  \wordwrap-string \stringArg
  \wordwrap-string \stringArg
}

\markup \vspace #1
\markup \large "B"

markupListArg = \markuplist { aaa bbb cccccc ddd }
\markuplist {
  \override #'(line-width . 10) \wordwrap-lines \markupListArg
  \override #'(line-width . 10) \wordwrap-lines \markupListArg
}

\markup \vspace #1
\markup \large "C"

markupListArg = \markuplist { aaa bbb cccccc ddd }
\markup \column {
  \override #'(line-width . 10) \wordwrap-lines \markupListArg
  \override #'(line-width . 10) \wordwrap-lines \markupListArg
}

\markup \vspace #1
\markup \large "D"

\markuplist {
  \override #'(line-width . 10) \wordwrap-lines \splitString \stringArg
  \override #'(line-width . 10) \wordwrap-lines \splitString \stringArg
}

\markup \vspace #1
\markup \large "E"

\markup \column \override #'(line-width . 10) {
  \override #'(line-width . 10) \wordwrap-lines \splitString \stringArg
  \override #'(line-width . 10) \wordwrap-lines \splitString \stringArg
}

\markup \vspace #1
\markup \large "F"

\markup \override #'(line-width . 10) \wordwrap-string \addParagraph \markuplist { \stringArg \stringArg }

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

Reply via email to