Palette Format Reference
Palette Format Reference
Authoring
Palettes are authored as JSON or YAML files. JSON is the canonical interchange format and what the schema, app, and site consume at runtime. YAML is an authoring convenience — it is parsed, validated, and normalized through the exact same core path as JSON, and the CLI can convert YAML to canonical JSON for commit or pipeline use.
Recommended workflow
Author in YAML (less syntax, no commas).
Convert to JSON before committing:
chromaril convert my-palette.palette.yaml --to json --output my-palette.palette.jsonOr let the pipeline handle conversion automatically.
JSON example (canonical)
{
"chromaril": "1.0",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Ocean Breeze",
"slug": "ocean-breeze",
"colors": [
{ "name": "Deep Sea", "hex": "#1A3A5C" },
{ "name": "Seafoam", "hex": "#5DAFEC" },
{ "name": "Sandy Shore", "hex": "#F5E6CC" }
]
}
YAML example (equivalent)
chromaril: "1.0"
id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
name: "Ocean Breeze"
slug: "ocean-breeze"
colors:
- name: "Deep Sea"
hex: "#1A3A5C"
- name: "Seafoam"
hex: "#5DAFEC"
- name: "Sandy Shore"
hex: "#F5E6CC"
Both produce identical output when validated and normalized.
Embedded views
Palettes may declare embedded views (type: "embedded") with either
format: "html" or format: "svg". The content field carries raw
HTML or SVG markup authored by the palette creator.
Security contract for consumers
Embedded view content is untrusted input. Palette documents arrive
via user import (editor-persistence), shared files, and third-party
sources. A palette author may include arbitrary markup — including
<script> tags, event handlers, or other executable surfaces — inside
an embedded view’s content field.
Consumers of palette documents MUST sanitize embedded view content before injecting it into the DOM. The Chromaril web app implements this contract in two layers:
| View format | Rendering strategy | Rationale |
|---|---|---|
svg | <img> tag with a data:image/svg+xml,… data URI | Browsers do not execute script inside <img>-loaded SVGs — no sanitizer needed. |
html | Sanitize with DOMPurify (allowlist: structural/text elements + inline styles; strip event handlers, <script>, <iframe>, javascript: URLs), then bind via v-html. | DOMPurify is the industry-standard HTML sanitizer; the allowlist is documented in sanitize.ts. |
Implementation reference
- Sanitization utility:
www/app.chromaril.ca/src/services/sanitize.ts - Embedded view rendering:
DetailView.vue(seesafeEmbeddedViews) - Renderer escaping:
packages/chromaril-renderer/src/index.ts(seeescapeXml)
Standard views
Standard views (type: "standard") are rendered server-side by the
@chromaril/renderer package. All palette-derived text fields (color
names, hex values, palette name) are escaped with escapeXml before
interpolation into SVG templates. The renderer produces well-formed
XML even for hostile inputs containing <, >, &, ", and '.