Skip to main content

Reference

Every prefix the prism extension recognises.

The complete prism behaviour: the attribute syntax, which prefix matches which format, the group alias, the default fallback, and the precedence between them.

Enabling the filter

filters:
  - prism

Syntax

An attribute key is format:name, and its value is used as name when format matches.

The attribute forms.
Pattern Behaviour
format:name="…" Becomes name="…" when format matches the active format; dropped otherwise.
slide:name="…" Becomes name="…" under revealjs, slidy, s5, dzslides, and slideous.
default:name="…" Used only when no format-specific variant of name matched.
name="…" Passed through unchanged, unless a higher-ranked entry sets the same name.
.class Untouched.
#identifier Untouched.

It applies to divs, spans, headings, and code blocks.

Which prefix matches which format

The prefix is matched exactly against the format Quarto is targeting and against its base format, both resolved through quarto.format.format_identifier().

Format names and their prefixes.
Active format Matching prefix
html html:
revealjs revealjs:
typst typst:
pdf pdf:
latex, when the target is .tex rather than PDF latex:
beamer beamer:
docx docx:
pptx pptx:
A custom format, say mcanouil-typst mcanouil-typst: and typst:
Important

A custom format also matches the prefix of its base format. Under mcanouil-typst, both mcanouil-typst: and typst: match, and mcanouil-typst: wins when both name the same attribute. The reverse is not true: under typst, mcanouil-typst: does not match. The slide alias also applies to a custom format based on a slide format, for example foo-revealjs.

The same holds for pdf and latex, which are two Quarto formats over one writer: format: pdf matches pdf: alone, and latex: matches only when the target is latex, the format that stops at .tex.

Note

Pandoc’s Typst writer reads typst:-prefixed attributes of its own, and prism leaves those alone in a Typst render rather than promoting them.

On a div, typst:text:<property> becomes #set text(<property>: …) and typst:<parameter> becomes an argument to #block(), for the thirteen parameters Typst’s block() accepts: width, height, breakable, fill, stroke, radius, inset, outset, spacing, above, below, clip, and sticky. On a span only typst:text:<property> is read, wrapping the content in #text(…). Those reach the writer untouched, so the two namespaces coexist on one element.

The writer reads nothing on a code block or a heading, and no single-level key on a span, so prism promotes those as it always has. The Typst property output reference is the authority on what it reads.

Any other typst: key is prism’s, because the writer splices it into #block() unvalidated and Typst then rejects it: typst:style on its own fails the render with unexpected argument: style. Prefixing it hands it to prism, which strips the prefix so that Quarto’s own CSS translation picks it up:

::: {typst:style="color: rgb(0,0,255);" typst:text:size="20pt"}
Blue and large in Typst output alone.
:::

color, background-color, font-family, font-size, font-weight, and font-style are the properties Quarto carries across to Typst.

Outside a Typst render a typst: key is dropped as any other non-matching prefix is.

Precedence

For one attribute name on one element:

How a value is chosen.
Rank Source Example
1 An exact format match. html:style under html.
2 A base format match. html:style under atelier-html.
3 A group alias. slide:style under revealjs.
4 The default: fallback. default:style.
5 An unprefixed attribute. style.

Two entries of the same rank for the same name, two html:style keys for instance, resolve to the last one written.

An unprefixed attribute is dropped when anything higher-ranked resolves to the same name, so an element never carries the same attribute twice and Pandoc never warns about it.

Promoted attributes are written after the unprefixed ones that survive, in the order their target names first appeared.

Options

extensions:
  prism:
    warn-on-drop: true
Document and project options.
Option Type Default Description
warn-on-drop boolean false Warn each time a format-scoped attribute is dropped because nothing matched.
Caution

A prefix is known when it is the target format name, its base format, a group alias, or default. Anything else is treated as a format that is not active, and the attribute is dropped in silence.

That is deliberate, since a format of that name would resolve it later, but it also hides a typo such as revaeljs:style. warn-on-drop is how you find those:

(W) [prism] Dropped attribute(s) 'revaeljs:style' on #mybox because no prefix matched target format 'revealjs'.

Limitations

  • The prefix must match the target format name or its base format exactly; there is no partial matching. A built-in format is its own base format, so html: never matches revealjs.
  • slide is the only group alias.
  • An unknown prefix is indistinguishable from an inactive format, which is why warn-on-drop exists.
  • On a div, a typst: key naming a block() parameter belongs to Pandoc, so typst:width sets a block width rather than promoting a width attribute. There is no way to promote it instead, and none is needed: the writer drops a plain attribute, so a promoted width would reach no consumer.
Back to top