► |  | Scribble: The Racket Documentation Tool

1 | Getting Started
2 | @ Syntax
3 | High-Level Scribble API
4 | Scribbling Documentation
5 | Literate Programming
6 | Low-Level Scribble API
7 | Running scribble
| Index

► | 6 | Low-Level Scribble API

6.1 | Scribble Layers
6.2 | @ Reader Internals
6.3 | Structures And Processing
6.4 | Renderers
6.5 | Decoding Text
6.6 | Document Language
6.7 | Document Reader
6.8 | Cross-Reference Utilities
6.9 | Tag Utilities
6.10 | Blue Boxes Utilities
6.11 | Extending and Configuring Scribble Output

▼ | 6.11 | Extending and Configuring Scribble Output

6.11.1 | Implementing Styles
6.11.2 | Configuring Output
6.11.3 | Base CSS Style Classes
6.11.4 | Manual CSS Style Classes
6.11.5 | Base Latex Macros
6.11.6 | Latex Prefix Support

top ← prev up next →

##### 6.11.1`` Implementing Styles

When a string is used as a style in an element, a multiarg-element, paragraph, table, itemization, nested-flow, or compound-paragraph, it corresponds to a CSS class for HTML output or a Latex macro/environment for Latex output. In Latex output, the string is used as a command name for a paragraph and an environment name for a table, itemization, nested-flow, or compound-paragraph; if the style has a 'command style property for a nested-flow or compound-paragraph, then the style name is used as a command instead of an environment; and if the style has a 'multicommand style property for a nested-flow, then the style name is used as a command with multiple arguments. In addition, for an itemization, the style string is suffixed with "Item" and used as a CSS class or Latex macro name to use for the itemization’s items (in place of \item in the case of Latex).

To add a mapping from your own style name to a CSS configuration, add a css-addition structure instance to a style’s style property list. To map a style name to a Latex macro or environment, add a tex-addition structure instance. A css-addition or tex-addition is normally associated with the style whose name is implemented by the adition, but it can also be added to the style for an enclosing part.

Scribble includes a number of predefined styles that are used by the exports of scribble/base. You can use them or redefine them. The styles are specified by "scribble.css" and "scribble.tex" in the "scribble" collection.

The styles used by scribble/manual are implemented by "racket.css" and "racket.tex" in the "scribble" collection. Other libraries, such as scriblib/autobib, similarly implement styles through files that are associated by css-addition and tex-addition style properties.

To avoid collisions with future additions to Scribble, start your style name with an uppercase letter that is not S. An uppercase letter helps to avoid collisions with macros defined by Latex packages, and future styles needed by scribble/base and scribble/manual will start with S.

For example, a Scribble document

#lang scribble/manual
@(require scribble/core
scribble/html-properties
scribble/latex-properties)
@(define inbox-style
(make-style "InBox"
(list (make-css-addition "inbox.css")
(make-tex-addition "inbox.tex"))))
@title{Quantum Pet}
Do not open: @elem[#:style inbox-style]{Cat}

combined with an "inbox.css" that contains

.InBox {
padding: 0.2em;
border: 1px solid #000000;
}

and an "inbox.tex" that contains

\newcommand{\InBox}[1]{\fbox{#1}}

generates

> Quantum Pet

> Do not open: Cat

Scribble documents can also embed specific html tags and attributes. For example, this Scribble document:

> #lang scribble/base
> @(require scribble/core
> scribble/html-properties)
> @(define external-image
> (elem
> #:style
> (style #f
> (list (alt-tag "img")
> (attributes
> '((src . "http://racket-lang.org/icon.png")))))))
> @external-image

renders as the the Racket logo at the url http://racket-lang.org/logo.png when producing html.

top ← prev up next →