Rich text fields
A rich text field holds paragraphs and, if you allow them, headings, lists, links, images, tables, quotes, callouts, code and video. Its look comes from one class map.
A rich text field holds formatted text. Paragraphs, bold, italic and line breaks are always on. Everything else is a tool you turn on by naming it as a modifier:
<article>{{ body:rich:headings:lists:links:images:quotes }}</article>
The editor's toolbar shows only the tools the field allows, and Verso checks every save against them. Text pasted from a word processor or a web page is cleaned to fit: a pasted <h1> becomes the nearest heading the field allows, or a paragraph when it allows none.
Tools
| Modifier | Adds | Elements |
|---|---|---|
headings | Three levels of heading. Type ##, ### or #### and a space | h2 h3 h4 |
lists | Bulleted and numbered lists. Type - or 1. and a space | ul ol li |
links | Links to pages, sites, email and phone numbers | a |
images | Images with a caption and alt text | figure img figcaption |
tables | Tables, with rows and columns added from the toolbar | table tr th td |
quotes | Block quotes. Type > and a space | blockquote |
callouts | A set-apart note, like the one at the end of this page | aside |
embeds | YouTube and Vimeo videos | figure iframe figcaption |
code | Inline code and code blocks | code pre |
Add required to refuse publishing while the field is empty. A field with only an image or a video in it counts as filled.
Images and video
Drop an image file into the field, or use the image button, and it becomes a figure with a caption. The file is copied into the page's own folder and stored by its name. Click an image to write its alt text. When the site is built, every image gets its width and height, lazy loading and, for wide JPEGs and PNGs, smaller copies with a srcset.
For video, paste a YouTube or Vimeo link on an empty line, or use the video button. Any form of link works: a watch page, a short link or a Shorts address. Verso stores one canonical address, using YouTube's privacy-enhanced domain, and the video loads lazily. Other sites can't be embedded.
Code
With code on, press ⌘E (Ctrl+E) or wrap text in backticks for inline code. For a block, type three backticks and a space. Add a language name after the backticks, like ```js, and it is kept as data-lang on the <code> element for a highlighter to read. In a block, Tab indents, Enter stays inside, and ⌘Enter (Ctrl+Enter) leaves. Whitespace in a code block is kept exactly.
How it is stored
Each rich text field is its own file beside page.json, named after the field: body.html for {{ body:rich }}. The file is clean HTML with bare tags and no classes, one top-level element per line, so a git diff shows exactly which paragraph changed.
<p>We cook what the market has. In April that means <em>asparagus</em>.</p>
<h2>The menu</h2>
<figure><img src="asparagus.jpg" alt="Asparagus on a board"><figcaption>First of the season.</figcaption></figure>
When a field is emptied, its file is removed. Only the attributes a tool needs are kept: href on links, src and alt on images, colspan and rowspan on table cells, and data-lang on code.
The class map
Because the stored HTML has no classes, its look comes from one place: "rich" in verso.json. It gives each element its Elevate classes, and Verso adds them as the page is rendered. You can write it by hand, or set it in the Design panel's Text tab, which picks each style from your tokens and saves it here.
{
"name": "Northlight",
"rich": {
"p": "text:ink-2:relaxed mg-b:d4",
"h2": "font:h4:semibold mg-t:d8 mg-b:d3",
"a": "text:accent:underline",
"code": "font:mono pd-x:d1 bg-color:paper-2 bd:round-d1",
"pre": "pd:d4 bg-color:paper-2 overflow-x:auto",
"pre code": "font:mono",
"aside": "pd:d4 bg-color:accent-soft bd:round-d3"
}
}
Elevate checks and compiles these classes like any other, so a typo stops the build with the element named. The map can style p, strong, em and every element the tools add. One map serves every rich text field on the site; a field can't have a map of its own.
code styles inline code. "pre code" styles the code inside a code block, so a block doesn't pick up inline code's background and padding. Without it, code blocks use code too.
Rules
A rich text field needs an element to itself, with nothing else inside it:
<div class="col gap:d4">{{ body:rich:lists }}</div>
Writing it next to other text or inside an attribute stops with “A rich text field needs an element to itself.” In a list, {{ item.body }} shows another page's rich text with the class map applied. In an attribute, the same reference gives its plain text, which is handy for a title or a meta tag.