lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: \uppercase function


From: David Nalesnik
Subject: Re: \uppercase function
Date: Thu, 9 Apr 2015 11:48:24 -0500

Kieren,

On Thu, Apr 9, 2015 at 10:37 AM, Kieren MacMillan <address@hidden> wrote:
Hi David,

> You are only using part of the code which I find here: http://www.autoindustry536.bllog.opensubscriber.com/message/address@hidden/12807136.html

Yes! That was it. Thanks for the link.

> Note that the following will work with your simple example, though \uppercase has to be directly before the markup:
> #(define-markup-command (uppercase layout props markup-argument)
>    (markup?)
>    (interpret-markup layout props
>      (string-upcase (markup->string markup-argument))))

My issue is the same as in that 2009 post:

    \uppercase \fromproperty #’header:title

fails. Any thoughts on how to fix that?

Nicholas's \simple function requires a string, and mine requires that we be able to get at the string within a markup argument.   Ordinarily, getting the string wouldn't be a problem.   Not so with the markup returned by the fromproperty command: the function markup->string won't work here.

Nevertheless, we can easily get the title string by referring to the variable myTitle:
 
\version "2.19"

#(define-markup-command (uppercase paper props markup-argument)   
   (markup?) 
   "Make the markup uppercase. 
  Syntax: \\uppercase \"string\"" 
   (interpret-markup paper (prepend-alist-chain 'case 'up props)   
     markup-argument)) 

#(define-markup-command (simple paper props str) (string?) 
   "Depending on the `case' property, may change the case 
of the string before interpreting it." 
   (let ((text-case (chain-assoc-get 'case props 'normal))) 
     (interpret-markup paper props 
       (case text-case 
         ((up) (string-upcase str)) 
         ((down) (string-downcase str)) 
         ;; TODO: small caps, capitalized text, etc 
         (else str))))) 


\header {
  myTitle = "myTitle"
  title = \markup {
    from \uppercase \simple #myTitle
  }
}
\markup {
  \null
}

%%%
Though you could just as easily write the following:

\header {
  myTitle = #"myOtherTitle"
  title = \markup {
    from \italic #(string-upcase myTitle)
  }
}
\markup {
  \null
}

%%%

HTHm
David

reply via email to

[Prev in Thread] Current Thread [Next in Thread]