Docusaurus Admonitions
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.
Rules
- Admonition fences (
:::) are preserved exactly as written - Content inside admonitions is not reformatted
- Admonition titles (
:::tip[Title]) are preserved - Blank lines are added before and after admonition blocks when missing
- All Docusaurus admonition types are supported:
note,tip,info,warning,danger
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.
Blank lines added around admonitions
Before:
Text before
:::note
Note content
:::
Text after
After:
Text before
:::note
Note content
:::
Text after
All admonition types
:::note
Note content
:::
:::tip
Tip content
:::
:::info
Info content
:::
:::warning
Warning content
:::
:::danger
Danger content
:::
All five types are preserved.