Skip to main content

Module textstyles

Module textstyles 

Source
Expand description

The textstyles feature: the inline formatting commands \emph, \textbf, \textit and \texttt.

The guide to the language describes these commands for authors (inline formatting).

§What an author writes

Each command takes one mandatory argument, its content, and marks that content with one inline style: \emph{…} is semantic emphasis, \textbf{…} bold weight, \textit{…} italic shape and \texttt{…} a monospaced face. The content is ordinary document content (text, references, mathematics, other formatting commands). A command is inline: it is part of the paragraph it is written in and keeps the whitespace around it. The commands are declared in text mode only; inside mathematics, the math feature declares its own \textbf, \textit and \texttt (see math::text).

§What the feature registers

The textstyles feature (TextStyles, a FlmFeature) registers:

  • the element type TEXT_STYLE (flm.textstyle): the four commands form one family, declared as one element type with one element value per command (elements and aspects): each element value carries a TextStyleElement, whose TextStyle says which style the command applies;
  • the lowering rule RULE (flm.textstyle.lower.default), the default on every backend, and the recomposition rule of latex for the latex-recomposed backend.

TextStyle is the feature’s own list of styles. The presentation elements use a separate list, SpanStyle; the lowering rule converts one into the other (TextStyle::span_style), so that the element never refers to a presentation type.

§What a formatting command becomes on each backend

  • Default rule (RULE, used by the text and html backends): the rule stages (builds into the lowered tree; see Lowerer) a flm.pres.span node whose payload carries the SpanStyle, over the argument lowered through the rules.
  • text backend: it prints the span’s content; the style has no form in plain text and is left out.
  • html backend: it writes the span as the HTML contract states for flm.pres.span (CONVENTIONS): an <em>, <strong>, <i> or <code> element by the style.
  • latex-recomposed backend: the rule of latex writes the command back as the LaTeX macro of the same name.

A backend that has no way to show a style writes the content without it.

§Map of the module

Modules§

latex
The recomposition rule of the textstyles feature for the latex-recomposed backend: each formatting command is written back as the LaTeX macro of the same name.

Structs§

TextStyleElement
The data of one element value of flm.textstyle: the style that the command applies.
TextStyleRule
The body of RULE: it stages a flm.pres.span node whose payload carries the command’s SpanStyle (TextStyle::span_style), over the command’s argument lowered through the rules.
TextStyles
The textstyles feature: it registers the four formatting commands, their default lowering rule and the recomposition rule of latex. See the module documentation.

Enums§

TextStyle
The inline style a formatting command applies: one value per command of the textstyles feature.

Constants§

FEATURE
The feature’s registered name, textstyles.
RULE
The name of the default lowering rule of TEXT_STYLE on every backend, flm.textstyle.lower.default, whose body is TextStyleRule.
TEXT_STYLE
The name of the element type of the four formatting commands, flm.textstyle. The data of each element value is a TextStyleElement.

Functions§

feature
The TextStyles feature as a shared value, ready to be listed in a package entry.