Highlight Text
Colour text, backgrounds, and borders, in every format.
Colouring a word in a Quarto document usually means writing raw HTML, which then disappears from the PDF, the Word file, and the slides. Every format has its own mechanism, and none of them is markdown.
highlight-text gives all of them one syntax. A span or a div carries the colours as attributes, and the filter writes whatever the current format needs: a styled span in HTML, \colorbox in LaTeX, text(fill: ...) in Typst, run properties in Word and PowerPoint.
Installation
quarto add mcanouil/quarto-highlight-text@2.3.1This will install the extension under the _extensions subdirectory. If you are using version control, you will want to check in this directory.
Or install it from your editor with Quarto Wizard:
Quick start
Enable the filter:
filters:
- highlight-textThen colour a span:
[Red text]{fg="#b22222"}
[White on red]{fg="#ffffff" bg="#b22222"}Which renders as Red textRed text and White on redWhite on red.
Or a whole block:
::: {fg="#ffffff" bg="#b22222"}
A block with white text on a red background.
:::A block with white text on a red background.
A block with white text on a red background.
See the Reference for every attribute, and the Examples for each of them rendered.
Where it works
HTML, LaTeX, Typst, Word, PowerPoint, RevealJS, and Beamer.
The filter writes what each format understands, so a document that renders to several of them keeps its colours in all of them. A few features are format-specific, and the Reference says which.
Links
- Reference for every attribute and its format support.
- Examples for rendered output.
- Changelog for what each release changed.
- Source and issues on GitHub.