Typst Support - Content Helpers
These helpers convert semantic Typst content into values suitable for page metadata and themes. Cross-target links are documented separately in Cross Reference.
plain-text(it, limit: none)plain-text(it, limit: none) recursively extracts a plain-text representation from Typst content. Images contribute their alternative text; line and paragraph breaks are preserved; formatting is removed. limitlimit counts Unicode grapheme clusters rather than bytes.
#import "@preview/shiroa:0.4.0": plain-text#let description = plain-text([ A *formatted* introduction with $x^2$.], limit: 160).trim()
#import "@preview/shiroa:0.4.0": plain-text#let description = plain-text([ A *formatted* introduction with $x^2$.], limit: 160).trim()
#import "@preview/shiroa:0.4.0": prepare-description#assert(prepare-description(none) == none)#assert( prepare-description(auto, plain-body: [Hello]) == "Hello",)
#import "@preview/shiroa:0.4.0": prepare-description#assert(prepare-description(none) == none)#assert( prepare-description(auto, plain-body: [Hello]) == "Hello",)
Normalizes a page description for a theme:
nonenonedisables the description.- A string is returned unchanged.
autoautoextracts and trimsplain-bodyplain-body, truncating it tolimitlimitclusters and appending......when the limit is reached.