[racket] conditional includes in a Scribble file

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jun 29 09:36:25 EDT 2011

You could use `itemlist*' instead of `itemlist', defining `itemlist*'
like this:

 (define (itemlist* . args)
   (apply itemlist (filter item? args)))

At Wed, 29 Jun 2011 09:27:52 -0400, "Todd O'Bryan" wrote:
> Hey all,
> I'm trying to use Scribble to create multiple forms of the same
> document--for example, teacher and student editions of the same text.
> Both documents share a lot of content, but also have differences.
> I created a parameter and function:
> (define edition (make-parameter "default"))
> (define (only-edition v text)
>   (if (equal? (edition) v)
>       text
>       ""))
> so I could write
> This content appears in both editions, @only-edition["student"]{while
> this part is only in the student edition}@only-edition["teacher"]{but
> only teachers see this}.
> Unfortunately, this solution doesn't work for lists.
> @itemlist[
>   @item{appears in both}
>   @only-edition["student"]{@item{appears in student}}
>   @only-edition["teacher"]{@item{appears in teacher}}
> ]
> I get a contract violation saying that "" isn't valid where an item is
> expected and the same thing happens with #void. I've solved this by
> writing my own @itemlist* that filters out non-items before using
> @itemlist. Is there a better way?
> Also, if I do
> @only-edition["teacher]{
> @section{Curriculum Standards}
> These are the state standards for this lesson:
> @itemlist[@item{Blah}]}
> I get an error because the stuff in the {...} is interpreted as
> multiple arguments. I can fix the definition by putting a dot in front
> of the text argument so that it can be a list, but then I need some
> way to "unwrap" the list in the Scribble document. Is this possible?
> Thanks!
> Todd

Posted on the users mailing list.