Skip to main content

Opshell Docusaurus Admonitions

Overview

Version 0.1.3 by Opshell. Registers a custom Gutenberg block opshell/admonition that renders Docusaurus-inspired admonition (callout) boxes. Also provides automatic raw content conversion for ::: syntax used outside the block editor.

Admonition Types

TypeIconDefault TitleCSS Class
noteDocument icon (default)Noteopshell-admonition--note
tipLightbulb iconTipopshell-admonition--tip
infoInfo circle iconInfoopshell-admonition--info
warningWarning triangle iconWarningopshell-admonition--warning
dangerDanger triangle iconDangeropshell-admonition--danger

Block Attributes

AttributeTypeDefaultDescription
typestringnoteAdmonition type: note, tip, info, warning, danger
titlestring""Custom title (falls back to capitalized type name)

Features

1. Gutenberg Block

Registered as opshell/admonition with:

  • Editor script at assets/js/editor.js
  • Block style at assets/css/admonitions.css
  • Editor style at assets/css/editor.css

2. Raw Content Conversion

Two regex-based conversion passes run on the_content filter at priority 8:

HTML block pattern: Converts ::: syntax wrapped in <p> tags:

<p>:::tip Custom title
Body content
:::</p>

Fenced block pattern: Converts standalone ::: fences:

:::warning
Warning body text
:::

3. Render Output

Each admonition renders as an <aside> element with:

  • Badge icon (SVG inline)
  • Title paragraph
  • Body content broken into <p> elements

Output Structure

<aside class="wp-block-opshell-admonition opshell-admonition opshell-admonition--tip">
<div class="opshell-admonition__badge" aria-hidden="true"><!-- SVG icon --></div>
<div class="opshell-admonition__body">
<p class="opshell-admonition__title">Tip</p>
<p>Body content here</p>
</div>
</aside>

CSS Architecture

FilePurpose
assets/css/admonitions.cssFrontend block styles
assets/css/editor.cssBlock editor overrides

Styles are enqueued automatically when blocks are present or when ::: syntax is detected in post content.

Usage

In the Block Editor: Search for "Admonition" or "Opshell" in the block inserter. Choose the type and optional custom title.

In Raw Markdown/Classic Editor: Use :::type Title syntax:

:::info[Important]
This is an important message with **formatting** support.
:::

Allowed types: note, tip, info, warning, danger.