[racket] conditional includes in a Scribble file

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

Actually, that's exactly what I did.

Well, I actually did

  (define (itemlist* fst . rst)
    (apply itemlist (filter item? (cons fst rst))))

which I'm now embarrassed about, but at least I was on the right track.

Any thoughts on the second problem--how to unwrap a (list el1 el2 el3
...) so that Scribble interprets it as el1 el2 el3 ... ?

On Wed, Jun 29, 2011 at 9:36 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> 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.