http://code.google.com/p/lilypond/issues/detail?id=1482

Hello lists,

using \fromproperty, \smallCaps (=\caps) and markup->string leads into some pitfalls: 1. if you want to use custom (self written) markup-commands, the default "markup->string" function will drop the content of them. 2. if you want to use caps, that function expects a string to capsify, so that if you try "\caps \italic text" the text will only be italic but not capsified. 3. if you want to use \fromproperty #'sym within caps or markup->string, the result will be empty.

I post these three in one mail, because the problems are related.

Here are my tries overcoming these obstacles:
1. a redesigned markup->string function, that is command-independent and looks for fromproperty-markups 2. a recaps markup-command relying on a recursive function capsifying all found strings and fromproperty-markup-results

This design may lead to other problems: E.g. if you have an arbitrary markup-command, wich takes a markup to scale another one, that gauge-markup will be put into the string

Right now this is not a patch for devel, because I am running stable and use this for my current projects.

Cheers,
Jan-Peter

--snip--
\version "2.14.2"

% taken from markup.scm
#(define (markup-function? x)
        (and (markup-command-signature x)
             (not (object-property x 'markup-list-command))))

% a markup-command-independent markup->string function
#(define-public (markup->string mup . mprops)
  (let ((conc (if (> (length mprops) 0) (car mprops) #f))
        (layout (if (> (length mprops) 1) (cadr mprops) #f))
        (props (if (> (length mprops) 2) (caddr mprops) '()))
        (mup? (lambda (m)(or (string? m)(list? m)(markup? m))))
        (result ""))
       (cond ((string? mup) (set! result mup))
             ((null? mup) (set! result ""))

             ((and (pair? mup) (equal? (car mup) concat-markup))
              (set! result (markup->string (cdr mup) #t layout props)))

             ((and (pair? mup) (equal? (car mup) fromproperty-markup))
(set! result (markup->string (chain-assoc-get (cadr mup) props "???") conc layout props)))

             ((and (pair? mup)(markup-function? (car mup)))
(for-each (lambda (m)(set! result (string-append result (if (or conc (string=? result "")) "" " ") (markup->string m conc layout props))))
                        (filter mup? (cdr mup))))
             ((list? mup)
(for-each (lambda (m)(set! result (string-append result (if (or conc (string=? result "")) "" " ") (markup->string m conc layout props))))
                        (filter mup? mup)))
             (else (ly:message "~A" mup)))
       result))
% plain text markup
#(define-markup-command (plain-text layout props arg)(markup?)
(interpret-markup layout props (markup (markup->string arg #f layout props))))

% apply caps to all strings found in m
#(define-public (rcaps m . mprops)
  (let ((layout (if (> (length mprops) 0) (car mprops) #f))
        (props (if (> (length mprops) 1) (cadr mprops) '()))
        (mup? (lambda (m)(or (string? m)(list? m)(markup? m))))
        (ret (markup)))
       (set! ret
         (cond
           ((string? m) (markup #:caps m))
           ((null? m) "")
           ((and (pair? m) (equal? (car m) fromproperty-markup))
            (markup #:caps (chain-assoc-get (cadr m) props "???")))
           ((and (pair? m)(markup-function? (car m))) (cons (car m)
(map (lambda (mup)(if (mup? mup) (rcaps mup layout props) mup)) (cdr m))))
           ((list? m)
            (map (lambda (mup)(rcaps mup layout props)) m))
           (else "ERROR, unable to caps markup"))
       )
       ret)
)
% recursive caps markup command
#(define-markup-command (recaps layout props mup)(markup?)
  (interpret-markup layout props (rcaps mup layout props)))

%%%%% example/test

test = \markup {
Hallo \recaps { Welt \fontsize #3 Du große \concat { \italic { Welt 2 3 } \fromproperty #'dummytext } }
}
#(display (markup->string test #f #f '(((dummytext . "bla"))) ))
\markup {
  \override #'(dummytext . "bla") \column {
    \test
    \plain-text \test
  }
}
--snip--



_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to