Skip to content

Render AsciiDoc admonitions as Markdown alerts - #2111

Open
ggrossetie wants to merge 2 commits into
github:masterfrom
ggrossetie:asciidoc-admonitions-markdown-alerts
Open

ggrossetie wants to merge 2 commits into
github:masterfrom
ggrossetie:asciidoc-admonitions-markdown-alerts

Conversation

@ggrossetie

Copy link
Copy Markdown

Closes #2091

AsciiDoc admonitions (NOTE, TIP, IMPORTANT, WARNING, CAUTION) are currently rendered with Asciidoctor's default HTML5 markup: a bare <table> that github.com doesn't style. This PR renders them with the same markup as Markdown alerts, so they get the markdown-alert* styles GitHub already ships.

NOTE: This is a note.

now renders as:

<div class="markdown-alert markdown-alert-note">
<p class="markdown-alert-title">Note</p>
<p>This is a note.</p>
</div>

Changes

  • Add GitHub::Markup::AsciidoctorConverter, a subclass of Asciidoctor's Html5Converter that overrides only convert_admonition. It keeps the block's id and roles. One-line admonitions are wrapped in <p>; delimited (====) admonitions keep their child blocks.
  • Use a block title (.Title) as the alert title in place of the default label. This matches how comrak renders a Markdown alert with a custom title (> [!TIP] Custom title).
  • Pass the converter through the :converter option. It is not registered with register_for 'html5', so other Asciidoctor conversions in the same process keep the default HTML5 output.
  • Load the converter inside the AsciiDoc render block, so asciidoctor is still only loaded on first use.
  • Add a README.admonitions.adoc fixture covering all five types and the variants (paragraph style, delimited block, id, title, role). Add a unit test that checks the generated classes, since the test pipeline's sanitizer strips them.

Line and branch coverage are still at 100%.

Notes for reviewers

  • The styling only shows up if the sanitizer on github.com keeps the markdown-alert, markdown-alert-<type> and markdown-alert-title classes on div and p in markup output. I can't check that from this repo.
  • Icons aren't included. comrak doesn't emit the octicon SVGs either, so they seem to be added later in the github.com pipeline. If that step also runs on markup output, AsciiDoc admonitions would get their icons with no change here. Otherwise, inline SVGs would probably be stripped by the sanitizer. If there's a supported way to get them (an allow-list, or a post-sanitization filter like the Markdown one), I'm happy to add them.

🤖 Generated with Claude Code

ggrossetie and others added 2 commits October 16, 2026 09:34
Use a custom Asciidoctor HTML5 converter that only overrides
convert_admonition to emit the markdown-alert markup GitHub already
styles for Markdown alerts, instead of an unstyled table.

The converter is passed through the :converter option rather than
registered for the html5 backend, so other Asciidoctor conversions in
the same process are unaffected.

Closes github#2091

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match comrak's rendering of Markdown alerts with a custom title
(`> [!TIP] Custom title`): the block title replaces the default label
in markdown-alert-title instead of being emitted as a separate,
unstyled div.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ggrossetie

Copy link
Copy Markdown
Author

Hi @joelhawksley @zkoppert 👋

This pull request addresses #2091 by rendering AsciiDoc admonitions with the same markup as Markdown alerts, so they pick up the markdown-alert* styles github.com already ships.

The change is self-contained (a small Asciidoctor converter passed via :converter, no global registration) and coverage stays at 100%.

The one thing I can't verify from this repo is whether the github.com sanitizer keeps the markdown-alert, markdown-alert-<type> and markdown-alert-title classes on div/p in markup output. If one of you could check that, or point me to the right person, that would be great. Same for the octicons, happy to adapt if there's a supported way to get them.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render AsciiDoc admonitions with the same style as Markdown alerts (NOTE/TIP/IMPORTANT/WARNING/CAUTION)

1 participant