commonmark/cmark
Fast, standards-compliant C implementation of CommonMark Markdown. Parse Markdown to an AST and render to HTML (and other formats) with a stable API, full spec test coverage, and high performance—ideal for embedding in apps, CLIs, and tooling.
Start by installing the package via Composer: composer require commonmark/cmark. Since this is a PHP extension binding, ensure the cmark extension is installed and enabled in your PHP environment (e.g., via pecl install cmark or your OS package manager). Verify installation with php -m | grep cmark.
The most immediate use case is rendering Markdown to HTML:
$parser = new \Cmark\Parser();
$ast = $parser->parseFile('README.md');
$html = \Cmark\Renderer::renderHtml($ast);
Check the examples/ directory in the repository for minimal working demos.
\Cmark\Renderer to inject behavior like syntax highlighting, link rewriting, or access control (e.g., strip ![]() for unauthenticated users).cmark) for shell scripts or build processes (e.g., cmark README.md > output.html).Cmark\ParserInterface and Cmark\RendererInterface to leverage auto-wiring.cmark C library and PHP extension—both must be installed separately. Without them, Composer installs succeed but runtime fails with class not found or undefined symbol errors.Parser::parseString() after editing the source Markdown.cmark versions.cmark library supports extension modules (e.g., tables, task lists). Register them via Parser::parseWithExtensions() and ensure the cmark build includes them.\Cmark\Renderer::renderCommonMark($ast) to output normalized CommonMark as a sanity check—great for diffing expected vs actual behavior.How can I help you explore Laravel packages today?