@@ -31,8 +31,9 @@ A document is processed in four passes:
3131 document order so that information from one part of a document
3232 can be communicated to other parts of the same document. The
3333 information is transmitted through a symbol-keyed mapping that
34- can be inspected and extended by @racket[traverse-element]s and
35- @racket[traverse-block]s in the document. The @tech{traverse
34+ can be inspected and extended by @racket[traverse-element]s,
35+ @racket[traverse-block]s, and @racket[traverse-part]s in the
36+ document. The @tech{traverse
3637 pass} iterates the traversal until it obtains a fixed point
3738 (i.e., the mapping from one iteration is unchanged from the
3839 previous iteration).}
@@ -52,11 +53,12 @@ A document is processed in four passes:
5253None of the passes mutate the document representation. Instead, the
5354 @tech{traverse pass}, @tech{collect pass}, and @tech{resolve pass}
5455 accumulate information in a side hash table, @racket[collect-info]
55- table, and @racket[resolve-info] table. The @tech{collect pass} and
56- @tech{resolve pass} are effectively specialized version of
57- @tech{traverse pass} that work across separately built documents.
56+ table, and @racket[resolve-info] table, except that
57+ @racket[traverse-part]s are replaced just after the traverse pass
58+ by rebuilding enclosing @racket[part] structures. The collect pass and
59+ resolve pass are effectively specialized version of
60+ traverse pass that work across separately built documents.
5861
59-
6062@; ------------------------------------------------------------------------
6163
6264@section[#:tag "parts " ]{Parts, Flows, Blocks, and Paragraphs}
@@ -386,7 +388,7 @@ value that has been accumulated from enclosing parts.
386388 [style style?]
387389 [to-collect list?]
388390 [blocks (listof block?)]
389- [parts (listof part?)])]{
391+ [parts (listof (or/c part? traverse-part?) )])]{
390392
391393The @racket[tag-prefix] field determines the optional @techlink{tag
392394prefix } for the part and/or @techlink{part context} accumulation. When
@@ -611,7 +613,9 @@ passes (i.e., it doesn't directly contribute to the output).
611613The @racket[blocks] field contains the part's initial flow (before
612614sub-parts).
613615
614- The @racket[parts] field contains sub-parts.
616+ The @racket[parts] field contains sub-parts. A @racket[traverse-part]
617+ within @racket[parts] is converted to a replacement list of
618+ @racket[part]s just after the @tech{traverse pass}.
615619
616620@history[#:changed "1.25 " @elem{Added @racket['no-index ] support.}
617621 #:changed "1.26 " @elem{Added @racket[link-render-style] support.}
@@ -621,7 +625,27 @@ The @racket[parts] field contains sub-parts.
621625 #:changed "1.57 " @elem{Added @racket['no-header-controls ] support.}
622626 #:changed "1.59 " @elem{Added @racket['no-navigation ],
623627 @racket['family-navigation ], and
624- @racket['show-language-family ] support.}]}
628+ @racket['show-language-family ] support.}
629+ #:changed "1.67 " @elem{Added @racket[traverse-part?] as a possible
630+ contract on an element in @racket[parts] list.}]}
631+
632+
633+ @defstruct[traverse-part ([traverse part-traverse-procedure/c])]{
634+
635+ Produces a replacement list of parts (possibly empty) during the
636+ @tech{traverse pass}, eventually.
637+
638+ The @racket[traverse] procedure is called with @racket[_get] and
639+ @racket[_set] procedures to get and set symbol-keyed information; the
640+ @racket[traverse] procedure should return either a list of
641+ @tech{parts} (which effectively takes the @racket[traverse-part]'s
642+ place ) or a procedure like @racket[traverse] to be called in the next
643+ iteration of the @tech{traverse pass}.
644+
645+ See @racket[traverse-block] for more information that applies to
646+ @racket[traverse-part], too.
647+
648+ @history[#:added "1.67 " ]}
625649
626650
627651@defstruct[paragraph ([style style?] [content content?])]{
@@ -1809,6 +1833,18 @@ Produces the block that replaces @racket[b].}
18091833Produces the content that replaces @racket[e].}
18101834
18111835
1836+ @defthing[part-traverse-procedure/c contract?]{
1837+
1838+ Defined as
1839+
1840+ @racketblock[
1841+ (recursive-contract
1842+ ((symbol? any/c . -> . any/c)
1843+ (symbol? any/c . -> . any )
1844+ . -> . (or/c part-traverse-procedure/c
1845+ (listof part?))))
1846+ ]}
1847+
18121848@defthing[block-traverse-procedure/c contract?]{
18131849
18141850Defined as
0 commit comments