gitmyhub

markdown

PHP ★ 38 updated 19d ago

Fast and extensible Markdown in PHP

A fast, extensible Markdown to HTML parser for PHP that adds code highlighting, tables, and frontmatter support.

PHPComposersetup: easycomplexity 2/5

tempest/markdown is a PHP library for converting Markdown text into HTML. Markdown is a simple writing format, you use plain text symbols like number signs for headings and double asterisks for bold, that gets converted to proper web page markup. This library handles that conversion inside PHP applications.

What sets it apart from other PHP Markdown parsers is a focus on speed and low memory use. Rather than using regular expressions, a common but slower pattern matching technique, to process text, it uses a hand written lexer, a step by step scanner that reads the Markdown file character by character and converts it into structured tokens before generating HTML. According to benchmarks included in the repository, this approach uses about 6 megabytes of memory and parses in around 6 milliseconds, compared to the popular league or commonmark library which uses 21 megabytes and takes 57 milliseconds on the same test content.

Beyond speed, the library adds features on top of standard Markdown: syntax highlighted code blocks, tables, div elements for layout and styling, extended markup options, and frontmatter support, frontmatter being a block of structured data at the top of a file, often used to store metadata like titles and dates. You install it via Composer, PHP's standard package manager, and use it with a simple two line API: create a Markdown instance, call parse, and access the resulting HTML or frontmatter fields. The package is still marked as a work in progress.

Where it fits