Chapter 80

The Render Theme CSS reference

A Render Theme is CSS. It styles Preview, HTML, PDF, image and print output, and the Word styles listed at the end of this chapter. A Render Theme may be a single .css file or part of a ZIP package with local assets. Syntax profiles define how source text becomes the document; Render Themes only style the result. CSS never styles the app or the editor; that is the Application Theme (Chapter 79).

The cascade#

Pilcrow applies styles in this order:

  1. Pilcrow's structural reset;
  2. the selected theme CSS;
  3. one-off CSS from the export panel (Advanced options ▸ Custom CSS);
  4. required print and rendering corrections.

Later rules win according to the normal CSS cascade. Theme JavaScript, remote resources, file: URLs and @import are not supported.

Resources#

Pilcrow reads theme CSS with a standard CSS tokenizer, so escapes are decoded before anything is checked: u\72 l(…) is a url() and @im\70 ort is an @import. Every place a browser would load from is checked: url(…), url("…"), src("…"), and strings inside image-set(). Each must be one of:

  • a package-relative path (fonts/Body.woff2, ./paper.png). A ?query or #fragment is allowed and ignored when the file is looked up;
  • a data: URL of type PNG, JPEG, GIF, WebP, SVG (image/svg+xml), TTF, OTF, WOFF or WOFF2;
  • a fragment reference such as url(#shadow), which names an element in the page.

Anything with a scheme other than data: (https:, file:, blob:) or starting with // is refused, as is a path that starts with / or contains ...

Render properties#

The built-in reset reads these properties, and supplies fallbacks:

GroupProperties
Colour--pt-background, --pt-foreground, --pt-secondary-background, --pt-secondary-foreground, --pt-accent, --pt-link-color, --pt-border-color
Code--pt-code-background, --pt-code-foreground, --pt-code-keyword, --pt-code-string, --pt-code-number, --pt-code-comment
Type--pt-body-font-family, --pt-mono-font-family, --pt-base-font-size, --pt-line-height
Spacing--pt-paragraph-spacing, --pt-blockquote-indent, --pt-list-indent, --pt-code-padding, --pt-heading-top, --pt-heading-bottom
Tables--pt-table-header-background, --pt-table-stripe-background
Alerts--pt-admonition-note-color, --pt-admonition-tip-color, --pt-admonition-important-color, --pt-admonition-warning-color, --pt-admonition-caution-color

Public element classes#

These fixed classes are public:

pt-document pt-heading pt-paragraph pt-blockquote pt-thematic-break
pt-list pt-list-item pt-code-block pt-code pt-literal-block pt-html-block
pt-raw-block pt-text pt-line-break pt-soft-break pt-emphasis pt-strong
pt-link pt-image pt-html-inline pt-raw-inline pt-table pt-table-section
pt-table-row pt-table-cell pt-definition-list pt-definition-item
pt-definition-term pt-definition-description pt-footnote-reference
pt-footnote-definition pt-admonition pt-sidebar pt-example pt-details
pt-strikethrough pt-underline pt-mark pt-superscript pt-subscript
pt-abbreviation pt-insertion pt-deletion pt-substitution pt-keyboard
pt-sample-output pt-variable pt-math-block pt-math-inline pt-citation
pt-bibliography-entry pt-cross-reference pt-anchor pt-index-term pt-video
pt-audio pt-figure pt-diagram pt-metadata-block pt-attribute-definition
pt-title-block pt-include pt-conditional pt-macro pt-comment
pt-table-of-contents

Public modifiers include pt-heading-1 through pt-heading-6, pt-list--ordered, pt-list--unordered, pt-definition-list--side-by-side, pt-code-block--wrap, pt-code-block--numbered, the five standard pt-admonition--* values, and parameterized classes for language, raw format, math notation, diagram format, table-section type, conditional type and macro name. Parameterized suffixes come from the active syntax profile or document and must be CSS-escaped when they contain punctuation.

Pilcrow may add classes and attributes in an update. Avoid selectors that depend on undocumented wrapper depth, generated IDs, or the absence of additional classes.

A minimal theme#

:root {
  color-scheme: light;
  --pt-background: #ffffff;
  --pt-foreground: #202124;
  --pt-secondary-background: #f5f6f7;
  --pt-secondary-foreground: #5f6368;
  --pt-accent: #0b57d0;
  --pt-link-color: var(--pt-accent);
  --pt-border-color: #dadce0;
  --pt-code-background: #f1f3f4;
  --pt-code-foreground: #202124;
  --pt-body-font-family: system-ui, -apple-system, sans-serif;
  --pt-mono-font-family: ui-monospace, "SF Mono", monospace;
  --pt-base-font-size: 16px;
  --pt-line-height: 1.6;
}

.pt-document { max-width: 72ch; }
.pt-heading-1 { letter-spacing: -0.025em; }

ZIP packages#

A ZIP package can hold Render Themes (.css) and Application Themes (.json) together; each is listed with its own kind in Settings. A ZIP with at most one CSS file and at most one Application Theme needs no manifest. Anything more needs pilcrow-theme.json, which lists every theme under variants[].file. The file's extension decides its kind:

{
  "id": "com.example.paper",
  "name": "Paper",
  "version": "1.0.0",
  "author": "Example Author",
  "license": "MIT",
  "cssAPIVersion": 1,
  "variants": [
    { "id": "app", "name": "Paper", "file": "Paper.json", "appearance": "automatic" },
    { "id": "light", "name": "Paper Light", "file": "Paper-Light.css", "appearance": "light" },
    { "id": "dark", "name": "Paper Dark", "file": "Paper-Dark.css", "appearance": "dark" }
  ]
}

The manifest describes the package and its themes. It never contains style values: those are in the CSS and Application Theme files.

  • The package id names the install folder. It must not start with . or have leading or trailing spaces. Installing a package whose id is already installed replaces it.
  • A ZIP made with Finder's Compress works as is. Pilcrow skips __MACOSX/, ._*, .DS_Store and Thumbs.db, and when every file sits inside one top-level folder, that folder is treated as the package root.
  • Deleting one theme removes it from the package and keeps the others along with the shared assets. Deleting the last theme removes the package. A deleted theme that was selected returns that selection to its kind's default: Automatic for the Application Theme, Light for the Render Theme.
  • CSS may reference packaged PNG, JPEG, GIF, WebP, TTF, OTF, WOFF and WOFF2 files with relative url(...) paths. Pilcrow verifies their signatures and embeds referenced assets as data URLs so rendering and exported HTML remain offline and self-contained. ZIP paths cannot escape the package, collide by case, or point to links. Archive size, entry count, individual size and compression ratio are bounded.

Word#

Word export uses the light (base) :root values and maps these semantic properties into named Word styles: --pt-foreground, --pt-background, --pt-accent, --pt-link-color, --pt-code-background, --pt-code-foreground, --pt-body-font-family, --pt-mono-font-family, --pt-base-font-size and --pt-line-height. Browser selectors and layout rules have no general Word equivalent. Preview, HTML, PDF and image output use the complete stylesheet; Word uses this subset while preserving document structure, diagrams, math pictures, links and media. The export panel shows this limitation whenever Word is selected.

Pilcrow includes two Render Themes, Light and Dark, which are complete starting points.