[Top][All Lists]

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

Re: \concat markup command

From: Werner LEMBERG
Subject: Re: \concat markup command
Date: Fri, 24 Nov 2006 12:07:43 +0100 (CET)

> > Good question.  Perhaps `\concat { f i }' should be really
> > identical to `fi', contrary to \line with word-space set to
> > zero...
> It's your call.  You could try to inspect the arguments, and if they
> are strings or simple markups, concatenate the strings.

OK, here it is.  Please comment -- especially my Scheme code since I'm
not really acquainted with it.



#(define-markup-command (concat layout props args) (markup-list?)
  "Concatenate @var{args} in a horizontal line, without spaces inbetween.
Strings and simple markups are concatenated on the input level, allowing
ligatures.  For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is
equivalent to @code{\"fi\"}."

  (define (concat-string-args arg-list)
    (do ((arg-list arg-list (cdr arg-list))
         (result-list '() result-list)
         (result #f (car result-list)))
        ((null? arg-list) (reverse result-list))
      (let ((arg (car arg-list)))
        (if (and (pair? arg) (eqv? (car arg) simple-markup))
          (set! arg (cadr arg)))
        (if (and (string? result) (string? arg))
            (set! result-list (cons (string-append result arg)
                                    (cdr result-list)))
          (set! result-list (cons arg result-list))))))

  (interpret-markup layout
                    (prepend-alist-chain 'word-space 0 props)
                    (make-line-markup (concat-string-args args))))

\relative {
  c-\markup { \concat { "f" "i" } \concat { "f" \null "i" } }
  c-\markup { \concat { "j" } }
  c-\markup { \concat { \tiny { "k" } } }
  c-\markup { \concat { \simple #"f" \simple #"i" } }

reply via email to

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