<div dir="ltr">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).<div>
<br></div><div style>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).</div>
<div style><br></div><div style>My @vocab function uses traverse-element to build the term list:</div><div style><br></div><div style><div><font face="courier new, monospace">(define (vocab body)</font></div><div><font face="courier new, monospace"> (traverse-element</font></div>
<div><font face="courier new, monospace"> (lambda (get set)</font></div><div><font face="courier new, monospace"> (set 'vocab-used (cons body (get 'vocab-used '())))</font></div><div><font face="courier new, monospace"> (elem #:style bs-vocab-style body))))</font></div>
<div><br></div><div style>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:</div>
<div style><br></div><div style><div><font face="courier new, monospace">(define (glossary)</font></div><div><font face="courier new, monospace"> (traverse-block</font></div><div><font face="courier new, monospace"> (lambda (get set)</font></div>
<div><font face="courier new, monospace"> (traverse-block</font></div><div><font face="courier new, monospace"> (lambda (get set)</font></div><div><font face="courier new, monospace"> (define terms (get 'vocab-used '()))</font></div>
<div><span style="font-family:'courier new',monospace"> (para terms))))))</span><br></div><div><br></div><div style>(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).</div>
<div style><br></div><div style>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:</div>
<div style><br></div><div style><font face="courier new, monospace">(define (lesson . body)</font></div><div style><font face="courier new, monospace"> (traverse-block</font></div><div style><font face="courier new, monospace"> (lambda (get set)</font></div>
<div style><font face="courier new, monospace"> (glossary)</font></div><div style><font face="courier new, monospace"> (para body))))</font></div><div style><br></div><div style>What do I need to change to populate the glossary?</div>
<div style><br></div><div style>thanks!</div><div style>Kathi</div></div></div></div>