3.1 Base Document Format
#lang scribble/base | package: scribble-lib |
Functions provided by this library, such as title and italic, might be called from Racket as
(title #:tag "how-to" "How to Design " (italic "Great") " Programs")
They can also be called with @ notation as
@title[#:tag "how-to"]{How to Design @italic{Great} Programs} |
Although the procedures are mostly designed to be used from @ mode, they are easier to document in Racket mode (partly because we have scribble/manual).
3.1.1 Document Structure
procedure
(title [ #:tag tag #:tag-prefix tag-prefix #:style style #:version vers #:date date] pre-content ...+) → title-decl? tag : (or/c #f string? (listof string?)) = #f tag-prefix : (or/c #f string? module-path?) = #f style : (or/c style? #f string? symbol? (listof symbol?)) = #f vers : (or/c string? #f) = #f date : (or/c string? #f) = #f pre-content : pre-content?
The style argument can be a style structure, or it can be one of the following: a #f that corresponds to a “plain” style, a string that is used as a style name, a symbol that is used as a style property, or a list of symbols to be used as style properties. For information on styles, see part. For example, a style of 'toc causes sub-sections to be generated as separate pages in multi-page HTML output.
The tag-prefix argument is propagated to the generated structure (see Tags). If tag-prefix is a module path, it is converted to a string using module-path-prefix->string.
The vers argument is propagated to the title-decl structure. Use "" as vers to suppress version rendering in the output.
The date argument is propagated to the title-decl structure via a document-date style property. Use "" as date to suppress date rendering in Latex output.
The section title is automatically indexed by decode-part. For the index key, leading whitespace and a leading “A”, “An”, or “The” (followed by more whitespace) is removed.
procedure
(section [ #:tag tag #:tag-prefix tag-prefix #:style style] pre-content ...+) → part-start? tag : (or/c #f string? (listof string?)) = #f tag-prefix : (or/c #f string? module-path?) = #f style : (or/c style? #f string? symbol? (listof symbol?)) = #f pre-content : pre-content?
procedure
(subsection [ #:tag tag #:tag-prefix tag-prefix #:style style] pre-content ...+) → part-start? tag : (or/c #f string? (listof string?)) = #f tag-prefix : (or/c #f string? module-path?) = #f style : (or/c style? #f string? symbol? (listof symbol?)) = #f pre-content : pre-content?
procedure
(subsubsection [ #:tag tag #:tag-prefix tag-prefix #:style style] pre-content ...+) → part-start? tag : (or/c #f string? (listof string?)) = #f tag-prefix : (or/c #f string? module-path?) = #f style : (or/c style? #f string? symbol? (listof symbol?)) = #f pre-content : pre-content?
procedure
(subsubsub*section [ #:tag tag #:tag-prefix tag-prefix #:style style] pre-content ...+) → paragraph? tag : (or/c #f string? (listof string?)) = #f tag-prefix : (or/c #f string? module-path?) = #f style : (or/c style? #f string? symbol? (listof symbol?)) = #f pre-content : pre-content?
syntax
(include-section module-path)
Examples:
@author{Alice P. Racketeer}
procedure
(author+email author-name [ #:obfuscate? obfuscate?]) → element? author-name : content? email : string? obfuscate? : any/c = #f
Note that author+email is not a replacement for author. The author+email function is often used in combination with author.
Examples:
@author[(author+email "Bob T. Scribbler" "bob@racket-lang.org")]
3.1.2 Blocks
procedure
(para [#:style style] pre-content ...) → paragraph?
style : (or/c style? string? symbol? #f) = #f pre-content : pre-content?
The style argument can be a style, #f to indicate a “plain” style, a string that is used as a style name, or a symbol that is used as a style name. (Note that section and para treat symbols differently as style arguments.)
procedure
(nested [#:style style] pre-flow ...) → nested-flow?
style : (or/c style? string? symbol? #f) = #f pre-flow : pre-flow?
The style argument is handled the same as para. The 'inset and 'code-inset styles cause the nested flow to be inset compared to surrounding text, with the latter particularly intended for insetting code. The default style is specified by the output destination (and tends to inset text for HTML output and not inset for Latex output).
procedure
(centered pre-flow ...) → nested-flow?
pre-flow : pre-flow?
procedure
(margin-note pre-flow ... [#:left? left?]) → block?
pre-flow : pre-flow? left? : any/c = #f
If left? is true, then the note is shown on the opposite as it would normally be shown (which is the left-hand side for HTML output). Beware of colliding with output for a table of contents.
procedure
(margin-note* pre-content ... [#:left? left?]) → element?
pre-content : pre-content? left? : any/c = #f
procedure
(itemlist itm ... [#:style style]) → itemization?
itm : items/c style : (or/c style? string? symbol? #f) = #f
The style argument is handled the same as para. The 'ordered style numbers items, instead of just using a bullet.
value
procedure
(tabular cells [ #:style style #:sep sep #:column-properties column-properties #:row-properties row-properties #:cell-properties cell-properties #:sep-properties sep-properties]) → table? cells : (listof (listof (or/c block? content? 'cont))) style : (or/c style? string? symbol? #f) = #f sep : (or/c block? content? #f) = #f column-properties : (listof any/c) = '() row-properties : (listof any/c) = '() cell-properties : (listof (listof any/c)) = '() sep-properties : (or/c list? #f) = #f
Use 'cont in cells as a cell to continue the content of the preceding cell in a row in the space that would otherwise be used for a new cell. A 'cont must not appear as the first cell in a row.
The style argument is handled the same as para. See table for a list of recognized style names and style properties.
The default style places no space between table columns. If sep is not #f, it is inserted as a new column between every column in the table; the new column’s properties are the same as the preceding column’s, unless sep-properties provides a list of style properties to use. When sep would be placed before a 'cont, a 'cont is inserted, instead.
The column-properties, row-properties, and cell-properties arguments specify style properties for the columns and cells of a table; see table-columns and table-cells for a description of recognized properties. The lists do not contain entries for columns potentially introduced for sep, and when non-empty, they are extended as needed to match the table size determined by cells:
If the length of column-properties is less than the length of each row in cells, the last item of the list is duplicated to make the list long enough.
If the length of row-properties is less than the length of cells, the last item of the list is duplicated to make the list long enough.
If the length of cell-properties is less than the number of rows in cells, then the last element is duplicated to make the list long enough. Each list within cell-properties is treated like a column-properties list—
expanded as needed to match the number of columns in each row.
Each element of column-properties or row-properties is either a list of style property values or a non-list element that is wrapped as a list. Similarly, for each list that is an element of cell-properties, the list’s non-list elements are wrapped as nested lists.
If column-properties is non-empty, then its list of property
lists is converted into a table-columns style property
that is added to the style specified by style—
If the style lists for column-properties are both merged with cell-properties and converted to table-columns, then style will contain some redundant information. In that case, column-attributes properties will be used from table-columns, while other properties will be used from the merger into table-cells.
Changed in version 1.1 of package scribble-lib: Added the #:column-properties,
#:row-properties,
and #:cell-properties arguments.
Changed in version 1.12: Changed sep insertion before a
'cont.
Changed in version 1.28: Added sep-properties and made
the preceding column’s properties used
consistently if not specified.
@tabular[#:sep @hspace[1] (list (list "soup" "gazpacho") (list "soup" "tonjiru"))] @tabular[#:style 'boxed #:column-properties '(left right) #:row-properties '(bottom-border ()) (list (list @bold{recipe} @bold{vegetable}) (list "caldo verde" "kale") (list "kinpira gobō" "burdock") (list "makizushi" 'cont))]
Renders like:
soup
gazpacho
soup
tonjiru
recipe
vegetable
caldo verde
kale
kinpira gobō
burdock
makizushi
procedure
indent : exact-nonnegative-integer? = 0 elem : content?
The string elems are not decoded with decode-content, so (verbatim "---") renders with three hyphens instead of an em dash. Beware, however, that reading @verbatim converts @ syntax within the argument, and such reading occurs well before arguments to verbatim are delivered at run-time. To disable simple @ notation within the verbatim argument, verbatim is typically used with |{...}| or similar brackets, like this:
@verbatim|{ |
Use @bold{---} like this... |
}| |
which renders as
Use @bold{---} like this... |
while
@verbatim|{ |
Use |@bold{---} like this... |
}| |
renders as
Use — |
Even with brackets like |{...}|, beware that consistent leading whitespace is removed by the parser; see Alternative Body Syntax for more information.
See also literal.
3.1.3 Text Styles and Content
procedure
pre-content : pre-content? style : (or/c style? string? symbol? #f) = #f
procedure
pre-content : pre-content?
procedure
pre-content : pre-content?
procedure
pre-content : pre-content?
To apply the 'tt style uniformly to all pre-content arguments, use (elem #:style 'tt pre-content ...), instead.
procedure
pre-content : pre-content?
procedure
(superscript pre-content ...) → element?
pre-content : pre-content?
procedure
pre-content : pre-content?
procedure
pre-content : pre-content?
procedure
pre-content : pre-content?
Beware that @ for a literal call performs some processing before delivering arguments to literal. The literal form can be used with |{...}| or similar brackets to disable @ notation within the literal argument, like this:
@literal|{@bold{---}}| |
which renders as
@bold{---} |
See also verbatim.
3.1.4 Images
procedure
(image path [ #:scale scale #:suffixes suffixes #:style style] pre-content ...) → image-element? path : (or/c path-string? (cons/c 'collects (listof bytes?))) scale : real? = 1.0 suffixes : (listof #rx"^[.]") = null style : (or/c style? string? symbol? #f) = #f pre-content : pre-content?
If path is a relative path, it is relative to the current directory, which is set by raco setup to the directory of the main document file. (In general, however, it’s more reliable to express relative paths using define-runtime-path.) Instead of a path or string, the path argument can be a result of path->main-collects-relative.
The scale argument sets the images scale relative to its default size as determined by the content of path. For HTML output, the resulting image-element is rendered with an img or object (for SVG) tag, and scale adjusts the width and height attributes; a class name or other attributes in style can effectively override that size.
The strings in suffixes are filtered to those supported by given renderer, and then the acceptable suffixes are tried in order. The HTML renderer supports ".png", ".gif", and ".svg", while the Latex renderer supports ".png", ".pdf", and ".ps" (but ".ps" works only when converting Latex output to DVI, and ".png" and ".pdf" work only for converting Latex output to PDF).
Note that when the suffixes list is non-empty, then the path argument should not have a suffix.
Changed in version 1.3 of package scribble-lib: Added the #:style argument.
3.1.5 Spacing
procedure
(nonbreaking pre-content ...) → element?
pre-content : pre-content?
procedure
n : exact-nonnegative-integer?
See .__ for an example.
The following example illustrates both ._ and .__:
#lang scribble/base My name is Mr@._ T@.__ I pity the fool who can't typeset punctuation.
3.1.6 Links
procedure
(hyperlink url pre-content ... [ #:underline? underline? #:style style]) → element? url : string? pre-content : pre-content? underline? : any/c = #t
style : (or/c style? string? symbol? #f) = (if underline? #f "plainlink")
procedure
(secref tag [ #:doc module-path #:tag-prefixes prefixes #:underline? underline?] #:link-render-style ref-style) → element? tag : string? module-path : (or/c module-path? #f) = #f prefixes : (or/c (listof string?) #f) = #f underline? : any/c = #t ref-style : (or/c link-render-style? #f)
If #:doc module-path is provided, the tag refers to a tag with a prefix determined by module-path. When raco setup renders documentation, it automatically adds a tag prefix to the document based on the source module. Thus, for example, to refer to a section of the Racket reference, module-path would be '(lib "scribblings/reference/reference.scrbl").
The #:tag-prefixes prefixes argument similarly supports selecting a particular section as determined by a path of tag prefixes. When a #:doc argument is provided, then prefixes should trace a path of tag-prefixed subsections to reach the tag section. When #:doc is not provided, the prefixes path is relative to any enclosing section (i.e., the youngest ancestor that produces a match).
For the result link-element, if ref-style is not #f, then it is attached as a style property and affects the rendering of the link. Alternatively, an enclosing part can have a link-render style that adjusts the rendering style for all links within the part. See link-element for more information about the rendering of section references.
If underline? is #f, then a style is attached to the result link-element so that the hyperlink is rendered in HTML without an underline
In Racket documentation that is rendered to HTML, clicking on a section title normally shows the secref call that is needed to link to the section.
Changed in version 1.25 of package scribble-lib: Added the #:link-render-style argument.
procedure
(Secref tag [ #:doc module-path #:tag-prefixes prefixes #:underline? underline?] #:link-render-style ref-style) → element? tag : string? module-path : (or/c module-path? #f) = #f prefixes : (or/c (listof string?) #f) = #f underline? : any/c = #t ref-style : (or/c link-render-style? #f)
Changed in version 1.25 of package scribble-lib: Added the #:link-render-style argument.
procedure
(seclink tag [ #:doc module-path #:tag-prefixes prefixes #:underline? underline? #:indirect? indirect?] pre-content ...) → element? tag : string? module-path : (or/c module-path? #f) = #f prefixes : (or/c (listof string?) #f) = #f underline? : any/c = #t indirect? : any/c = #f pre-content : pre-content?
In addition to secref’s arguments, seclink supports a indirect? argument. When indirect? is true, then the section hyperlink’s resolution in HTML is potentially delayed; see 'indirect-link for link-element.
procedure
(other-doc module-path [ #:underline? underline? #:indirect indirect]) → element? module-path : module-path? underline? : any/c = #t indirect : (or/c #f content?) = #f
If indirect is not #f, then the link’s resolution in HTML can be delayed, like seclink with #:indirect? #t. The indirect content is prefixed with “the” and suffixed with “documentation” to generate the rendered text of the link. For example:
@other-doc['(lib "parsack/parsack/parsack.scrbl") |
#:indirect "Parsec implementation in Racket"] |
renders as a hyperlink with the text:
the Parsec implementation in Racket documentation |
procedure
t : (or/c taglet? generated-tag?) pre-content : pre-content?
procedure
(elemref t pre-content ... [ #:underline? underline?]) → element? t : (or/c taglet? generated-tag?) pre-content : pre-content? underline? : any/c = #t
3.1.7 Indexing
procedure
(index words pre-content ...) → index-element?
words : (or/c string? (listof string?)) pre-content : pre-content?
Use index when an index entry should point to a specific word or phrase within the typeset document (i.e., the pre-content). Use section-index, instead, to create an index entry that leads to a section, instead of a specific word or phrase within the section.
procedure
(index* words word-contents pre-content ...) → index-element?
words : (listof string?) word-contents : (listof list?) pre-content : pre-content?
procedure
(as-index pre-content ...) → index-element?
pre-content : pre-content?
procedure
(section-index word ...) → part-index-decl?
word : string?
procedure
(index-section [#:tag tag]) → part?
tag : (or/c #f string?) = "doc-index"
3.1.8 Tables of Contents
procedure
procedure
(local-table-of-contents [#:style style]) → delayed-block?
style : (or/c symbol? #f) = #f
The meaning of the style argument depends on the output type, but 'immediate-only normally creates a table of contents that contains only immediate sub-sections of the enclosing section. See also the 'quiet style of part (i.e., in a part structure, not supplied as the style argument to local-table-of-contents), which normally suppresses sub-part entries in a table of contents.
3.1.9 Tags
The exports of scribble/tag are all re-exported by scribble/base.