2017-08-29 14:27 GMT+02:00 Thomas Morley <[email protected]>:
> 2017-08-27 22:34 GMT+02:00 David Kastrup <[email protected]>:
>
>> You are right that fold-matches is probably not worth the trouble in
>> brain contortion here: processing the result from list-matches should be
>> good enough without overflowing memory.
>
>
>
> I now come up with (only markup again):
>
> #(define-markup-command (dyn-test-II layout props strg)(string?)
> #:properties ((reg-exp "\\{[^{}]*\\}")
> (separators (char-set #\{ #\}))
> (dynamcs (char-set #\f #\m #\p #\r #\s #\z)))
> (interpret-markup layout props
> (make-line-markup
> (map
> (lambda (s)
> (let* ((matches (list-matches reg-exp s)))
> (if (null? matches)
> s
> (let* ((poss-dyns (map match:substring matches)))
> (append-map
> (lambda (p-d)
> (let* ((cand (string-trim-both p-d separators)))
> (if (string-every char-set:dynamics cand)
> (make-concat-markup
> (list
> (make-concat-markup
> (map match:prefix matches))
> (make-dynamic-markup cand)
> (make-concat-markup
> (map match:suffix matches))))
> p-d)))
> poss-dyns)))))
> (string-split strg #\space)))))
>
> \markup \dyn-test-II #"poco {f}, but {p} sub. {ma} non troppo"
>
> Though, if I split the string anyway (splitting at #\space should do
> no harm, imho), it's probably cheaper to go for string-match instead
> of list-matches.
>
> Not sure...
>
> Cheers,
> Harm
Aaargh, some typos, plese use:
#(use-modules (ice-9 regex))
#(define-markup-command (dyn-test-II layout props strg)(string?)
#:properties ((reg-exp "\\{[^{}]*\\}")
(separators (char-set #\{ #\}))
(dynamics (char-set #\f #\m #\p #\r #\s #\z)))
(interpret-markup layout props
(make-line-markup
(map
(lambda (s)
(let* ((matches (list-matches reg-exp s)))
(if (null? matches)
s
(let* ((poss-dyns (map match:substring matches)))
(append-map
(lambda (p-d)
(let* ((cand (string-trim-both p-d separators)))
(if (string-every dynamics cand)
(make-concat-markup
(list
(make-concat-markup
(map match:prefix matches))
(make-dynamic-markup cand)
(make-concat-markup
(map match:suffix matches))))
p-d)))
poss-dyns)))))
(string-split strg #\space)))))
\markup \dyn-test-II #"poco {f}, but {p} sub. {ma} non troppo"
Cheers,
Harm
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user