mdx-formatter

Type to search...

to open search from anywhere

You are viewing documentation for an older version. View the latest version

Docusaurus Admonitions

How the formatter preserves Docusaurus admonition syntax

The formatter preserves Docusaurus admonition syntax (:::note, :::tip, :::warning, etc.) intact during formatting. This is controlled by the preserveAdmonitions option.

Without this feature, the ::: syntax would be parsed as regular text and potentially broken by the formatter.

Admonition syntax is preserved as-is. The formatter does not modify content inside admonitions. This works because the formatter’s line-based approach does not modify content it does not specifically target.

Rules

  • Admonition fences (:::) are preserved exactly as written
  • Content inside admonitions is not reformatted
  • Admonition titles (:::tip[Title]) are preserved
  • All Docusaurus admonition types are supported: note, tip, info, warning, danger, caution

Examples

Simple admonition

:::note
This is a note admonition.
:::

Preserved as-is after formatting.

Admonition with title

:::tip[Pro Tip]
This is a professional tip with a custom title.
:::

Preserved as-is after formatting.

Admonition with rich content

:::warning
Be careful with this operation:

- Item 1
- Item 2

```js
dangerousOperation();
```

:::

The entire block is preserved, including nested lists and code blocks.

All admonition types

:::note
Note content
:::

:::tip
Tip content
:::

:::info
Info content
:::

:::warning
Warning content
:::

:::danger
Danger content
:::

:::caution
Caution content
:::

All six types are preserved.

Revision History