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.
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 $text->setMarkdown($markdown); // or just $text = new Markdown_Text($markdown); // now you can output html echo $text->getHtml(); // or just echo $text;
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 ); Markdown_Filter::setDefaultFilters($filters); // all transformations now use the custom filter echo new Markdown_Text('**Markdown is great!**'); // you can get current filters set Markdown_Filter::getDefaultFilters();
- PHP >= 5.3