Comark Syntax Showcase
All syntax features supported by Comark, from standard CommonMark to Comark-specific extensions.
Headings
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Text Formatting
Bold and also bold
Italic and also italic
Bold and italic together
Strikethrough
Inline code
Links
A plain link, a link with title, and a link with attributes.
Lists
Unordered
- Item one
Item two
- Nested item
Another nested item
- Deep nested
- Item three
Ordered
- First item
Second item
- Nested ordered
- Another nested
- Third item
Task list
- Completed task
- Pending task
- Another done
- Yet to do
Blockquotes
A simple blockquote.
Blockquotes support formatting and can span multiple lines.
Nested blockquotes work too.
Alert Blockquotes
Code Blocks
Plain fenced block:
No syntax highlightingWith a language:
function greet(name) {
return `Hello, ${name}!`
}With a filename:
export function add(a: number, b: number): number {
return a + b
}With line highlighting:
print("Line 1 — highlighted")
print("Line 2 — not highlighted")
print("Line 3 — highlighted")
print("Line 4 — highlighted")
print("Line 5 — highlighted")Tables
| Name | Type | Required | Description |
|---|---|---|---|
markdown | string | Yes | Content to render |
options | object | No | Parser options |
components | object | No | Custom component map |
Span Attributes
Apply classes and attributes to any inline content:
Highlighted span
Custom styled span
Bold with class: Important notice
Link with attributes: Open in new tab
Block Components
Block components are declared with ::name and closed with ::.
Props can be passed inline or as YAML frontmatter.
Inline props
Alert component.YAML frontmatter props
type prop.Nested Block Components
Increase fence depth with extra colons (:::, ::::, …) to nest:
Outer info alert.
Block Components with Named Slots
Named slots use the #slot-name syntax inside a component block.
Inline Components
Inline components are prefixed with a single colon.
Plain:
With label: hello
With props: hello
Slot Unwrap — <slot unwrap="div" />
ProseUnwrapDiv renders <slot unwrap="div" />.
The wrapping div is stripped, and its children are rendered directly:
div with inline styles — but the div itself is removed by the unwrap slot.Frontmatter
Documents can declare YAML frontmatter at the top (before any content):
---
title: My Document
description: A short description
tags:
- markdown
- comark
published: true
---Access frontmatter via tree.frontmatter when using the MarkdownDocument component.
Comments
HTML comments are parsed and ignored by the renderer:
Text before the comment and text after the comment both render normally.