decent-newsroom / asciidoc-html
A lightweight AsciiDoc to HTML converter for PHP.
0.1.0
2026-08-10 13:09 UTC
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.6
README
A lightweight PHP converter for the most common AsciiDoc blocks and inline markup. It is intended for applications that need predictable HTML output without a full AsciiDoc toolchain.
Requirements
- PHP 8.0 or newer
Installation
composer require decent-newsroom/asciidoc-html
Usage
<?php require __DIR__ . '/vendor/autoload.php'; $converter = new AsciiDocConverter(); $html = $converter->convert(<<<'ASCIIDOC' = A short document == Introduction This is *bold*, this is _italic_, and this is `code`. ASCIIDOC); echo $html;
convert() returns an HTML string. Text, links, image URLs, captions, and
other generated attributes are escaped before being written to the output.
Supported syntax
- Document and section headings (
=,==, and so on) - Paragraphs, basic unordered and ordered list items, and horizontal rules
- Bold, italic, monospace, superscript, subscript, and inline line breaks
- Escaped inline delimiters such as
\*literal\* - Links and images, including image width and alignment attributes
- Audio blocks with optional captions
- Quote and verse blocks with optional author and source attribution
- Source blocks with optional language classes (
[source,php]) - Footnotes (
footnote:[...], named footnotes, andfootnoteref) - Explicit anchors (
[[id]]) and cross-references (<<id,Text>>,xref:id[]) - Literal blocks, sidebars, and NOTE/TIP/WARNING/IMPORTANT/CAUTION admonitions
This is a deliberately small converter, not a complete implementation of the AsciiDoc specification. Unsupported syntax is not guaranteed to produce the same output as Asciidoctor.
Testing
composer install
composer test
License
MIT. See LICENSE.