Notice: Uninitialized string offset: 1 in /www/htdocs/w0065fc9/milianw/projects/markdownify/index.php on line 25
Markdownify: The HTML to Markdown converter for PHP

Markdownify: The HTML to Markdown converter for PHP

about Markdownify

What do you gain by using Markdownify?

Markdown is a great way to format texts for the internet. Without much experience an easy to read text is written — without the bloat of HTML tags.

But this comes — like so many things — with a cost: performance will suffer and CPU is wasted since normally Markdown would have to convert your texts to HTML for every page impression. Only some way of caching could prevent this.

That is exactly the point where Markdownify (formerly html2text.php) comes into play: Write texts in Markdown and save them in HTML. You won’t need a copy of the original Markdown input, since Markdownify can convert the saved HTML back to Markdown. And because page impressions are far more often than write actions, this gives you a simple way to increase your page’s performance.

Another benefit for a CMS or similar software is that now only one format of text is saved — HTML. The user can now choose wether to write texts in plain HTML or use a full fledged Wysiwyg editor. And of course he can write in Markdown!

Yeah, but what do I lose?

Technical stuff

Status: Markdownify is currently in beta status. Markdownify_Extra is still missing support for “Markdown in blockelements” and word wrapping is not yet finished. Additionally I hope to gain a few performance boosts by refactoring a few parts.

Markdownify is written in PHP and should work since PHP 4.3. The test cases from MDTest were used as a basis for the “test driven development” (TDD). To convert Markdown to HTML you should use Michel Fortin’s PHP Markdown or PHP Markdown Extra.

How to use Markdownify

It could not be much easier:

<?php
require_once 'markdownify.php';
$md = new Markdownify;
echo $md->parseString($htmlInput);

And yesPHP Markdown Extra is supported by Markdownify!. Just use the Markdownify_Extra class and see tables, definition lists and all that glory stuff get converted.

Optionally you can give some parameters to the class constructor:

License

Markdownify is published under the LGPL, i.e. you can use it freely as in beer and speech. Also using Markdownify in commercial products is allowed. Open Source makes it possible!

Author

Milian Wolff is the brain behind Markdownify. He is 19 years old and currently studying physics in Berlin. He does webdevelopment for years now and his projects get released under open source licenses.

Here are some ways to get in contact with him:

Email:
mail@milianw.de
Jabber:
milianw@amessage.de
MSN:
msn@milianw.de
ICQ:
201408577