Skip to the content.

Fundamental concepts for understanding and using Chalk.

Content Policies

Content policies define what types of content can appear within different sections of elements and documents. Each section (body, detail) can have its own content policy:

Where ContentPolicy is used:

Document Classes

A document class is simply the name/identifier you assign to a document type (e.g., ‘blog-post’, ‘article’, ‘book’). It defines the structure and allowed content for documents of that type. Every library starts with a document definition that specifies:

Elements vs. Primitives

Libraries

Libraries are collections of definitions that tell Chalk how to parse and validate documents:

Result Pattern

Chalk uses a Result pattern for error handling:

interface Result<T, E> {
  ok: boolean;
  data?: T;    // Present when ok: true
  error?: E;   // Present when ok: false
}

This pattern provides explicit error handling without exceptions.

Next Steps