cebe/markdown
Fast, extensible PHP Markdown parser with classes for multiple flavors (Traditional, GitHub Flavored, and partial Markdown Extra) plus a CLI to convert .md to HTML. Designed for speed, easy customization, and AST-based hooks for extensions.
composer require cebe/markdownuse cebe\markdown\Markdown;
$markdown = new Markdown();
$html = $markdown->parse('# Hello World');
Gfm or Extra classes for specific syntax. Note: GFM now handles inline HTML (e.g., <a> tags) more robustly with URLs/emails:
use cebe\markdown\Gfm;
$html = (new Gfm())->parse("Visit [Google](https://google.com) or email user@example.com");
Markdown or Gfm as a singleton in AppServiceProvider:
$this->app->singleton(\cebe\markdown\Gfm::class, fn() => new \cebe\markdown\Gfm());
$view->with('content', $markdown->parse($post->body_markdown));
Gfm for advanced use cases (e.g., custom [[reference]] syntax). Avoid using [ as the first character in reference names to prevent conflicts:
class CustomGfm extends Gfm {
protected function parseReference($text) { /* Handle [[custom]] syntax */ }
}
HTMLPurifier) due to relaxed inline HTML handling in GFM. The package does not auto-sanitize.league/commonmark.<a> tags) within Markdown. Test edge cases like nested tags or malformed HTML.[ as the first character in custom references (e.g., [[ref]] works, [ref] may conflict). Use [[ for clarity.Visit [Google](https://google.com) or email user@example.com.
composer dump-autoload) if classes fail to load.How can I help you explore Laravel packages today?