On 2024-03-19 1:50 pm, Johannes Roeßler wrote:
thx again Aaron,
I tried it with
%%%
\line {\fromproperty #'header:composer " - " \as-string
\fromproperty #'header:title }
%%%
- then the title (in the footnote) was empty.
But you gave so many valuable insights, that I'll use it to make it in
a better way - very instructive,
thank you very much!
Aha! \as-string (as I defined it) is not going to work with
\fromproperty. The problem is that \fromproperty needs to be
interpretted to get its contents. \as-string is processing too soon, so
it will not work. Also, once markup is interpretted, it becomes a
stencil. And that is basically useless for our purposes.
One solution would be to customize \fromproperty itself:
%%%%
\version "2.22.0"
%% Based on code from define-markup-commands.scm:
#(define-markup-command
(frompropertystring layout props symbol) (symbol?)
(let ((m (chain-assoc-get symbol props)))
(if (markup? m)
(interpret-markup
layout
(cons (list (cons symbol `(,property-recursive-markup
,symbol))) props)
(markup->string m))
empty-stencil)))
\header {
asdf = \markup \with-color #red \bold \line { "Hello," "World!" }
title = \markup \fromproperty #'header:asdf
subtitle = \markup \frompropertystring #'header:asdf
}
\score { { b'1 } }
%%%%
Again, this is probably not the best approach. For instance, a nested
\fromproperty within a field is going to fail much the same way. So,
then we are looking at redefining \fromproperty itself to be able to
call markup->string as needed. Doable, but it really starts to feel
like a clunky hack.
I think the best approach is to avoid putting markup around data that
needs to be accessed in different ways. Keep the fields as simple text,
so there is no need for an \as-string or \frompropertystring command.
-- Aaron Hill