Skip to content

Heading [[heading: SyntaxConcept]]SyntaxConcept

Description [[description: text]]text

All headings in QMD.md follow a unified syntax with optional components. Headings create objects and define document structure.

QMDC parses these Markdown constructs:

  • Headings (# through ###### and beyond) create objects
  • [[id]] in a heading defines the object identifier
  • [[id: Kind]] adds a type
  • [[:Kind]] auto-generates ID from Title and adds a type
  • Title text (without [[...]]) is stored in __label

Position of [[id]] in the heading does not matter: ## Title [[id]], ## [[id]] Title, and ## Title [[id]] More all produce the same ID.

Syntax [[syntax: text]]text

Basic heading forms:

# Title
# Title [[id]]
# Title [[id: Kind]]
# Title [[:Kind]]
# [[id]] Title
# [[id: Kind]] Title

Components (all optional):

  • Title β€” human-readable text, stored in __label
  • [[id]] β€” object/field identifier
  • [[id: Kind]] β€” identifier with type
  • [[:Kind]] β€” auto-generated ID with type

Auto ID Generation [[auto_id: text]]text

When [[id]] is not specified, the ID is auto-generated from Title.

Algorithm:

  1. Take the Title text (excluding [[...]] parts)
  2. Convert to lowercase
  3. Replace non-alphanumeric characters with a single space
  4. Collapse consecutive spaces into one
  5. Replace spaces with _
  6. Strip leading and trailing _
  7. If it starts with a digit, prepend _

Examples:

Title Auto-generated ID
Configuration configuration
John Doe john_doe
My Team #1 my_team_1
API Service api_service
2024 Report _2024_report

Kinds [[kinds: text]]text

Built-in kinds (lowercase) β€” parser hints:

  • text β€” multiline text field
  • object β€” nested object
  • array β€” object array
  • yaml β€” embedded YAML block
  • json β€” embedded JSON block
  • map β€” flat string dictionary (strβ†’str)

System kinds (prefixed with __) β€” created automatically by the parser:

  • __Document β€” document container
  • __TextBlock β€” unstructured text block
  • __Object β€” object without explicit Kind
  • __Workspace β€” workspace root
  • __Namespace β€” namespace grouping

User kinds (PascalCase) β€” from schemas:

  • User, Stage, Config β€” object types for validation
  • [User], [Stage] β€” array of typed objects

Filtering system types: objects.filter(obj => !obj.__kind?.startsWith("__"))

Nesting Levels [[nesting_levels: text]]text

Heading levels H1–H6 and beyond (unlimited # count). Nesting is relative β€” a child element is one level below its parent.

Note: Standard Markdown supports only H1–H6. QMD.md extends this by allowing arbitrary # counts for deep nesting (H7, H8, etc.).

Rules [[rules: text]]text

  • Each heading may contain at most one [[...]] definition. Multiple definitions (## Title [[a: array]] [[b: Kind]]) produce a multiple_definitions error.
  • If [[id]] is not specified and the heading has no fields, it becomes a __TextBlock (not an object).
  • If [[id]] is not specified but the heading has fields or heading-syntax children, the ID is auto-generated from Title.
  • __has_explicit_id: false is set when the ID was auto-generated (absent when explicit).
  • __level records the heading level (1–6+) for lossless rebuild.