[racket-dev] conditional scribble documents
Just to follow up on this: in my conditional scribble language, I've
needed a splicing style for itemlists, because certain items may or
may not show depending on context.
Just in case this happens to be helpful for anyone else, here's the
helper I'm using:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; itemlist/splicing is like itemlist, but also cooperates with the
;; splice form to absorb arguments.
(define (itemlist/splicing #:style [style #f] . items)
(define spliced-items
(reverse
(let loop ([items items]
[acc '()])
(foldl (lambda (i acc)
(cond
[(splice? i)
(loop (splice-run i) acc)]
[else
(cons i acc)]))
acc
items))))
(apply itemlist spliced-items #:style style))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
For example, @itemlist/splicing[@item{x}, @splice[@item{y} @item{z}]]
gives me a three-item list.