Syntax

Attributes

Add custom classes, IDs, styles, and data attributes to native Markdown elements using the curly brace syntax.

Comark allows adding custom attributes to native Markdown elements using {...} syntax after the element.

Element Attributes

Strong/Bold

**bold text**{.highlight #important}
**bold text**{data-value="custom"}
**bold text**{bool}

Italic/Emphasis

*italic text*{.emphasized}
_italic text_{#custom-id}
[Link text](url){target="_blank" rel="noopener"}
[Link text](url){.button .primary}
[External](https://example.com){target="_blank" .external-link}

Images

![Alt text](image.png){.responsive width="800" height="600"}
![Logo](logo.svg){.logo #site-logo}

Inline Code

`code snippet`{.language-js}
`variable`{data-type="string"}

Attribute Types Summary

SyntaxOutputDescription
{bool}:bool="true"Boolean attribute
{#my-id}id="my-id"ID attribute
{.my-class}class="my-class"Class attribute
{key="value"}key="value"Key-value attribute
{:data='{"key": "val"}'}data={"key": "val"}JSON object attribute

Span Attributes

Wrap inline text in a <span> element with custom attributes. This is useful for styling specific parts of text or adding metadata without creating custom components.

Syntax

[text content]{attributes}

The text goes in square brackets [...] followed by attributes in curly braces {...}.

Examples

Class:

This is [highlighted text]{.highlight} in a paragraph.

Multiple classes:

[Important]{.badge .primary} information here.

ID:

Reference this [specific text]{#ref-1} later.

Inline styles:

[Blue text]{style="color: blue; font-weight: bold"}

Data attributes:

[Earth]{data-planet="earth" data-type="terrestrial"}

Combined attributes:

[Status: Active]{#status .badge .success data-state="active"}

Common Use Cases

  1. Styling with utility classes:
    [Warning]{.text-red-500 .font-bold}: System maintenance in progress.
    
  2. Adding tooltips:
    Hover over [this text]{title="Additional information"} for more details.
    
  3. Adding metadata for JavaScript:
    Click [here]{data-action="open-modal" data-target="login"} to sign in.
    
  4. Accessibility attributes:
    [Important]{role="alert" aria-label="Critical notice"} security update available.
    

Nested Markdown

Span syntax supports nested markdown formatting:

[**Bold** and *italic* text]{.highlight}

AST

For this span:

[Hello world]{.greeting style="color: blue"}

The AST nodes are:

[
  "span",
  {
    "class": "greeting",
    "style": "color: blue"
  },
  "Hello world"
]
Spans work within any paragraph or inline context, and support all standard HTML attributes. For block-level customization, use Components instead.

Next Steps

Copyright © 2026