bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

core.scrbl (80012B)


      1 #lang scribble/doc
      2 @(require scribble/manual 
      3           (except-in "utils.rkt" url)
      4           "struct-hierarchy.rkt" 
      5           (only-in scribble/eval as-examples)
      6           (for-label scribble/manual-struct
      7                      racket/serialize
      8                      file/convertible
      9                      setup/main-collects
     10                      scriblib/render-cond
     11                      xml/xexpr
     12                      net/url-structs
     13                      scriblib/figure
     14                      (only-in scribble/html-render render-mixin)))
     15 
     16 @title[#:tag "core"]{Structures And Processing}
     17 
     18 @defmodule[scribble/core]
     19 
     20 A document is represented as a @techlink{part}, as described in
     21  @secref["parts"]. This representation is intended to be
     22  independent of its eventual rendering, and it is intended to be
     23  immutable; rendering extensions and specific data in a document can
     24  collude arbitrarily, however.
     25 
     26 A document is processed in four passes:
     27 
     28 @itemlist[
     29 
     30  @item{The @deftech{traverse pass} traverses the document content in
     31        document order so that information from one part of a document
     32        can be communicated to other parts of the same document. The
     33        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
     36        pass} iterates the traversal until it obtains a fixed point
     37        (i.e., the mapping from one iteration is unchanged from the
     38        previous iteration).}
     39 
     40  @item{The @deftech{collect pass} globally collects information in the
     41        document that can span documents that are built at separate
     42        times, such as targets for hyperlinking.}
     43 
     44  @item{The @deftech{resolve pass} matches hyperlink references
     45        with targets and expands delayed elements (where the expansion
     46        should not contribute new hyperlink targets).}
     47 
     48  @item{The @deftech{render pass} generates the result document.}
     49 
     50 ]
     51 
     52 None of the passes mutate the document representation. Instead, the
     53  @tech{traverse pass}, @tech{collect pass}, and @tech{resolve pass}
     54  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.
     58 
     59  
     60 @; ------------------------------------------------------------------------
     61 
     62 @section[#:tag "parts"]{Parts, Flows, Blocks, and Paragraphs}
     63 
     64 This diagram shows the large-scale structure of the
     65 type hierarchy for Scribble documents. A box represents
     66 a struct or a built-in Racket type; for example @racket[part] is a struct.
     67 The bottom portion of a box shows the fields; for example
     68 @racket[part] has three fields, @racket[title], @racket[blocks], 
     69 and @racket[subparts].
     70 The substruct relationship
     71 is shown vertically with navy blue lines connected by a triangle;
     72 for example, a @racket[compound-paragraph] is a @racket[block]. 
     73 The types of values on fields are shown via dark red lines in the diagram.
     74 Doubled lines represent lists and tripled lines represent lists
     75 of lists; for example, the @racket[blocks] field of 
     76 @racket[compound-paragraph] is a list of @racket[blocks].
     77 Dotted lists represent functions that compute elements of
     78 a given field; for example, the @racket[block] field of 
     79 a @racket[traverse-block] struct is a function that
     80 computes a @racket[block]. 
     81 
     82 The diagram is not completely
     83 accurate: a @racket[table] may have @racket['cont]
     84 in place of a block in its @racket[cells] field, and
     85 the types of fields are only shown if they are other structs
     86 in the diagram.
     87 A prose description with more detail follows the diagram.
     88 
     89 @(mk-diagram)
     90 
     91 A @deftech{part} is an instance of @racket[part]; among other things,
     92  it has a title @techlink{content}, an initial @techlink{flow}, and a
     93  list of subsection @techlink{parts}.  There is no difference between
     94  a part and a full document; a particular source module just as easily
     95  defines a subsection (incorporated via @racket[include-section]) as a
     96  document.
     97 
     98 A @deftech{flow} is a list of @techlink{blocks}.
     99 
    100 A @deftech{block} is either a @techlink{table}, an
    101  @techlink{itemization}, a @techlink{nested flow}, a
    102  @techlink{paragraph}, a @techlink{compound paragraph}, a
    103  @techlink{traverse block}, or a @techlink{delayed block}.
    104 
    105 @itemize[
    106 
    107        @item{A @deftech{table} is an instance of @racket[table]; it
    108              has a list of list of @techlink{blocks} corresponding to
    109              table cells.}
    110 
    111        @item{A @deftech{itemization} is an instance of @racket[itemization];
    112              it has a list of @techlink{flows}.}
    113 
    114        @item{A @deftech{nested flow} is an instance of
    115              @racket[nested-flow]; it has a @tech{flow} that
    116              is typeset as sub-flow.}
    117 
    118        @item{A @deftech{paragraph} is an instance of
    119              @racket[paragraph]; it has a @tech{content}:
    120 
    121              @itemize[
    122 
    123              @item{A @deftech{content} can be a string, one of a few
    124                    symbols, a convertible value in the sense of @racket[convertible?],
    125                    an instance of @racket[element] (possibly
    126                    @racket[link-element], etc.), a @racket[multiarg-element], a
    127                    @techlink{traverse element}, a @techlink{part-relative element}, a
    128                    @techlink{delayed element}, or a list of content.
    129 
    130                    @itemize[
    131 
    132                    @item{A string is included in the result
    133                          document verbatim, except for space, and
    134                          unless the content's enclosing @tech{style} is
    135                          @racket['hspace]. In a style other than
    136                          @racket['hspace], consecutive spaces in the
    137                          output may be collapsed togther or replaced
    138                          with a line break. In the style
    139                          @racket['hspace], all text is converted to
    140                          uncollapsible spaces that cannot be broken
    141                          across lines.}
    142 
    143                    @item{A symbol content is either @racket['mdash],
    144                          @racket['ndash], @racket['ldquo],
    145                          @racket['lsquo], @racket['rdquo], @racket['rsquo], @racket['larr],
    146                          @racket['rarr], or @racket['prime]; it is
    147                          rendered as the corresponding HTML entity
    148                          (even for Latex output).}
    149 
    150                    @item{A convertible value in the sense of @racket[convertible?]
    151                          is used in a renderer-specific way, but values convertible
    152                          to @racket['text] renders the same as the resulting
    153                          string. If a renderer is not able to convert the value
    154                          to a known format, the value is converted to a string
    155                          using @racket[write].}
    156 
    157                    @item{An instance of @racket[element] has a
    158                          @techlink{content} plus a @tech{style}. The style's
    159                          interpretation depends on the renderer, but it
    160                          can be one of a few special symbols (such as
    161                          @racket['bold]) that are recognized by all
    162                          renderers.}
    163 
    164                    @item{An instance of @racket[link-element] has a
    165                          @techlink{tag} for the target of the link.}
    166 
    167                    @item{An instance of @racket[target-element] has a
    168                          @techlink{tag} to be referenced by
    169                          @racket[link-element]s. An instance of the
    170                          subtype @racket[toc-target-element] is
    171                          treated like a kind of section label, to be
    172                          shown in the ``on this page'' table for HTML
    173                          output.}
    174 
    175                    @item{An instance of @racket[index-element] has a
    176                          @techlink{tag} (as a target), a list of
    177                          strings for the keywords (for sorting and
    178                          search), and a list of @techlink{contents} to
    179                          appear in the end-of-document index.}
    180 
    181                    @item{An instance of @racket[image-element]
    182                          incorporates an image from a file into the rendered
    183                          document.}
    184 
    185                    @item{An instance of @racket[multiarg-element]
    186                          combines a style with a list of content,
    187                          where the style corresponds to a rendered
    188                          command that takes multiple arguments.}
    189 
    190                    @item{An instance of @racket[collect-element] has a
    191                          procedure that is called in the
    192                          @techlink{collect pass} of document
    193                          processing to record information used by
    194                          later passes.}
    195 
    196                    @item{A @deftech{traverse element} is an instance
    197                          of @racket[traverse-element], which
    198                          ultimately produces content, but can
    199                          accumulate and inspect information in the
    200                          @tech{traverse pass}.}
    201 
    202                    @item{A @deftech{part-relative element} is an
    203                          instance of @racket[part-relative-element],
    204                          which has a procedure that is called in the
    205                          @techlink{collect pass} of document
    206                          processing to obtain @defterm{content}. When the
    207                          part-relative element's procedure is called,
    208                          collected information is not yet available,
    209                          but information about the enclosing parts is
    210                          available.}
    211 
    212                    @item{A @deftech{delayed element} is an instance of
    213                          @racket[delayed-element], which has a
    214                          procedure that is called in the
    215                          @techlink{resolve pass} of document
    216                          processing to obtain @defterm{content}.}
    217 
    218                    @item{An instance of @racket[render-element] has a
    219                          procedure that is called in the
    220                          @techlink{render pass} of document
    221                          processing.}
    222 
    223              ]}]}
    224 
    225        @item{A @deftech{compound paragraph} is an instance of
    226              @racket[compound-paragraph]; like @racket[blockquote], it
    227              has list of @tech{blocks}, but the blocks are typeset as
    228              a single paragraph (e.g., no indentation after the first
    229              block) instead of inset.}
    230 
    231        @item{A @deftech{traverse block} is an instance of
    232              @racket[traverse-block], which ultimately produces
    233              another block, but can accumulate and inspect information
    234              during the @tech{traverse pass}.}
    235 
    236        @item{A @deftech{delayed block} is an instance of
    237              @racket[delayed-block], which has a procedure that
    238              is called in the @techlink{resolve pass} of document
    239              processing to obtain a @defterm{block}.}
    240 
    241 ]
    242 
    243 @history[#:changed "1.23" @elem{Changed the handling of @racket[convertible?]
    244                                 values to recognize a @racket['text] conversion
    245                                 and otherwise use @racket[write].}]
    246 
    247 @; ------------------------------------------------------------------------
    248 
    249 @section[#:tag "tags"]{Tags}
    250 
    251 A @deftech{tag} is a list containing a symbol and either a string, a
    252 @racket[generated-tag] instance, or an arbitrary list. The symbol
    253 effectively identifies the type of the tag, such as @racket['part] for
    254 a tag that links to a part, or @racket['def] for a Racket function
    255 definition. The symbol also effectively determines the interpretation
    256 of the second half of the tag.
    257 
    258 A part can have a @deftech{tag prefix}, which is effectively added
    259 onto the second item within each tag whose first item is
    260 @racket['part], @racket['tech], or @racket['cite], or whose second
    261 item is a list that starts with @racket['prefixable]:
    262 
    263 @itemlist[
    264 
    265  @item{The prefix is added to a string second item by creating a list
    266        containing the prefix and string.}
    267 
    268  @item{The prefix is added to a list second item after @racket['part],
    269        @racket['tech], or @racket['cite] using @racket[cons].}
    270 
    271  @item{The prefix is added to a second item that starts
    272        @racket['prefixable] by adding it to the list after
    273        @racket['prefixable].}
    274 
    275  @item{A prefix is not added to a  @racket[generated-tag] item.}
    276 
    277 ]
    278 
    279 The prefix is used for reference outside the part, including the use
    280 of tags in the part's @racket[tags] field. Typically, a document's
    281 main part has a tag prefix that applies to the whole document;
    282 references to sections and defined terms within the document from
    283 other documents must include the prefix, while references within the
    284 same document omit the prefix. Part prefixes can be used within a
    285 document as well, to help disambiguate references within the document.
    286 
    287 Some procedures accept a ``tag'' that is just the string part of the
    288 full tag, where the symbol part is supplied automatically. For
    289 example, @racket[section] and @racket[secref] both accept a string
    290 ``tag'', where @racket['part] is implicit.
    291 
    292 The @racketmodname[scribble/tag] library provides functions for constructing
    293 @tech{tags}.
    294 
    295 @; ------------------------------------------------------------------------
    296 
    297 @section[#:tag "style"]{Styles}
    298 
    299 A @deftech{style} combines a @tech{style name} with a list of
    300 @tech{style properties} in a @racket[style] structure. A @deftech{style name}
    301 is either a string, symbol, or @racket[#f]. A @deftech{style property} can be
    302 anything, including a symbol or a structure such as
    303 @racket[color-property].
    304 
    305 A style has a single @tech{style name}, because the name typically
    306 corresponds to a configurable instruction to a renderer. For example,
    307 with Latex output, a string style name corresponds to a Latex command
    308 or environment. For more information on how string style names
    309 interact with configuration of a renderer, see
    310 @secref["config"]. Symbolic style names, meanwhile, provide a simple
    311 layer of abstraction between the renderer and documents for widely
    312 supported style; for example, the @racket['italic] style name is
    313 supported by all renderers.
    314 
    315 @tech{Style properties} within a style compose with style names and other
    316 properties. Again, symbols are often used for properties that are directly
    317 supported by renderers. For example, @racket['unnumbered] style
    318 property for a @tech{part} renders the part without a section number.
    319 Many properties are renderer-specific, such as a @racket[hover-property]
    320 structure that associates text with an element to be shown in an
    321 HTML display when the mouse hovers over the text.
    322 
    323 @; ------------------------------------------------------------------------
    324 
    325 @section[#:tag "passes"]{Collected and Resolved Information}
    326 
    327 The @techlink{collect pass}, @techlink{resolve pass}, and
    328 @techlink{render pass} processing steps all produce information that
    329 is specific to a rendering mode. Concretely, the operations are all
    330 represented as methods on a @racket[render<%>] object.
    331 
    332 The result of the @method[render<%> collect] method is a
    333 @racket[collect-info] instance. This result is provided back as an
    334 argument to the @method[render<%> resolve] method, which produces a
    335 @racket[resolve-info] value that encapsulates the results from both
    336 iterations. The @racket[resolve-info] value is provided back to the
    337 @method[render<%> resolve] method for final rendering.
    338 
    339 Optionally, before the @method[render<%> resolve] method is called,
    340 serialized information from other documents can be folded into the
    341 @racket[collect-info] instance via the @method[render<%>
    342 deserialize-info] method. Other methods provide serialized information
    343 out of the collected and resolved records.
    344 
    345 During the @techlink{collect pass}, the procedure associated with a
    346 @racket[collect-element] instance can register information with
    347 @racket[collect-put!].
    348 
    349 During the @techlink{resolve pass}, collected information for a part
    350 can be extracted with @racket[part-collected-info], which includes a
    351 part's number and its parent part (or @racket[#f]). More generally,
    352 the @racket[resolve-get] method looks up information previously
    353 collected. This resolve-time information is normally obtained by the
    354 procedure associated with a @techlink{delayed block} or
    355 @techlink{delayed element}.
    356 
    357 The @racket[resolve-get] information accepts both a @racket[part] and
    358 a @racket[resolve-info] argument. The @racket[part] argument enables
    359 searching for information in each enclosing part before sibling parts.
    360 
    361 @; ------------------------------------------------------------------------
    362 
    363 @section{Structure Reference}
    364 
    365 @defstruct[part ([tag-prefix (or/c #f string?)]
    366                  [tags (listof tag?)]
    367                  [title-content (or/c #f list?)]
    368                  [style style?]
    369                  [to-collect list?]
    370                  [blocks (listof block?)]
    371                  [parts (listof part?)])]{
    372 
    373 The @racket[tag-prefix] field determines the optional @techlink{tag
    374 prefix} for the part.
    375 
    376 The @racket[tags] indicates a list of @techlink{tags} that each link
    377 to the section. Normally, @racket[tags] should be a non-empty list, so
    378 that hyperlinks can target the section.
    379 
    380 The @racket[title-content] field holds the part's title, if any.
    381 
    382 For the @racket[style] field, the currently recognized symbolic style
    383 names are as follows:
    384 
    385 @itemize[
    386 
    387  @item{@indexed-racket['index] --- The part represents an index.}
    388 
    389 ]
    390 
    391 The recognized @tech{style properties} are as follows:
    392 
    393 @itemize[
    394 
    395  @item{@indexed-racket['unnumbered] --- A section number is not computed or
    396        rendered for the section.}
    397 
    398  @item{@indexed-racket['hidden-number] --- A section number is computed for
    399        the section, but it is not rendered as part of the section name.}
    400 
    401  @item{@indexed-racket['toc-hidden] --- The part title is not shown in tables
    402        of contents, including in ``on this page'' boxes. For Latex
    403        rendering, the part title is omitted only if it is unnumbered
    404        or has a hidden number.}
    405 
    406  @item{@indexed-racket['hidden] --- The part title is not shown; for Latex
    407        output, the part title is not shown only if its is empty, and
    408        in that case, it is also excluded from tables of contents.  The
    409        @racket['toc-hidden] @tech{style property} usually should be included with
    410        @racket['hidden] (for consistency in non-Latex output).}
    411 
    412  @item{@indexed-racket['grouper] --- The part is numbered with a Roman
    413        numeral, by default, and its subsections continue numbering as
    414        if they appeared in the preceeding part. In other words, the
    415        part acts like a ``part'' in a book where chapter numbering is
    416        continuous across parts.}
    417 
    418  @item{@tech{numberer} --- A @tech{numberer} created with
    419        @racket[make-numberer] determines a representation of the
    420        part's section number as an extension of it's parent's number.
    421        A @tech{numberer} overrides the default representation, which
    422        is a natural number or (in the case of an accompanying
    423        @racket['grouper] property) a Roman numeral. If a
    424        @racket['unnumbered] property is also present, a
    425        @tech{numberer} property is ignored.}
    426 
    427  @item{@indexed-racket['toc] --- Sub-parts of the part are rendered on separate
    428        pages for multi-page HTML mode.}
    429 
    430  @item{@indexed-racket['non-toc] --- Initial sub-parts of the part are
    431        @emph{not} rendered on separate pages for multi-page HTML
    432        mode; this @tech{style property} applies only to the main part.}
    433 
    434  @item{@indexed-racket['reveal] --- Shows sub-parts when this part is
    435        displayed in a table-of-contents panel in HTML output (which
    436        normally shows only the top-level sections).}
    437 
    438  @item{@indexed-racket['quiet] --- In HTML output and most other output modes,
    439        hides entries for sub-parts of this part in a
    440        @racket[table-of-contents] or @racket[local-table-of-contents]
    441        listing except when those sub-parts are top-level entries in
    442        the listing.}
    443 
    444  @item{@indexed-racket['no-toc+aux] --- As a @tech{style property} for
    445        the main part of a rendered page, causes the HTML output to not
    446        include a margin box for the main table of contents, ``on this
    447        page'', or tables with the @racket['aux] style property. The
    448        @racket['no-toc+aux] property effectively implies
    449        @racket['no-toc] and @racket['no-sidebar], but also suppresses
    450        @racket['aux] tables.}
    451 
    452  @item{@indexed-racket['no-toc] --- As a @tech{style property} for the main part of a
    453        rendered page, causes the HTML output to not include a margin box
    454        for the main table of contents; the ``on this page'' box that
    455        contains @racket[toc-element] and @racket[toc-target-element]
    456        links (and that only includes an ``on this page'' label for
    457        multi-page documents) takes on the location and color of the
    458        main table of contents, instead.}
    459 
    460  @item{@indexed-racket['no-sidebar] --- As a @tech{style property} for the main part of a
    461        document, causes the HTML output to not include an ``on this 
    462        page'' margin box.}
    463 
    464  @item{@indexed-racket['no-index] --- Has no effect as a @tech{style
    465        property} on a @racket[part], but as a style property on a
    466        @racket[title] or @racket[part-start] that provides a
    467        @racket[part]'s style via @racket[decode], the
    468        @racket['no-index] @tech{style property} cause @racket[decode]
    469        to skip the generation of an entry for the part's title in the
    470        document index.}
    471 
    472  @item{@racket[document-version] structure --- A version number for
    473        this part and its sub-parts (except as overridden). When it is
    474        not @racket[""] may be used when rendering a document; at a
    475        minimum, a non-@racket[""] version is rendered when it is
    476        attached to a part representing the whole document. The default
    477        version for a document is @racket[(version)]. In rendered form,
    478        the version is normally prefixed with the word ``Version,'' but
    479        this formatting can be controlled by overriding
    480        @tt{.version:before} and/or @tt{.versionNoNav:before} in CSS
    481        for HTML rendering or by redefining the @tt{\SVersionBefore}
    482        macro for Latex rendering (see @secref["config"]).}
    483 
    484  @item{@racket[document-date] structure --- A date for the part,
    485        normally used on a document's main part for for Latex
    486        output. The default date for a document is @racket[#f], which
    487        avoids explicitly specifying a date at the Latex level, so that
    488        the current date is used as the document date. Set the date to
    489        @racket[""] to suppress a date in an output document.}
    490 
    491   @item{@racket[body-id] structure --- Generated HTML uses the given
    492         string @tt{id} attribute of the @tt{<body>} tag; this @tech{style property} can
    493         be set separately for parts that start different HTML pages,
    494         otherwise it is effectively inherited by sub-parts; the
    495         default is @racket["scribble-racket-lang.org"], but
    496         @exec{raco setup} installs @racket["doc-racket-lang.org"] as the
    497         @tt{id} for any document that it builds.}
    498 
    499  @item{@racket[attributes] structure --- Provides additional HTML
    500        attributes for the @tt{<html>} tag when the part corresponds to
    501        its own HTML page.}
    502 
    503  @item{@racket[head-extra] structure --- Provides additional HTML
    504        content for the @tt{<head>} tag when the part corresponds to
    505        its own HTML page.}
    506 
    507  @item{@racket[color-property] structure --- For HTML, applies a color
    508        to the part title.}
    509 
    510  @item{@racket[background-color-property] structure --- For HTML,
    511        applies a color to the background of the part title.}
    512 
    513  @item{@racket[hover-property] structure --- For HTML, adds a text
    514        label to the title to be shown when the mouse hovers over
    515        it.}
    516            
    517  @item{@racket[render-convertible-as] structure --- For HTML, controls
    518         how objects that subscribe to the @racketmodname[file/convertible]
    519         protocol are rendered.}
    520 
    521  @item{@racket[document-source] structure --- For HTML, provides a
    522         module path for the part's source. Clicking on an HTML section
    523         title generated for the part or its sub-parts may show the
    524         module path plus a section-tag string, so that the user can
    525         create a reference to the section.}
    526 
    527  @item{@racket[link-render-style] structure --- Determines the default
    528        rendering of links to sections or other destinations within the
    529        section. See also @racket[link-element] and
    530        @racket[current-link-render-style].}
    531 
    532  @item{@racket['enable-index-merge] --- On an index parts or one of
    533        its enclosing parts for Latex output, causes index entries to
    534        be merged when they have the same content, with multiple
    535        references for the same entry combined with @ltx{Smanypageref}.
    536        The @ltx{Smanypageref} Latex macro must be redefined to accept
    537        multiple @litchar{,}-separated labels and generate a suitable set of
    538        references. See also @racketmodname[scriblib/book-index].}
    539 
    540 ]
    541 
    542 The @racket[to-collect] field contains @techlink{content} that is
    543 inspected during the @techlink{collect pass}, but ignored in later
    544 passes (i.e., it doesn't directly contribute to the output).
    545 
    546 The @racket[blocks] field contains the part's initial flow (before
    547 sub-parts).
    548 
    549 The @racket[parts] field contains sub-parts.
    550 
    551 @history[#:changed "1.25" @elem{Added @racket['no-index] support.}
    552          #:changed "1.26" @elem{Added @racket[link-render-style] support.}
    553          #:changed "1.27" @elem{Added @racket['no-toc+aux] support.}]}
    554 
    555 
    556 @defstruct[paragraph ([style style?] [content content?])]{
    557 
    558 A @techlink{paragraph} has a @tech{style} and a @tech{content}.
    559 
    560 For the @racket[style] field, a string @tech{style name} corresponds
    561 to a CSS class for HTML output or a macro for Latex output (see
    562 @secref["extra-style"]). The following symbolic @tech{style names} are
    563 recognized:
    564 
    565 @itemize[
    566 
    567  @item{@indexed-racket['author] --- Typeset as the author of a document.  Such
    568        paragraphs normally should appear only in the initial flow of a
    569        @racket[part] for a document, where they are treated specially
    570        by the Latex renderer by moving the author information to the
    571        title.}
    572 
    573  @item{@indexed-racket['pretitle] --- Typeset before the title of the
    574        enclosing part.}
    575 
    576  @item{@indexed-racket['wraps] --- Like a @racket[#f] @tech{style name}, but not
    577        @tech{boxable} in the sense of @racket[box-mode] for Latex output.}
    578 
    579 ]
    580 
    581 When a paragraph's style is @racket[#f], then it is @tech{boxable} in the
    582 sense of @racket[box-mode] for Latex output.
    583 
    584 The currently recognized @tech{style properties} are as follows:
    585 
    586 @itemize[
    587 
    588  @item{@indexed-racket['omitable] --- When a table cell contains a single
    589        @racket[paragraph] with the @racket['omitable] @tech{style property},
    590        then when rendering to HTML, no @tt{<p>} tag wraps the cell
    591        content.}
    592 
    593  @item{@indexed-racket['div] --- Generates @tt{<div>} HTML output instead of
    594        @tt{<p>} (unless a @racket[alt-tag] property is provided).}
    595 
    596  @item{@racket[alt-tag] structure --- Generates the indicated HTML tag
    597        instead of @tt{<p>} or @tt{<div>}.}
    598 
    599  @item{@racket[attributes] structure --- Provides additional HTML
    600        attributes for the @tt{<p>}, @tt{<div>}, or alternate tag.}
    601 
    602  @item{@indexed-racket['never-indents] --- For Latex and @tech{compound
    603        paragraphs}; see @racket[compound-paragraph].}
    604 
    605  @item{@racket[box-mode] structure --- For Latex output, uses an alternate
    606        rendering form for @tech{boxing contexts} (such as a table cell); see
    607        @racket[box-mode].}
    608 
    609 ]}
    610 
    611 
    612 @defstruct[table ([style style?]
    613                   [blockss (listof (listof (or/c block? 'cont)))])]{
    614 
    615 See also the @racket[tabular] function.
    616 
    617 A @techlink{table} has, roughly, a list of list of blocks. A cell in
    618 the table can span multiple columns by using @racket['cont] instead of
    619 a block in the following columns (i.e., for all but the first in a set
    620 of cells that contain a single block).
    621 
    622 Within @racket[style], a string @tech{style name} corresponds to a CSS
    623 class for HTML output or an environment for Latex output (see
    624 @secref["extra-style"]). The following symbolic style names are also
    625 recognized:
    626 
    627 @itemize[
    628 
    629  @item{@indexed-racket['boxed] --- Renders as a definition.
    630        This style name is not intended for use on a table that is
    631        nested within a @racket['boxed] table; nested uses may look
    632        right for some renders of the style but not others.}
    633 
    634  @item{@indexed-racket['centered] --- Centers HTML output horizontally.}
    635 
    636  @item{@indexed-racket['block] --- Prevents pages breaks in Latex output.}
    637 
    638 ]
    639 
    640 The following @tech{style properties} are currently recognized:
    641 
    642 @itemize[
    643 
    644  @item{@racket[table-columns] structure --- Provides column-specific
    645        styles, but only @racket[column-attributes] properties (if any)
    646        are used if a @racket[table-cells] structure is included as a
    647        @tech{style property}. See @racket[table-cells] for information
    648        about how a column style is used for each cell.}
    649 
    650  @item{@racket[table-cells] structure --- Provides cell-specific
    651        styles. See @racket[table-cells] for information about how the
    652        styles are used.}
    653 
    654  @item{@racket[attributes] structure --- Provides additional HTML
    655        attributes for the @tt{<table>} tag.}
    656 
    657  @item{@indexed-racket['aux] --- For HTML, include the table in the
    658        table-of-contents display for the enclosing part.}
    659 
    660  @item{@indexed-racket['never-indents] --- For Latex and @tech{compound
    661        paragraphs}; see @racket[compound-paragraph].}
    662 
    663 ]
    664 
    665 For Latex output, a paragraph as a cell value is not automatically
    666 line-wrapped, unless a vertical alignment is specified for the cell
    667 through a @racket[table-cells] or @racket[table-columns]
    668 @tech{style property}. To get a line-wrapped paragraph, use a
    669 @racket[compound-paragraph] or use an element with a string style and
    670 define a corresponding Latex macro in terms of @ltx{parbox}. For Latex
    671 output of blocks in the flow that are @racket[nested-flow]s,
    672 @racket[itemization]s, @racket[compound-paragraph]s, or
    673 @racket[delayed-block]s, the block is wrapped with @ltxe{minipage} using
    674 @ltx{linewidth} divided by the column count as the width.}
    675 
    676 
    677 @defstruct[itemization ([style style?]
    678                         [blockss (listof (listof block?))])]{
    679 
    680 A @techlink{itemization} has a @tech{style} and a list of @tech{flows}.
    681 
    682 In @racket[style], a string @tech{style name} corresponds to a CSS
    683 class for HTML output or a macro for Latex output (see
    684 @secref["extra-style"]). In addition, the following symbolic style
    685 names are recognized:
    686 
    687 @itemize[
    688 
    689  @item{@indexed-racket['compact] --- Reduces space between items.}
    690 
    691  @item{@indexed-racket['ordered] --- Generates @tt{<ol>} HTML output instead
    692        of @tt{<ul>} or an Latex enumeration instead of an
    693        itemization.}
    694 ]
    695 
    696 The following @tech{style properties} are currently recognized:
    697 
    698 @itemize[
    699 
    700  @item{@racket[attributes] structure --- Provides additional HTML
    701        attributes for the @tt{<ul>} or @tt{<ol>} tag.}
    702 
    703  @item{@indexed-racket['never-indents] --- For Latex and @tech{compound
    704        paragraphs}; see @racket[compound-paragraph].}
    705 
    706 ]}
    707 
    708 
    709 @defstruct[nested-flow ([style style?]
    710                         [blocks (listof block?)])]{
    711 
    712 A @techlink{nested flow} has a style and a @tech{flow}.
    713 
    714 In @racket[style], the @tech{style name} is normally a string that
    715 corresponds to a CSS class for HTML @tt{<blockquote>} output or a Latex
    716 environment (see @secref["extra-style"]). The following symbolic style
    717 names are recognized:
    718 
    719 @itemize[
    720 
    721  @item{@indexed-racket['inset] --- Insets the nested flow relative to
    722        surrounding text.}
    723 
    724  @item{@indexed-racket['code-inset] --- Insets the nested flow relative to
    725        surrounding text in a way suitable for code. If the nested flow
    726        has a single block, then it is @tech{boxable} in the sense of
    727        @racket[box-mode] for Latex output.}
    728 
    729  @item{@indexed-racket['vertical-inset] --- Insets the nested flow vertically
    730        relative to surrounding text, but not horizontally. If the
    731        nested flow has a single block, then it is @tech{boxable} in the sense
    732        of @racket[box-mode] for Latex output.}
    733 
    734 ]
    735 
    736 The following @tech{style properties} are currently recognized:
    737 
    738 @itemize[
    739 
    740  @item{@indexed-racket['command] --- For Latex output, a string @tech{style
    741        name} is used as a command name instead of an environment
    742        name.}
    743 
    744  @item{@indexed-racket['multicommand] --- For Latex output, a string
    745        @tech{style name} is used as a command name with a separate
    746        argument for each block in @racket[blocks].}
    747 
    748  @item{@racket[attributes] structure --- Provides additional HTML
    749        attributes for the @tt{<blockquote>} tag.}
    750 
    751  @item{@indexed-racket['never-indents] --- For Latex and @tech{compound
    752        paragraphs}; see @racket[compound-paragraph].}
    753 
    754  @item{@racket[box-mode] structure --- For Latex output, uses an alternate
    755        rendering form for @tech{boxing contexts} (such as a table cell); see
    756        @racket[box-mode].}
    757 
    758  @item{@indexed-racket['decorative] --- The content of the nested flow is intended
    759        for decoration. Text output skips a decorative nested flow.}
    760 
    761  @item{@racket[alt-tag] structure --- Generates the indicated HTML tag
    762        instead of @tt{<blockquote>}.}
    763 
    764  @item{@indexed-racket['pretitle] --- For Latex, raises the contents
    765    of the flow to above the title.}
    766 ]}
    767 
    768 
    769 @defstruct[compound-paragraph ([style style?]
    770                                [blocks (listof block?)])]{
    771 
    772 A @techlink{compound paragraph} has a @tech{style} and a list of
    773 @tech{blocks}.
    774 
    775 For HTML, a @racket[paragraph] block in @racket[blocks] is rendered
    776 without a @tt{<p>} tag, unless the paragraph has a style with a
    777 non-@racket[#f] @tech{style name}. For Latex, each @tech{block} in
    778 @racket[blocks] is rendered with a preceding @ltx{noindent}, unless
    779 the block has the @racket['never-indents] property (checking
    780 recursively in a @racket[nested-flow] or @racket[compound-paragraph]
    781 if the @racket[nested-flow] or @racket[compound-paragraph] itself has
    782 no @racket['never-indents] property).
    783 
    784 The @racket[style] field of a compound paragraph is normally a string
    785 that corresponds to a CSS class for HTML output or Latex environment
    786 for Latex output (see @secref["extra-style"]). The following
    787 @tech{style properties} are currently recognized:
    788 
    789 @itemize[
    790 
    791  @item{@indexed-racket['command] --- For Latex output, a string @tech{style
    792        name} is used as a command name instead of an environment
    793        name.}
    794 
    795  @item{@racket[alt-tag] structure --- Generates the given HTML tag
    796        instead of @tt{<p>}.}
    797 
    798  @item{@racket[attributes] structure --- Provides additional HTML
    799        attributes for the @tt{<p>} or alternate tag.}
    800 
    801  @item{@indexed-racket['never-indents] --- For Latex within another
    802        @tech{compound paragraph}; see above.}
    803 
    804 ]}
    805 
    806 
    807 @defstruct[traverse-block ([traverse block-traverse-procedure/c])]{
    808 
    809 Produces another block during the @tech{traverse pass}, eventually.
    810 
    811 The @racket[traverse] procedure is called with @racket[_get] and
    812 @racket[_set] procedures to get and set symbol-keyed information; the
    813 @racket[traverse] procedure should return either a @tech{block} (which
    814 effectively takes the @racket[traverse-block]'s place) or a procedure
    815 like @racket[traverse] to be called in the next iteration of the
    816 @tech{traverse pass}.
    817 
    818 All @racket[traverse-element] and @racket[traverse-block]s that have
    819 not been replaced are forced in document order relative to each other
    820 during an iteration of the @tech{traverse pass}.
    821 
    822 The @racket[_get] procedure passed to @racket[traverse] takes a symbol
    823 and any value to act as a default; it returns information registered
    824 for the symbol or the given default if no value has been
    825 registered. The @racket[_set] procedure passed to @racket[traverse]
    826 takes a symbol and a value to be registered for the symbol.
    827 
    828 @margin-note*{See also @racket[cond-block] in @racketmodname[scriblib/render-cond].}
    829 @;
    830 The symbol @indexed-racket['scribble:current-render-mode] is
    831 automatically registered to a list of symbols that describe the
    832 target of document rendering. The list contains @racket['html]
    833 when rendering to HTML, @racket['latex] when rendering via Latex, and
    834 @racket['text] when rendering to text. The registration of
    835 @racket['scribble:current-render-mode] cannot be changed via
    836 @racket[_set].}
    837 
    838 
    839 @defstruct[delayed-block ([resolve (any/c part? resolve-info? . -> . block?)])]{
    840 
    841 The @racket[resolve] procedure is called during the @techlink{resolve
    842 pass} to obtain a normal @tech{block}. The first argument to
    843 @racket[resolve] is the renderer.
    844 
    845 }
    846 
    847 
    848 @defstruct[element ([style element-style?]
    849                     [content content?])]{
    850 
    851 Styled @tech{content} within an enclosing @tech{paragraph} or other content.
    852 
    853 The @racket[style] field can be a @racket[style] structure, but it can
    854 also be just a @tech{style name}.
    855 
    856 In @racket[style], a string @tech{style name} corresponds to a CSS
    857 class for HTML output and a macro name for Latex output (see
    858 @secref["extra-style"]). The following symbolic style names are
    859 recognized:
    860 
    861 @itemize[
    862 
    863  @item{@indexed-racket['tt], @racket['italic], @racket['bold], @racket['roman], @racket['sf],
    864        @racket['url], @racket['subscript], @racket['superscript], 
    865        @racket['smaller], @racket['larger] ---
    866        Basic styles recognized by all renders.}
    867 
    868  @item{@indexed-racket['hspace] --- Renders its @racket[content] as monospace
    869        blanks.}
    870  
    871  @item{@indexed-racket['newline] --- Renders a line break independent of
    872        the @racket[content].}
    873 
    874  @item{@indexed-racket['no-break] --- Prevents line breaks when rendering
    875        @racket[content].}
    876 
    877 ]
    878 
    879 The following @tech{style properties} are currently recognized:
    880 
    881 @itemize[
    882 
    883  @item{@racket[target-url] structure --- Generates a hyperlink.}
    884 
    885  @item{@racket[url-anchor] structure --- For HTML, inserts a hyperlink
    886        target before @racket[content].}
    887 
    888  @item{@racket[color-property] structure --- Applies a color to the
    889        text of @racket[content].}
    890 
    891  @item{@racket[background-color-property] structure --- Applies a
    892        color to the background of @racket[content].}
    893 
    894  @item{@racket[alt-tag] structure --- Generates the given HTML tag
    895        instead of the default one (@tt{<span>}, @tt{<b>}, @|etc|).}
    896 
    897  @item{@racket[attributes] structure --- Provides additional HTML
    898        attributes for a tag.}
    899 
    900  @item{@racket[hover-property] structure --- For HTML, adds a text
    901        label to the content to be shown when the mouse hovers over
    902        it.}
    903 
    904  @item{@racket[script-property] structure --- For HTML, supplies a
    905        script alternative to @racket[content].}
    906 
    907  @item{@racket[xexpr-property] structure --- For HTML, supplies literal
    908        HTML to render before and after @racket[content].}
    909 
    910   @item{@indexed-racket['aux] --- Intended for use in titles, where the
    911         auxiliary part of the title can be omitted in hyperlinks. See,
    912         for example, @racket[secref].}
    913 
    914   @item{@indexed-racket['tt-chars] --- For Latex output, when the @tech{style
    915         name} is a string, render the element's content with escapes
    916         suitable for Latex @tt{tt} mode.}
    917 
    918   @item{@indexed-racket['exact-chars] --- For Latex output, when the @tech{style
    919         name} is a string or @racket[#f], render the elements content exactly
    920         (without escapes).}
    921 
    922   @item{@racket[command-extras] structure --- For Latex output,
    923          adds strings as arguments to the Latex command.}
    924 
    925 ]
    926 
    927 @history[#:changed "1.6" @elem{Changed @racket['exact-chars] handling to
    928          take effect when the style name is @racket[#f].}
    929          #:changed "1.27" @elem{Changed to support @racket[xexpr-property].}]}
    930 
    931 
    932 @defstruct[(image-element element) ([path (or/c path-string?
    933                                                 (cons/c 'collects (listof bytes?)))]
    934                                     [suffixes (listof #rx"^[.]")]
    935                                     [scale real?])]{
    936 
    937 Used as a style for an @racket[element] to inline an image. The
    938 @racket[path] field can be a result of
    939 @racket[path->main-collects-relative].
    940 
    941 For each string in @racket[suffixes], if the rendered works with the
    942 corresponding suffix, the suffix is added to @racket[path] and used if
    943 the resulting path refers to a file that exists. The order in
    944 @racket[suffixes] determines the order in which suffixes are
    945 tried. The HTML renderer supports @racket[".png"], @racket[".gif"], and @racket[".svg"],
    946 while the Latex renderer supports @racket[".png"], @racket[".pdf"],
    947 and @racket[".ps"] (but rendering Latex output to PDF will not work
    948 with @racket[".ps"] files, while rendering to Latex DVI output works
    949 only with @racket[".ps"] files). If @racket[suffixes] is empty or if
    950 none of the suffixes lead to files that exist, @racket[path] is used
    951 as-is.
    952 
    953 The @racket[scale] field scales the image in its rendered form.}
    954 
    955 
    956 @defstruct[(target-element element) ([_tag tag?])]{
    957 
    958 Declares the content as a hyperlink target for @racket[_tag].}
    959 
    960 
    961 @defstruct[(toc-target-element target-element) ()]{
    962 
    963 Like @racket[target-element], the content is also a kind of section
    964 label to be shown in the ``on this page'' table for HTML output.}
    965 
    966 
    967 @defstruct[(toc-target2-element toc-target-element) ([toc-content content?])]{
    968 
    969 Extends @racket[target-element] with a separate field for the content
    970 to be shown in the ``on this page'' table for HTML output.}
    971 
    972 
    973 @defstruct[(page-target-element target-element) ()]{
    974 
    975 Like @racket[target-element], but a link to the element goes to the
    976 top of the containing page.}
    977 
    978 
    979 @defstruct[(redirect-target-element target-element) ([alt-path path-string?]
    980                                                      [alt-anchor string?])]{
    981 
    982 Like @racket[target-element], but a link to the element is redirected
    983 to the given URL.}
    984 
    985 
    986 @defstruct[(toc-element element) ([toc-content content?])]{
    987 
    988 Similar to @racket[toc-target-element], but with specific content for
    989 the ``on this page'' table specified in the @racket[toc-content]
    990 field.}
    991 
    992 
    993 @defstruct[(link-element element) ([tag tag?])]{
    994 
    995 Represents a hyperlink to @racket[_tag].
    996 
    997 Normally, the content of the element is rendered as the hyperlink.
    998 When @racket[_tag] is a part tag and the content of the element is
    999 @racket[null], however, rendering is treated specially based on the
   1000 @racket[_mode] value of a @racket[link-render-style] @tech{style
   1001 property}:
   1002 
   1003 @itemlist[
   1004 
   1005  @item{For HTML output, in the @racket['default] mode, the generated
   1006        reference is the hyperlinked title of the elements in the
   1007        section's title content, except that elements with the
   1008        @racket['aux] @tech{style property} are omitted in the
   1009        hyperlink label.
   1010 
   1011        In @racket['number] mode, the section title is not shown.
   1012        Instead, the word ``section'' is shown followed by a
   1013        hyperlinked section number. The word ``section'' starts in
   1014        uppercase if the element's style includes a @racket['uppercase]
   1015        property.}
   1016 
   1017  @item{For Latex/PDF output, the generated reference's format can
   1018        depend on the document style in addition the @racket[_mode].
   1019        For the @racket['default] mode and a default document style, a
   1020        section number is shown by the word ``section'' followed by the
   1021        section number, and the word ``section'' and the section number
   1022        are together hyperlinked. The word ``section'' starts in
   1023        uppercase if the element's style includes a @racket['uppercase]
   1024        property. The @racketmodname[scribble/manual] style uses the
   1025        symbol ``§'' in place of the word ``section''.
   1026 
   1027        In @racket['number] mode, rendering is the same, except that
   1028        only the number is hyperlinked, not the word ``section'' or
   1029        the ``§'' symbol.
   1030 
   1031        A new document style can customize Latex/PDF output (see
   1032        @secref["config"]) by redefining the @ltx{SecRefLocal}, @|etc|,
   1033        macros (see @secref["builtin-latex"]). The @ltx{SecRef},
   1034        @|etc|, variants are used in @racket['number] mode.}
   1035 
   1036 ]
   1037 
   1038 If a @racket[link-render-style] @tech{style property} is not attached
   1039 to a @racket[link-element] that refers to a part, a
   1040 @racket[link-render-style] @tech{style property} that is attached to
   1041 an enclosing part is used, since attaching a
   1042 @racket[link-render-style] @tech{style property} to a part causes
   1043 @racket[current-link-render-style] to be set while rendering the part.
   1044 Otherwise, the render-time value of @racket[current-link-render-style]
   1045 determine's a @racket[link-element]'s rendering.
   1046 
   1047 The following style properties are recognized in addition to the style
   1048 properties for all @racket[element]s:
   1049 
   1050 @itemize[
   1051 
   1052  @item{@racket[link-render-style] structure --- As described above.}
   1053 
   1054  @item{@indexed-racket['indirect-link] --- For HTML output, treats the link as
   1055        ``external''. When rendering to HTML and the
   1056        @method[render-mixin set-external-tag-path] method is called to
   1057        provide an external-link URL, then the resolution of the
   1058        hyperlink can be deferred until the link is clicked (or, in
   1059        some cases, patched by JavaScript when the documentation is
   1060        viewed in a browser).}
   1061 
   1062 ]
   1063 
   1064 @history[#:changed "1.26" @elem{Added @racket[link-render-style] support.}]}
   1065 
   1066 
   1067 @defstruct[(index-element element) ([tag tag?]
   1068                                     [plain-seq (and/c pair? (listof string?))]
   1069                                     [entry-seq (listof content?)]
   1070                                     [desc any/c])]{
   1071 
   1072 The @racket[plain-seq] specifies the keys for sorting, where the first
   1073 string is the main key, the second is a sub-key, etc. For
   1074 example, an ``night'' portion of an index might have sub-entries for
   1075 ``night, things that go bump in'' and ``night, defender of the''. The
   1076 former would be represented by @racket[plain-seq] @racket['("night"
   1077 "things that go bump in")], and the latter by @racket['("night"
   1078 "defender of the")]. Naturally, single-string
   1079 @racket[plain-seq] lists are the common case, and at least one word is
   1080 required, but there is no limit to the word-list length. The strings in 
   1081 @racket[plain-seq] must not contain a newline character.
   1082 
   1083 The @racket[entry-seq] list must have the same length as
   1084 @racket[plain-seq]. It provides the form of each key to render in the
   1085 final document.
   1086 
   1087 The @racket[desc] field provides additional information about the
   1088 index entry as supplied by the entry creator. For example, a reference
   1089 to a procedure binding can be recognized when @racket[desc] is an
   1090 instance of @racket[procedure-index-desc]. See
   1091 @racketmodname[scribble/manual-struct] for other typical types of
   1092 @racket[desc] values.
   1093 
   1094 See also @racket[index].}
   1095 
   1096 
   1097 @defstruct[multiarg-element ([style element-style?]
   1098                              [contents (listof content?)])]{
   1099 
   1100 Like @racket[element] with a list for content, except that for Latex
   1101 output, if the @tech{style name} in @racket[style] is a string, then
   1102 it corresponds to a Latex command that accepts as many arguments (each
   1103 in curly braces) as elements of @racket[contents].}
   1104 
   1105 
   1106 @defstruct[traverse-element ([traverse element-traverse-procedure/c])]{
   1107 
   1108 @margin-note*{See also @racket[cond-element] in @racketmodname[scriblib/render-cond].}
   1109 @;
   1110 Like @racket[traverse-block], but the @racket[traverse] procedure must
   1111 eventually produce @tech{content}, rather than a @tech{block}.}
   1112 
   1113 
   1114 @defstruct[delayed-element ([resolve (any/c part? resolve-info? . -> . content?)]
   1115                             [sizer (-> any/c)]
   1116                             [plain (-> any/c)])]{
   1117 
   1118 The @racket[render] procedure's arguments are the same as for
   1119 @racket[delayed-block], but the result is @techlink{content}. 
   1120 Unlike @racket[delayed-block], the
   1121 result of the @racket[render] procedure's argument is remembered on
   1122 the first call for re-use for a particular resolve pass.
   1123 
   1124 The @racket[sizer] field is a procedure that produces a substitute
   1125 @techlink{content} for the delayed element for the purposes of
   1126 determining the delayed element's width (see @racket[element-width]).
   1127 
   1128 The @racket[plain] field is a procedure that produces a substitute
   1129 @techlink{content} when needed before the @techlink{collect pass},
   1130 such as when @racket[element->string] is used before the @tech{collect
   1131 pass}.}
   1132 
   1133 
   1134 @defstruct[part-relative-element ([resolve (collect-info? . -> . content?)]
   1135                                   [sizer (-> any/c)]
   1136                                   [plain (-> any/c)])]{
   1137 
   1138 Similar to @racket[delayed-block], but the replacement
   1139 @techlink{content} is obtained in the @techlink{collect pass} by
   1140 calling the function in the @racket[resolve] field.
   1141 
   1142 The @racket[resolve] function can call @racket[collect-info-parents]
   1143 to obtain a list of @techlink{parts} that enclose the element,
   1144 starting with the nearest enclosing section. Functions like
   1145 @racket[part-collected-info] and @racket[collected-info-number] can
   1146 extract information like the part number.}
   1147 
   1148 
   1149 @defstruct[(collect-element element) ([collect (collect-info . -> . any)])]{
   1150 
   1151 Like @racket[element], but the @racket[collect] procedure is called
   1152 during the @techlink{collect pass}. The @racket[collect] procedure
   1153 normally calls @racket[collect-put!].
   1154 
   1155 Unlike @racket[delayed-element] or @racket[part-relative-element], the
   1156 element remains intact (i.e., it is not replaced) by either the
   1157 @tech{collect pass} or @tech{resolve pass}.}
   1158 
   1159 
   1160 @defstruct[(render-element element) ([render (any/c part? resolve-info? . -> . any)])]{
   1161 
   1162 Like @racket[delayed-element], but the @racket[render] procedure is called
   1163 during the @techlink{render pass}.
   1164 
   1165 If a @racket[render-element] instance is serialized (such as when
   1166 saving collected info), it is reduced to a @racket[element] instance.}
   1167 
   1168 
   1169 @defstruct[collected-info ([number (listof part-number-item?)]
   1170                            [parent (or/c #f part?)]
   1171                            [info any/c])]{
   1172 
   1173 Computed for each part by the @techlink{collect pass}.
   1174 
   1175 The length of the @racket[number] list indicates the section's nesting
   1176 depth. Elements of @racket[number] correspond to the section's number,
   1177 it's parent's number, and so on (that is, the section numbers are in
   1178 reverse order):
   1179 
   1180 @itemlist[
   1181 
   1182  @item{A number value corresponds to a normally numbered
   1183        section.}
   1184 
   1185  @item{A non-empty string corresponds to a @racket['grouper] section,
   1186        which is shown as part of the combined section number only when
   1187        it's the first element.}
   1188 
   1189  @item{A a list corresponds to a @tech{numberer}-generated section
   1190        string plus its separator string, where the separator is used
   1191        in a combined section number after the section string and
   1192        before a subsection's number (or, for some output modes, before
   1193        the title of the section).}
   1194 
   1195  @item{For an unnumbered section, a @racket[#f] is used in place of
   1196        any number or lists element, while @racket[""] is used in place
   1197        of all non-empty strings.}
   1198 
   1199 ]
   1200 
   1201 @history[#:changed "1.1" @elem{Added @racket[(list/c string? string?)]
   1202                                number items for
   1203                                @tech{numberer}-generated section
   1204                                numbers.}]}
   1205 
   1206 
   1207 @defstruct[target-url ([addr path-string?])]{
   1208 
   1209 Used as a @tech{style property} for an @racket[element]. A path is
   1210 allowed for @racket[addr], but a string is interpreted as a URL rather
   1211 than a file path.}
   1212 
   1213 
   1214 @defstruct[document-version ([text (or/c string? #f)])]{
   1215 
   1216 Used as a @tech{style property} for a @racket[part] to indicate a
   1217 version number.}
   1218 
   1219 
   1220 @defstruct[document-date ([text (or/c string? #f)])]{
   1221 
   1222 Used as a @tech{style property} for a @racket[part] to indicate a
   1223 date (which is typically used for Latex output).}
   1224 
   1225 
   1226 @defstruct[color-property ([color (or/c string? (list/c byte? byte? byte?))])]{
   1227 
   1228 Used as a @tech{style property} for an @racket[element] to set its
   1229 color. Recognized string names for @racket[color] depend on the
   1230 renderer, but at the recognized set includes at least
   1231 @racket["white"], @racket["black"], @racket["red"], @racket["green"],
   1232 @racket["blue"], @racket["cyan"], @racket["magenta"], and
   1233 @racket["yellow"]. When @racket[color] is a list of bytes, the values
   1234 are used as RGB levels.
   1235 
   1236 When rendering to HTML, a @racket[color-property] is also recognized
   1237 for a @tech{block}, @racket[part] (and used for the title in the
   1238 latter case)or cell in a @racket[table].}
   1239 
   1240 
   1241 @defstruct[background-color-property ([color (or/c string? (list/c byte? byte? byte?))])]{
   1242 
   1243 Like @racket[color-property], but sets the background color.}
   1244 
   1245 
   1246 @defstruct[table-cells ([styless (listof (listof style?))])]{
   1247 
   1248 Used as a @tech{style property} for a @racket[table] to set its cells'
   1249 styles.
   1250 
   1251 If a cell style has a string name, it is used as an HTML class for the
   1252 @tt{<td>} tag or as a Latex command name.
   1253 
   1254 The following are recognized as cell-@tech{style properties}:
   1255 
   1256 @itemize[
   1257 
   1258  @item{@indexed-racket['left] --- Left-align the cell content.}
   1259 
   1260  @item{@indexed-racket['right] --- Right-align the cell content top baselines.}
   1261 
   1262  @item{@indexed-racket['center] --- Center the cell content horizontally.}
   1263 
   1264  @item{@indexed-racket['top] --- Top-align the cell content.}
   1265 
   1266  @item{@indexed-racket['baseline] --- Align the cell content top baselines.}
   1267 
   1268  @item{@indexed-racket['bottom] --- bottom-align the cell content.}
   1269 
   1270  @item{@indexed-racket['vcenter] --- Center the cell content vertically.}
   1271 
   1272  @item{@indexed-racket['border] --- Draw a line around all sides of the
   1273        cell. Borders along a shared edge of adjacent cells are
   1274        collapsed into a single line.}
   1275 
   1276  @item{@indexed-racket['left-border], @indexed-racket['right-border],
   1277        @indexed-racket['top-border], or @indexed-racket['bottom-border] --- Draw a
   1278        line along the corresponding side of the cell (with the same
   1279        border collapsing as for @racket['border]).}
   1280 
   1281  @item{@racket[color-property] structure --- For HTML, applies a color
   1282        to the cell content.}
   1283 
   1284  @item{@racket[background-color-property] structure --- For HTML,
   1285        applies a color to the background of the cell.}
   1286 
   1287  @item{@racket[attributes] --- Provides additional HTML attributes
   1288        for the cell's @tt{<td>} tag.}
   1289 
   1290 ]
   1291 
   1292 @history[#:changed "1.1" @elem{Added @racket[color-property] and 
   1293                                @racket[background-color-property] support.}
   1294          #:changed "1.4" @elem{Added @racket['border], @racket['left-border],
   1295                                @racket['right-border], @racket['top-border],
   1296                                and @racket['bottom-border] support.}]}
   1297 
   1298 
   1299 @defstruct[table-columns ([styles (listof style?)])]{
   1300 
   1301 Like @racket[table-cells], but with support for a
   1302 @racket[column-attributes] property in each style, and the
   1303 @racket[styles] list is otherwise duplicated for each row in the
   1304 table. The non-@racket[column-attributes] parts of a
   1305 @racket[table-columns] are used only when a @racket[table-cells] property is
   1306 not present along with the @racket[table-columns] property.
   1307 
   1308 For HTML table rendering, for each column that has a
   1309 @racket[column-attributes] property in the corresponding element of
   1310 @racket[styles], the attributes are put into an HTML @tt{col} tag
   1311 within the table.}
   1312 
   1313 
   1314 @deftogether[(
   1315 @defstruct[box-mode ([top-name string?]
   1316                      [center-name string?]
   1317                      [bottom-name string?])]
   1318 @defproc[(box-mode* [name string?]) box-mode?]
   1319 )]{
   1320 
   1321 As a @tech{style property}, indicates that a @tech{nested flow} or
   1322 @tech{paragraph} is @deftech{boxable} when it is used in a
   1323 @deftech{boxing context} for Latex output, but a @tech{nested flow} is
   1324 @tech{boxable} only if its content is also @tech{boxable}.
   1325 
   1326 A @tech{boxing context} starts with a table cell in a multi-column
   1327 table, and the content of a @tech{block} in a @tech{boxing context} is
   1328 also in a @tech{boxing context}. If the cell's content is
   1329 @tech{boxable}, then the content determines the width of the cell,
   1330 otherwise a width is imposed. A @tech{paragraph} with a @racket[#f]
   1331 @tech{style name} is @tech{boxable} as a single line; the
   1332 @racket['wraps] @tech{style name} makes the paragraph
   1333 non-@tech{boxable} so that its width is imposed and its content can
   1334 use multiple lines. A @tech{table} is @tech{boxable} when that all of
   1335 its cell content is boxable.
   1336 
   1337 To generate output in box mode, the @racket[box-mode] property
   1338 supplies Latex macro names to apply to the @tech{nested flow} or
   1339 @tech{paragraph} content. The @racket[top-name] macro is used if the
   1340 box's top line is to be aligned with other boxes, @racket[center-name]
   1341 if the box's center is to be aligned, and @racket[bottom-name] if the
   1342 box's bottom line is to be aligned. The @racket[box-mode*] function
   1343 creates a @racket[box-mode] structure with the same name for all three
   1344 fields.
   1345 
   1346 A @racket[box-mode] @tech{style property} overrides any automatic
   1347 boxed rendering (e.g., for a @tech{paragraph} with @tech{style name}
   1348 @racket[#f]).  If a @tech{block} has both a @racket[box-mode]
   1349 @tech{style property} and a @racket['multicommand] @tech{style
   1350 property}, then the Latex macro @racket[top-name],
   1351 @racket[center-name], or @racket[bottom-name] is applied with a
   1352 separate argument for each of its content.}
   1353 
   1354 
   1355 @defproc[(block? [v any/c]) boolean?]{
   1356 
   1357 Returns @racket[#t] if @racket[v] is a @racket[paragraph],
   1358 @racket[table], @racket[itemization], @racket[nested-flow],
   1359 @racket[traverse-block], or @racket[delayed-block], @racket[#f]
   1360 otherwise.}
   1361 
   1362 
   1363 @defproc[(content? [v any/c]) boolean?]{
   1364 
   1365 Returns @racket[#t] if @racket[v] is a string, symbol,
   1366 @racket[element], @racket[multiarg-element],
   1367 @racket[traverse-element], @racket[delayed-element],
   1368 @racket[part-relative-element], a convertible value in 
   1369 the sense of @racket[convertible?], or list of @tech{content}. 
   1370 Otherwise, it returns @racket[#f].}
   1371 
   1372 
   1373 @defstruct[style ([name (or/c string? symbol? #f)]
   1374                   [properties list?])]{
   1375 
   1376 Represents a @techlink{style}.}
   1377 
   1378 
   1379 @defthing[plain style?]{
   1380 
   1381 A style @racket[(make-style #f null)].}
   1382 
   1383 
   1384 @defproc[(element-style? [v any/c]) boolean?]{
   1385 
   1386 Returns @racket[#t] if @racket[v] is a string, symbol, @racket[#f],
   1387 or @racket[style] structure.}
   1388 
   1389 
   1390 @defproc[(tag? [v any/c]) boolean?]{
   1391 
   1392 Returns @racket[#t] if @racket[v] is acceptable as a link
   1393 @techlink{tag}, which is a list containing a symbol and either a
   1394 string, a @racket[generated-tag] instance, or a non-empty list
   1395 of @racket[serializable?] values.}
   1396 
   1397 
   1398 @defstruct[generated-tag ()]{
   1399 
   1400 A placeholder for a tag to be generated during the @techlink{collect
   1401  pass}. Use @racket[tag-key] to convert a tag containing a
   1402  @racket[generated-tag] instance to one containing a string.
   1403 
   1404 }
   1405 
   1406 
   1407 @defproc*[([(content->string (content content?)) string?]
   1408            [(content->string (content content?) (renderer any/c) (p part?) (info resolve-info?)) string?])]{
   1409 
   1410 Converts @tech{content} to a single string (essentially
   1411 rendering the content as ``plain text'').
   1412 
   1413 If @racket[p] and @racket[info] arguments are not supplied, then a
   1414 pre-``collect'' substitute is obtained for @tech{delayed
   1415 elements}. Otherwise, the two arguments are used to force the
   1416 @tech{delayed element} (if it has not been forced already).}
   1417 
   1418 @defproc[(content-width [c content?]) exact-nonnegative-integer?]{
   1419 
   1420 Returns the width in characters of the given @tech{content}.
   1421 
   1422 }
   1423 
   1424 
   1425 @defproc[(block-width (e block?)) exact-nonnegative-integer?]{
   1426 
   1427 Returns the width in characters of the given @tech{block}.}
   1428 
   1429 
   1430 @defproc[(part-number-item? [v any/c]) boolean]{
   1431 
   1432 Return @racket[#t] if @racket[v] is @racket[#f], an exact non-negative
   1433 integer, a string, or a list containing two strings. See @racket[collected-info]
   1434 for information on how different representations are used for numbering.
   1435 
   1436 @history[#:added "1.1"]}
   1437 
   1438 
   1439 @deftogether[(
   1440 @defproc[(numberer? [v any/c]) boolean?]
   1441 @defproc[(make-numberer [step (any/c (listof part-number-item?)
   1442                                . -> .
   1443                                (values part-number-item? any/c))]
   1444                         [initial-value any/c])
   1445           numberer?]
   1446 @defproc[(numberer-step [n numberer?]
   1447                         [parent-number (listof part-number-item?)]
   1448                         [ci collect-info?]
   1449                         [numberer-values hash?])
   1450          (values part-number-item? hash?)]
   1451 )]{
   1452 
   1453 A @deftech{numberer} implements a representation of a section number
   1454 that increment separately from the default numbering style and that
   1455 can be rendered differently than as Arabic numerals.
   1456 
   1457 The @racket[numberer?] function returns @racket[#t] if @racket[v] is a
   1458 @tech{numberer}, or @racket[#f] otherwise.
   1459 
   1460 The @racket[make-numberer] function creates a @tech{numberer}. The
   1461 @racket[step] function computes both the current number's
   1462 representation and increments the number, where the ``number'' can be
   1463 an arbitrary value; the @racket[initial-value] argument determines the
   1464 initial value of the ``number'', and the @racket[step] function
   1465 receives the current value as its first argument and returns an
   1466 incremented value as its second result. A numberer's ``number'' value
   1467 starts fresh at each new nesting level. In addition to the numberer's
   1468 current value, the @racket[step] function receives the parent
   1469 section's numbering (so that its result can depend on the part's
   1470 nesting depth).
   1471 
   1472 The @racket[numberer-step] function is normally used by a renderer. It
   1473 applies a @tech{numberer}, given the parent section's number, a
   1474 @racket[collect-info] value, and a hash table that accumulates
   1475 @tech{numberer} values at a given nesting layer. The
   1476 @racket[collect-info] argument is needed because a @tech{numberer}'s
   1477 identity is based on a @racket[generated-tag]. The result of
   1478 @racket[numberer-step] is the rendered form of the current section
   1479 number plus an updated hash table with an incremented value for the
   1480 @tech{numberer}.
   1481 
   1482 Typically, the rendered form of a section number (produced by
   1483 @racket[numberer-step]) is a list containing two strings. The first
   1484 string is the part's immediate number, which can be combined with a
   1485 prefix for enclosing parts' numbers. The second string is a separator
   1486 that is placed after the part's number and before a subsection's
   1487 number for each subsection. If @racket[numberer-step] produces a plain
   1488 string for the rendered number, then it is not added as a prefix to
   1489 subsection numbers. See also @racket[collected-info].
   1490 
   1491 @history[#:added "1.1"]}
   1492 
   1493 
   1494 @defstruct[link-render-style ([mode (or/c 'default 'number)])]{
   1495 
   1496 Used as a @tech{style property} for a @racket[part] or a specific
   1497 @racket[link-element] to control the way that a hyperlink is rendered
   1498 for a part via @racket[secref] or for a figure via @racket[figure-ref]
   1499 from @racketmodname[scriblib/figure].
   1500 
   1501 The @racket['default] and @racket['number] modes represent generic
   1502 hyperlink-style configurations that could make sense for various kinds
   1503 of references. The @racket['number] style is intended to mean that a
   1504 specific number is shown for the reference and that only the number is
   1505 hyperlinked. The @racket['default] style is more flexible, allowing a
   1506 more appropriate choice for the rendering context, such as using the
   1507 target section's name for a hyperlink in HTML.
   1508 
   1509 @history[#:added "1.26"]}
   1510 
   1511 
   1512 @defparam[current-link-render-style style link-render-style?]{
   1513 
   1514 A parameter that determines the default rendering style for a section
   1515 link.
   1516 
   1517 When a @racket[part] has a @racket[link-render-style] as one of its
   1518 @tech{style properties}, then the @racket[current-link-render-style]
   1519 parameter is set during the @tech{resolve pass} and @tech{render pass}
   1520 for the @racket[part]'s content.
   1521 
   1522 @history[#:added "1.26"]}
   1523 
   1524 
   1525 @defstruct[collect-info ([fp any/c] [ht any/c] [ext-ht any/c] 
   1526                          [ext-demand (tag? collect-info? . -> . any/c)]
   1527                          [parts any/c] 
   1528                          [tags any/c] [gen-prefix any/c] 
   1529                          [relatives any/c] 
   1530                          [parents (listof part?)])]{
   1531 
   1532 Encapsulates information accumulated (or being accumulated) from the
   1533 @techlink{collect pass}. The fields are exposed, but not currently
   1534 intended for external use, except that @racket[collect-info-parents]
   1535 is intended for external use.
   1536 
   1537 }
   1538 
   1539 @defstruct[resolve-info ([ci any/c] [delays any/c] [undef any/c] [searches any/c])]{
   1540 
   1541 Encapsulates information accumulated (or being accumulated) from the
   1542 @techlink{resolve pass}. The fields are exposed, but not currently
   1543 intended for external use.
   1544 
   1545 }
   1546 
   1547 @defproc[(info-key? [v any/c]) boolean?]{
   1548 
   1549 Returns @racket[#t] if @racket[v] is an @deftech{info key}: a list of
   1550 at least two elements whose first element is a symbol. The result is
   1551 @racket[#f] otherwise.
   1552 
   1553 For a list that is an info tag, the interpretation of the second
   1554 element of the list is effectively determined by the leading symbol,
   1555 which classifies the key. However, a @racket[#f] value as the second
   1556 element has an extra meaning: collected information mapped by such
   1557 info keys is not propagated out of the part where it is collected;
   1558 that is, the information is available within the part and its
   1559 sub-parts, but not in ancestor or sibling parts.
   1560 
   1561 Note that every @techlink{tag} is an info key.
   1562 
   1563 }
   1564 
   1565 @defproc[(collect-put! [ci collect-info?] [key info-key?] [val any/c])
   1566          void?]{
   1567 
   1568 Registers information in @racket[ci]. This procedure should be called
   1569 only during the @techlink{collect pass}.
   1570 
   1571 }
   1572 
   1573 @defproc[(resolve-get [p (or/c part? #f)] [ri resolve-info?] [key info-key?])
   1574          any/c]{
   1575 
   1576 Extract information during the @techlink{resolve pass} or
   1577 @techlink{render pass} for @racket[p] from @racket[ri], where the
   1578 information was previously registered during the @techlink{collect
   1579 pass}. See also @secref["passes"].
   1580 
   1581 The result is @racket[#f] if the no value for the given key is found.
   1582 Furthermore, the search failure is recorded for potential consistency
   1583 reporting, such as when @exec{racket setup} is used to build
   1584 documentation.
   1585 
   1586 }
   1587 
   1588 
   1589 @defproc[(resolve-get/ext? [p (or/c part? #f)] [ri resolve-info?] [key info-key?])
   1590          (values any/c boolean?)]{
   1591 
   1592 Like @racket[resolve-get], but returns a second value to indicate
   1593 whether the resulting information originated from an external source
   1594 (i.e., a different document).}
   1595 
   1596 
   1597 @defproc[(resolve-get/ext-id [p (or/c part? #f)] [ri resolve-info?] [key info-key?])
   1598          (values any/c (or/c boolean? string?))]{
   1599 
   1600 Like @racket[resolve-get/ext?], but the second result can be a string
   1601 to indicate the source document's identification as established via
   1602 @racket[load-xref] and a @racket[#:doc-id] argument.
   1603 
   1604 @history[#:added "1.1"]}
   1605 
   1606 
   1607 @defproc[(resolve-search [dep-key any/c] [p (or/c part? #f)] [ri resolve-info?] [key info-key?])
   1608          void?]{
   1609 
   1610 Like @racket[resolve-get], but a shared @racket[dep-key] groups
   1611 multiple searches as a single request for the purposes of consistency
   1612 reporting and dependency tracking. That is, a single success for the
   1613 same @racket[dep-key] means that all of the failed attempts for the
   1614 same @racket[dep-key] have been satisfied. However, for dependency
   1615 checking, such as when using @exec{racket setup} to re-build
   1616 documentation, all attempts are recorded (in case external changes
   1617 mean that an earlier attempt would succeed next time).
   1618 
   1619 }
   1620 
   1621 @defproc[(resolve-get/tentative [p (or/c part? #f)] [ri resolve-info?] [key info-key?])
   1622          any/c]{
   1623 
   1624 Like @racket[resolve-search], but without dependency tracking. For
   1625 multi-document settings where dependencies are normally tracked, such
   1626 as when using @exec{racket setup} to build documentation, this function
   1627 is suitable for use only for information within a single document.
   1628 
   1629 }
   1630 
   1631 @defproc[(resolve-get-keys [p (or/c part? #f)]
   1632                            [ri resolve-info?] 
   1633                            [pred (info-key? . -> . any/c)])
   1634          list?]{
   1635 
   1636 Applies @racket[pred] to each key mapped for @racket[p] in
   1637 @racket[ri], returning a list of all keys for which @racket[pred]
   1638 returns a true value.
   1639 
   1640 }
   1641 
   1642 @defproc[(part-collected-info [p part?]
   1643                               [ri resolve-info?])
   1644          collected-info?]{
   1645 
   1646 Returns the information collected for @racket[p] as recorded within
   1647 @racket[ri].
   1648 
   1649 }
   1650 
   1651 @defproc[(tag-key [t tag?] [ri resolve-info?]) tag?]{
   1652 
   1653 Converts a @racket[generated-tag] value with @racket[t] to a string.
   1654 
   1655 }
   1656 
   1657 
   1658 @defproc[(traverse-block-block [b traverse-block?]
   1659                                [i (or/c resolve-info? collect-info?)])
   1660          block?]{
   1661 
   1662 Produces the block that replaces @racket[b].}
   1663 
   1664 
   1665 @defproc[(traverse-element-content [e traverse-element?]
   1666                                    [i (or/c resolve-info? collect-info?)])
   1667          content?]{
   1668 
   1669 Produces the content that replaces @racket[e].}
   1670 
   1671 
   1672 @defthing[block-traverse-procedure/c contract?]{
   1673 
   1674 Defined as
   1675 
   1676 @racketblock[
   1677   (recursive-contract
   1678    ((symbol? any/c . -> . any/c)
   1679     (symbol? any/c . -> . any)
   1680     . -> . (or/c block-traverse-procedure/c
   1681                  block?)))
   1682 ]}
   1683 
   1684 @defthing[element-traverse-procedure/c contract?]{
   1685 
   1686 Defined as
   1687 
   1688 @racketblock[
   1689   (recursive-contract
   1690    ((symbol? any/c . -> . any/c)
   1691     (symbol? any/c . -> . any)
   1692     . -> . (or/c element-traverse-procedure/c
   1693                  content?)))
   1694 ]}
   1695 
   1696 @; ----------------------------------------
   1697 
   1698 @section{HTML Style Properties}
   1699 
   1700 @defmodule[scribble/html-properties]{ The
   1701 @racket[scribble/html-properties] library provides datatypes used as
   1702 @tech{style properties} for HTML rendering.}
   1703 
   1704 
   1705 @defstruct[attributes ([assoc (listof (cons/c symbol? string?))])]{
   1706 
   1707 Used as a @tech{style property} to add arbitrary attributes to an HTML
   1708 tag.}
   1709 
   1710 
   1711 @defstruct[alt-tag ([name (and/c string? #rx"^[a-zA-Z0-9]+$")])]{
   1712 
   1713 Use as a @tech{style property} for an @racket[element],
   1714 @racket[paragraph], or @racket[compound-paragraph] to substitute an
   1715 alternate HTML tag (instead of @tt{<span>}, @tt{<p>}, @tt{<div>},
   1716 @|etc|).}
   1717 
   1718 
   1719 @defstruct[column-attributes ([assoc (listof (cons/c symbol? string?))])]{
   1720 
   1721 Used as a @tech{style property} on a style with @racket[table-columns]
   1722 to add arbitrary attributes to an HTML @tt{col} tag within the table.}
   1723 
   1724 
   1725 @defstruct[url-anchor ([name string?])]{
   1726 
   1727 Used as a @tech{style property} with @racket[element] to insert an
   1728 anchor before the element.}
   1729 
   1730 
   1731 @defstruct[hover-property ([text string?])]{
   1732 
   1733 Used as a @tech{style property} with @racket[element] to add text that
   1734 is shown when the mouse hovers over the element.}
   1735 
   1736 
   1737 @defstruct[script-property ([type string?]
   1738                            [script (or/c path-string? (listof string?))])]{
   1739 
   1740 Used as a @tech{style property} with @racket[element] to supply a
   1741 script alternative to the element content.}
   1742 
   1743 
   1744 @defstruct[xexpr-property ([before xexpr/c]
   1745                            [after xexpr/c])]{
   1746 
   1747 Used as a @tech{style property} with @racket[element] to supply literal
   1748 HTML that is rendered before and after element content.
   1749 
   1750 @as-examples["Example:"
   1751 @codeblock[#:keep-lang-line? #t]|{
   1752   #lang scribble/base
   1753   @(require scribble/core
   1754             scribble/html-properties
   1755             (only-in xml cdata))
   1756 
   1757   @(define comments (xexpr-property
   1758                      (cdata #f #f "<!-- before -->")
   1759                      (cdata #f #f "<!-- after -->")))
   1760 
   1761   Here is some
   1762   @elem[#:style (style #f (list comments))]{content with comments around}.
   1763 }|]
   1764 
   1765 @history[#:added "1.27"]}
   1766 
   1767 
   1768 @defstruct[css-addition ([path (or/c path-string? 
   1769                                      (cons/c 'collects (listof bytes?))
   1770                                      url?
   1771                                      bytes?)])]{
   1772 
   1773 Used as a @tech{style property} to supply a CSS file (if @racket[path]
   1774 is a path, string, or list), URL (if @racket[path] is a @racket[url])
   1775 or content (if @racket[path] is a byte string) to be referenced or
   1776 included in the generated HTML. This property can be attached to any
   1777 style, and all additions are collected and lifted to the enclosing
   1778 generated HTML. When the style property is attached to a @tech{part},
   1779 then it is also propagated to any generated HTML for a subpart of the
   1780 part.
   1781 
   1782 The @racket[path] field can be a result of
   1783 @racket[path->main-collects-relative].}
   1784 
   1785 @defstruct[css-style-addition ([path (or/c path-string? 
   1786                                            (cons/c 'collects (listof bytes?))
   1787                                            url?
   1788                                            bytes?)])]{
   1789 
   1790 Like @racket[css-addition], but added after any style files that are
   1791 specified by a document and before any style files that are provided
   1792 externally.}
   1793 
   1794 
   1795 @defstruct[js-addition ([path (or/c path-string? 
   1796                                     (cons/c 'collects (listof bytes?))
   1797                                     url?
   1798                                     bytes?)])]{
   1799 
   1800 Like @racket[css-addition], but for a JavaScript file instead of a CSS file.}
   1801 
   1802 
   1803 @defstruct[js-style-addition ([path (or/c path-string? 
   1804                                           (cons/c 'collects (listof bytes?))
   1805                                           url?
   1806                                           bytes?)])]{
   1807 
   1808 Like @racket[css-style-addition], but for a JavaScript file instead of a CSS file.}
   1809 
   1810 
   1811 @defstruct[body-id ([value string?])]{
   1812 
   1813 Used as a @tech{style property} to associate an @tt{id} attribute with
   1814 an HTML tag within a main @racket[part].}
   1815 
   1816 
   1817 @defstruct[document-source ([module-path module-path?])]{
   1818 
   1819 Used as a @tech{style property} to associate a module path with a
   1820 part.  Clicking on a section title within the part may show
   1821 @racket[module-path] with the part's tag string, so that authors of
   1822 other documents can link to the section.
   1823 
   1824 More specifically, the section title is given the HTML attributes
   1825 @tt{x-source-module} and @tt{x-part-tag}, plus @tt{x-part-prefixes}
   1826 if the section or enclosing sections declare tag prefixes, and
   1827 @tt{x-source-pkg} if the source is found within a package at document-build time. The
   1828 @racketmodname[scribble/manual] style recognizes those tags to make
   1829 clicking a title show cross-reference information.
   1830 
   1831 @history[#:added "1.2"
   1832          #:changed "1.7" @elem{Added @tt{x-part-prefixes}.}
   1833          #:changed "1.9" @elem{Added @tt{x-source-pkg}.}]}
   1834 
   1835 
   1836 @defstruct[html-defaults ([prefix (or/c bytes? path-string? 
   1837                                         (cons/c 'collects (listof bytes?)))]
   1838                           [style (or/c bytes? path-string? 
   1839                                        (cons/c 'collects (listof bytes?)))]
   1840                           [extra-files (listof (or/c path-string? 
   1841                                                      (cons/c 'collects (listof bytes?))))])]{
   1842 
   1843 Like @racket[latex-defaults], but use for the 
   1844 @exec{scribble} command-line tool's @DFlag{html} and
   1845 @DFlag{htmls} modes.}
   1846 
   1847 
   1848 @defstruct[head-extra ([xexpr xexpr/c])]{
   1849 
   1850 For a @racket[part] that corresponds to an HTML page, adds content to
   1851 the @tt{<head>} tag.}
   1852 
   1853 
   1854 @defstruct[head-addition ([xexpr xexpr/c])]{
   1855 
   1856 Like @racket[head-extra] in content, but propagated to enclosing and
   1857 nested HTML pages like @racket[css-addition]. Additions to @tt{<head>}
   1858 via @racket[head-addition] appear before additions via @racket[head-extra].
   1859 
   1860 @history[#:added "1.38"]}
   1861 
   1862 
   1863 @defstruct[render-convertible-as ([types (listof (or/c 'png-bytes 'svg-bytes 'gif-bytes))])]{
   1864  For a @racket[part] that corresponds to an HTML page,
   1865  controls how objects that subscribe to the @racketmodname[file/convertible]
   1866  protocol are rendered.
   1867       
   1868  The alternatives in the @racket[types] field are tried in order
   1869  and the first one that succeeds is used in the html output.
   1870 
   1871  @history[#:changed "1.34" @elem{Added support for  @racket['gif-bytes].}]
   1872 }
   1873 
   1874 @defstruct[part-link-redirect ([url url?])]{
   1875 
   1876 As a @tech{style property} on a @tech{part}, causes hyperiinks to the
   1877 part to be redirected to @racket[url] instead of the rendered part.}
   1878 
   1879 @defstruct[link-resource ([path path-string?])]{
   1880 
   1881 As a @tech{style property} on an @racket[element], causes the elements
   1882 to be rendered as a hyperlink to (a copy of) @racket[path].
   1883 
   1884 The file indicated by @racket[path] is referenced in place when
   1885 @racket[render<%>] is instantiated with
   1886 @racketidfont{refer-to-existing-files} as true. Otherwise, it is
   1887 copied to the destination directory and potentially renamed to avoid
   1888 conflicts.}
   1889 
   1890 
   1891 @defstruct[install-resource ([path path-string?])]{
   1892 
   1893 Like @racket[link-resource], but makes @racket[path] accessible in the
   1894 destination without rendering a hyperlink.
   1895 
   1896 This @tech{style property} is useful only when @racket[render<%>] is
   1897 instantiated with @racketidfont{refer-to-existing-files} as
   1898 @racket[#f], and only when @racket[path] does not match then name of
   1899 any other file that is copied by the renderer to the destination.}
   1900 
   1901 @; ----------------------------------------
   1902 
   1903 @section{Latex Style Properties}
   1904 
   1905 @defmodule[scribble/latex-properties]{ The
   1906 @racket[scribble/latex-properties] library provides datatypes used as
   1907 @tech{style properties} for Latex rendering.}
   1908 
   1909 
   1910 @defstruct[tex-addition ([path (or/c path-string? 
   1911                                      (cons/c 'collects (listof bytes?))
   1912                                      bytes?)])]{
   1913 
   1914 Used as a @tech{style property} to supply a @filepath{.tex} file (if
   1915 @racket[path] is a path, string, or list) or content (if @racket[path]
   1916 is a byte string) to be included in the generated Latex. This property
   1917 can be attached to any style, and all additions are collected to the
   1918 top of the generated Latex file.
   1919 
   1920 The @racket[path] field can be a result of
   1921 @racket[path->main-collects-relative].}
   1922 
   1923 
   1924 @defstruct[latex-defaults ([prefix (or/c bytes? path-string? 
   1925                                          (cons/c 'collects (listof bytes?)))]
   1926                            [style (or/c bytes? path-string? 
   1927                                         (cons/c 'collects (listof bytes?)))]
   1928                            [extra-files (listof (or/c path-string? 
   1929                                                       (cons/c 'collects (listof bytes?))))])]{
   1930 
   1931 Used as a @tech{style property} on the main @racket[part] of a document
   1932 to set a default prefix file, style file, and extra files (see
   1933 @secref["config-style"]).  The defaults are used by the
   1934 @exec{scribble} command-line tool for @DFlag{latex} or @DFlag{pdf}
   1935 mode if none are supplied via @DFlag{prefix} and @DFlag{style} (where
   1936 @racket[extra-files] are used only when @racket[prefix] is used). A
   1937 byte-string value is used directly like file content, and a path can
   1938 be a result of @racket[path->main-collects-relative].
   1939 
   1940 Languages (used with @hash-lang[]) like
   1941 @racketmodname[scribble/manual] and @racketmodname[scribble/sigplan]
   1942 add this property to a document to specify appropriate files for Latex
   1943 rendering.
   1944 
   1945 See also @racketmodname[scribble/latex-prefix].}
   1946 
   1947 @defstruct[(latex-defaults+replacements latex-defaults)
   1948            ([replacements (hash/c string? (or/c bytes? path-string?
   1949                                                 (cons/c 'collects (listof bytes?))))])]{
   1950   Like @racket[latex-defaults] but it allows for more configuration. For example if
   1951   the @racket[replacements] maps @racket["scribble-load-replace.tex"] to @racket["my-scribble.tex"],
   1952   then the @racket["my-scribble.tex"] file in the current directory will we used in place
   1953   of the standard scribble package inclusion header.
   1954 }
   1955 
   1956 
   1957 @defstruct[command-extras ([arguments (listof string?)])]{
   1958 
   1959 Used as a @tech{style property} on an @racket[element] to add extra
   1960 arguments to the element's command in Latex output.}
   1961 
   1962 @defstruct[command-optional ([arguments (listof string?)])]{
   1963                                                   
   1964  Used as a @tech{style property} on a @racket[element] to add
   1965  optional arguments to the element's command in Latex output.
   1966 
   1967  @history[#:added "1.20"]
   1968 }
   1969 
   1970 @defstruct[short-title ([text (or/c string? #f)])]{
   1971                                                   
   1972  Used as a @tech{style property} on a @racket[title-decl].
   1973  Attaches a short title to the title for a @racket[part] if
   1974  the Latex class file uses a short title.
   1975 
   1976  @history[#:added "1.20"]
   1977 }
   1978 
   1979 @defstruct[table-row-skip ([amount string?])]{
   1980 
   1981  Used as a @tech{style property} in @racket[table-cells] to specify a
   1982  spacing adjustment between the cell's row and the row afterward, such
   1983  as @racket["1ex"] to increase the space or @racket["-1ex"] to
   1984  decrease it. If multiple cells on a row provide this property, the
   1985  first one in the row is used.
   1986 
   1987  @history[#:added "1.33"]
   1988 }