Am So., 31. Aug. 2025 um 08:03 Uhr schrieb Jeff Olson <[email protected]>:
>
> On 8/30/2025 12:18 PM, Magnus Svenson wrote:
> > Tightening up the quotation marks seems to fix it:
> >
> > "A
> > B
> > C"
>
> Thank you, Magnus. Your discovery shows that the page breaking
> algorithm can't deal with an empty line or an embedded newline in the
> string that string-lines works on. That should be documented as a known
> problem.
>
> But it gets worse. The page breaking problem even infects any proper
> subsequent string-lines markuplists, as shown by this example.
>
> \version "2.24.3"
>
> \markuplist { \column-lines \string-lines
> "A
> B
>
> C"
> }
>
> \markuplist { \column-lines \string-lines
> "D
> E
> F"
> }
>
> In this case, without the blank line between B and C, both the A B C and
> D E F markuplists display the expected columns at the top of a single page.
>
> But including that blank line (or equivalently, a \n after the B) breaks
> up not only the A B C markuplist but also the innocent D E F
> markuplist. The output starts with A B at the top of the page, but
> then page breaking begins putting each stanza line on a new page, so
> even D E and F are now on separate pages for a total of 6 pages.
>
> It appears that page breaking goes berserk globally when a single
> string-lines delivers a bad list of markups from a string.
>
> Are there page-breaking experts here who could explain what's going on?
>
> Jeff
>
>
>
Actually, this is not a problem of string-lines or column-lines.
`markuplist` itself fails:
\markuplist { "A" "" "C" }
with:
programming error: insane spring min_distance requested, ignoring it
and with bad output.
This is a bug, imho.
For now one could replace the empty-stencil for the empty string with
point-stencil. Alternatively delete the empty-stencil.
Below a fix for string-lines implementing both.
#(define-markup-list-command (string-lines-rev layout props str)(string?)
#:properties ((split-char #\newline)
(keep-empty #t))
;; If `keep-empty` is #t every empty stencil is replaced by `point-stencil`.
;; If `keep-empty` is #f every empty stencil is removed.
(let* ((split-strgs (string-split str split-char))
(trimmed-strg-ls (map string-trim-both split-strgs))
(stils (interpret-markup-list layout props trimmed-strg-ls))
(stils-rev
(if keep-empty
(map
(lambda (stil)
(if (ly:stencil-empty? stil) point-stencil stil))
stils)
(remove ly:stencil-empty? stils))))
stils-rev))
\markuplist
\box
\column-lines
\string-lines-rev
"
A
B
"
\markuplist
\box
\column-lines
\override-lines #'(keep-empty . #f)
\string-lines-rev
"
A
B
"
The \box-command is there to make all better visible. Although it
affects spacing, delete it.
HTH,
Harm