Search by

phore / markdown

dermatthes

Small dependency-free HTML and Markdown converters for PHP.

dev-main 2026-09-09 10:42 UTC

This package is auto-updated.

Last update: 2026-09-09 11:36:56 UTC


README

Small, dependency-free converters for common HTML and Markdown. The package intentionally supports a compact subset and falls back to readable text instead of trying to preserve every formatting detail.

use Phore\Markdown\Markdown;

$markdown = Markdown::fromHtml('<h1>Hello</h1><p>A <strong>small</strong> example.</p>');
$html = Markdown::toHtml("# Hello\n\nA **small** example.");
$text = Markdown::textFromHtml('<p>Hello <em>world</em>.</p>');

HTML input is treated as untrusted. Scripts, styles, forms, iframes, and images are removed during HTML-to-Markdown or text conversion. Markdown-to-HTML escapes raw HTML and accepts links only for http, https, and mailto URLs.

Supported syntax includes level 1–5 headings, paragraphs, line breaks, emphasis, strong text, inline code, links, unordered lists, and blockquotes.

Examples

Run either script after composer install, for example:

php examples/markdown-to-html.php