Markdown implementaion for PHP (object-oriented)
Pull request Compare This branch is 170 commits behind maxtsepkov:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

What is Markdown?

Markdown is a text-to-HTML conversion tool for web writers. It is intended to be as easy-to-read and easy-to-write as is feasible.

Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

See official website for syntax.

What is markdown-oo-php?

It's an object-oriented PHP library capable of converting markdown text to XHTML.

Quick start

Library has two entities: Text and Filter Text represents a piece of text which can be both markdown and html. Filter is responsible for actual transformation.

In most cases, Text is enough for simple usage.

require_once 'Markdown/Text.php';

// create an instance
$text = new Markdown_Text();

// set plaintext

// or just
$text = new Markdown_Text($markdown);

// now you can output html
echo $text->getHtml();

// or just
echo $text;

Advanced usage

Internally, Filter uses a set of filters which extends Markdown_Filter. A filter is an object which can accept markdown text and return html. You can write your own filters and use like this:

$filters = array(
    'Linebreak',            // a built-in filter
    new MyCustomFilter(),   // child of Markdown_Filter

// all transformations now use the custom filter
echo new Markdown_Text('**Markdown is great!**');

// you can get current filters set


  • PHP >= 5.3


  1. Fork me
  2. Mail me