[racket] conditional includes in a Scribble file

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Wed Jun 29 09:27:52 EDT 2011

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)

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.

  @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

@section{Curriculum Standards}

These are the state standards for this lesson:

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?


Posted on the users mailing list.