Quarto Extension
The prism filter lets a single Div, Span, or CodeBlock carry conditional attributes: each output format picks its own values from format-prefixed keys, so the same prose or code can be styled differently in HTML, revealjs, and Typst without duplication.
Attributes are keyed format:name="value". At render time, attributes whose format matches the active output are re-emitted as name="value"; the rest are dropped. Unprefixed attributes pass through unchanged.
Prism matches each prefix against the target format of the current render, resolved from quarto.format.format_identifier()["target-format"]. Matching is exact, so html: targets HTML output without affecting revealjs.
This document is rendered to three formats:
| Active format | Matching prefix |
|---|---|
html |
html: |
revealjs |
revealjs: |
typst |
typst: |
Each prefix is independent: html:style is applied only under HTML, revealjs:style only under revealjs, and typst:fill only under Typst. The unprefixed note attribute is preserved everywhere.
This paragraph is pink in HTML, blue in revealjs, and unstyled in Typst.
A format-scoped attribute overrides a static attribute of the same name. Under HTML the html: value wins; under revealjs the revealjs: value wins; under Typst no prefix matches, so the static gray is kept.
This paragraph reads as purple in HTML, green in revealjs, and gray in Typst.
Inline content carries format-scoped attributes the same way.
The next sentence styles a single span only under the matching format.
CodeBlocks accept the same syntax.
Prefixes that do not resolve to the active target format are removed entirely. The next Div carries only revealjs: and typst: attributes; under HTML it therefore renders as plain content with no style attribute.
Plain content in HTML; styled in revealjs and Typst.
The slide alias matches every HTML slide format: revealjs, slidy, s5, dzslides, and slideous. A single slide: prefix targets the whole group, so the next Div is styled under revealjs without naming each slide format. Under HTML and Typst no slide format is active, so the slide: value is dropped.
Styled under any HTML slide format; plain in HTML and Typst.
An exact format prefix wins over the slide alias for the same attribute name. Under revealjs the revealjs: value applies; under any other slide format the slide: value would apply instead.
Crimson under revealjs, teal under the other slide formats.
A default:name prefix provides a fallback value, applied only when no format-specific variant of the same name matched the active format. Under HTML the html: value wins; under revealjs and Typst no specific variant matches, so the default: value is used.
Purple under HTML, gray under revealjs and Typst.