- ;; This relies on the markup list returned by a markup list command
- ;; to be modifiable
- (reverse!
- (fold
- (lambda (m prev)
- (if (markup-command-list? m)
- (reverse! (apply (car m) layout props (cdr m)) prev)
- (cons (interpret-markup layout props m) prev)))
- '()
- markup-list)))
+ (fold-right
+ (lambda (m prev)
+ (if (markup-command-list? m)
+ (append (apply (car m) layout props (cdr m)) prev)
+ (cons (interpret-markup layout props m) prev)))
+ '()
+ markup-list))