PHP Markdown Lib

It’s time for PHP Markdown to become a mature well-packaged PHP library instead of a hybrid file that tries to be everything for everyone.

Today, I’m announcing the Lib branch of PHP Markdown. It contains the two exact same parsers found in PHP Markdown and PHP Markdown Extra, but without all the cruft. It is packaged to be used as a library, and only as a library. The two parsers classes are in the Michelf namespace:


Yep, a namespace, so it requires PHP 5.3 or later.

The Lib branch is PSR-0 compliant to allow autoloading of its parser classes. It’s also a Composer package made available on Packagist.

Three Branches

So, right now there are three branches of PHP Markdown. Here’s a summary of each:

PHP Markdown
The original PHP Markdown is the one implementing the Markdown syntax specification. It includes a global Markdown function, a parser class, as well as various plugin interfaces for Wordpress, Smarty, for replacing the Textile parser.
PHP Markdown Extra
The Extra branch has been added quite a while ago to extend the core Markdown syntax with other useful things. It’s implemented as a second parser class derived from the PHP Markdown parser’s, and packaged exactly the same way in a single file with the various plugin interfaces.
PHP Markdown Lib
The Lib branch is a new one aimed at being a modern PHP library people can use to integrate in various things. Contrary to the other two, it does not contain any plugin code. It requires PHP 5.3 or later because it makes use of namespaces.

PHP Markdown Lib starts at version 1.3. I wanted to start over at 1.0, but that’d have made bug reports about a specific version of PHP Markdown harder to understand (people often don’t say or know which branch they’re using), hence why there’s a separate version number.

Moving forward

Next year, in 2014, only the Lib branch will continue to be updated.

The original PHP Markdown and PHP Markdown Extra distributions will continue to be available on the classic version page, but starting next year updates containing bug fixes and new Extra features will go exclusively to the Lib branch.

If like many of you you’ve been using PHP Markdown as a Wordpress plugin, you can still continue to rely on it, it is unlikely to stop working anytime soon. The reality however is that I do not have the time to keep improving things for Wordpress as it evolves. Time passed, and now many other plugins based on PHP Markdown but with better integration have appeared. I do not have a recommendation to make at this time, but feel free to let me know if you have one as I might write a follow-up on that topic.

Ditching support for older versions of PHP will simplify the maintenance work and will enable usage of newer PHP constructs in the code. Getting rid of the Wordpress plugin part will let me worry about things which are more related to the parser side of things.

It’s time for PHP Markdown to become a mature well-packaged PHP library instead of the strange hybrid it has been for many years. Therfore, starting today, the Lib version now takes the front row on the updated PHP Markdown webpage. Let me know if you have any question.

  • © 2003–2022 Michel Fortin.