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


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

  1. First item
  2. Second item

    1. Nested ordered
    2. Another nested
  3. 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

A note for the reader.
A helpful tip.
Something to be cautious about.
A potential risk or danger.

Code Blocks

Plain fenced block:

No syntax highlighting

With a language:

function greet(name) {
  return `Hello, ${name}!`
}

With a filename:

utils.ts
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

NameTypeRequiredDescription
markdownstringYesContent to render
optionsobjectNoParser options
componentsobjectNoCustom 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

This is an info alert rendered with a custom Alert component.
This is a warning alert with a link.
Task completed successfully.
Something went wrong.

YAML frontmatter props

This alert uses YAML frontmatter for its type prop.

Nested Block Components

Increase fence depth with extra colons (:::, ::::, …) to nest:

Outer info alert.

Nested warning inside the info.

Block Components with Named Slots

Named slots use the #slot-name syntax inside a component block.

This is the default slot content.

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:

This content is inside a 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.