Skip to content

tempestphp/markdown

Repository files navigation

Fast and extensible Markdown in PHP

tempest/markdown is a Markdown parser written in PHP. It's designed to be fast and extensible, and has a bunch of additional features built-in like code highlighting, table and div support, extended markup, and frontmatter support.

Important

This package is still a work in progress! Feel free to open issues.

Quickstart

composer require tempest/markdown

Render Markdown like this:

use Tempest\Markdown\Markdown;

$markdown = new Markdown();

$parsed = $markdown->parse(file_get_contents('README.md'));

echo $parsed->frontMatter['title'];
echo $parsed->html;

You can read more in the docs.

Performance

This package began as a challenge to make a more performant Markdown parser in pure PHP. The primary performance gain is from not relying on regex but instead using a simple lexer to tokenize Markdown files and convert them to HTML.

Benchmarks are included in this repo and can be run with composer bench after installing all dev dependencies. Here are the results on my machine for rendering the full Tempest docs:

Package Memory Time to parse
tempest/markdown 5.944mb 6.281ms
league/commonmark 21.114mb 56.993ms
michelf/php-markdown 7.343mb 23.215ms
erusev/parsedown-extra 8.485mb 15.163ms

About

Fast and extensible Markdown in PHP

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages