[racket-dev] Need help staging traverse-blocks to generate a document glossary

From: Kathi Fisler (kfisler at gmail.com)
Date: Tue Jun 18 05:32:07 EDT 2013

I am trying to use traverse-block to build a glossary of terms used in a
document.  I have a scribble function @vocab to tag items to include in the
glossary.  I want to display the glossary early in the document (before the
terms are used).

I'm having trouble delaying glossary generation until the list of terms has
been populated (the list is populated if I generate the glossary at the end
of the document, but the terms list is empty if I generate near the top of
the document).

My @vocab function uses traverse-element to build the term list:

(define (vocab body)
  (traverse-element
   (lambda (get set)
     (set 'vocab-used (cons body (get 'vocab-used '())))
     (elem #:style bs-vocab-style body))))

My glossary function (in my scribble extension, not exposed to the document
author) fetches and displays the terms.  I call it within a larger
user-exposed function that defines the document contents:

(define (glossary)
  (traverse-block
    (lambda (get set)
      (traverse-block
        (lambda (get set)
          (define terms (get 'vocab-used '()))
          (para terms))))))

(I tried nesting the inner lambda directly in the outer one, but that
yields an error from traverse-block-block that no block is computed).

The user-facing scribble function that calls glossary is also wrapped in a
traverse-block (for reasons unrelated to the glossary).  Rough structure is
as follows, where @vocab calls are in body:

(define (lesson . body)
  (traverse-block
    (lambda (get set)
       (glossary)
       (para body))))

What do I need to change to populate the glossary?

thanks!
Kathi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20130618/3984038f/attachment.html>

Posted on the dev mailing list.