4.4 Racket
The
scribble/racket library (or
scribble/scheme
for backward compatibility) provides utilities for typesetting Racket
code. The
scribble/manual forms provide a higher-level
interface.
The supplied typeset-expr expression should produce a
procedure that performs the actual typesetting. This expression is
normally to-element or to-paragraph. The argument
supplied to typeset-expr is normally a syntax object, but
more generally it is the result of applying d->s-expr.
The optional uncode-id specifies the default escape from
literal code to be recognized by id, and the default for
uncode-id is unsyntax. A use of the id form
can specify an alternate escape via #:escape, as in
racketblock and racket.
The optional d->s-expr should produce a procedure that
accepts three arguments suitable for datum->syntax: a syntax
object or #f, an arbitrary value, and a vector for a source
location. The result should record as much or as little of the
argument information as needed by typeset-expr to typeset the
code. Normally, d->s-expr is datum->syntax.
The stx-prop-expr should produce a procedure for recording a
'paren-shape property when the source expression uses with
id has such a property. The default is
syntax-property.
Typesets an S-expression that is represented by a syntax object, where
source-location information in the syntax object controls the
generated layout.
Identifiers that have for-label bindings are typeset and
hyperlinked based on definitions declared elsewhere (via
defproc, defform, etc.). The identifiers
code:line, code:comment,
code:blank, code:hilite, and
code:quote are handled as in racketblock, as
are identifiers that start with _.
In addition, the given v can contain var-id,
shaped-parens, just-context, or
literal-syntax structures to be typeset specially (see each
structure type for details), or it can contain element
structures that are used directly in the output.
If expr? is true, then v is rendered in expression
style, much like print with the print-as-expression
parameter set to #t. In that case, for-label
bindings on identifiers are ignored, since the identifiers are all
quoted in the output. Typically, expr? is set to true for
printing result values.
If color? is #f, then the output is typeset without
coloring.
The wrap-elem procedure is applied to each element
constructed for the resulting block. When combined with #f
for color?, for example, the wrap-elem procedure can
be used to give a style to an element.
Like
to-paragraph, but
prefix1 is prefixed onto the
first line,
prefix is prefix to any subsequent line, and
suffix is added to the end. The
prefix1,
prefix, and
suffix arguments are used as
content, except that if
suffix is a list of elements,
it is added to the end on its own line.
Like
to-paragraph, except that source-location information is
mostly ignored, since the result is meant to be inlined into a
paragraph.
Like
to-element, but
for-syntax bindings are
ignored, and the generated text is uncolored. This variant is
typically used to typeset results.
When
to-paragraph and variants encounter a
var-id
structure, it is typeset as
sym in the variable font, like
racketvarfont—
unless the
var-id appears under
quote or quasiquote, in which case
sym is typeset as a symbol.
When
to-paragraph and variants encounter a
shaped-parens structure, it is typeset like a syntax object
that has a
'paren-shape property with value
shape.
When
to-paragraph and variants encounter a
long-boolean structure, it is typeset as
#true or
#false,
as opposed to
#t or
#f.
When
to-paragraph and variants encounter a
just-context structure, it is typeset using the
source-location information of
val just the lexical context
of
ctx.
When
to-paragraph and variants encounter a
literal-syntax structure, it is typeset as the string form of
stx. This can be used to typeset a syntax-object value in the
way that the default printer would represent the value.
Styles that are used for coloring Racket programs, results, and I/O.