PHP Markdown / classic version

The classic version of PHP Markdown & Extra is a hybrid library, plugin for Wordpress, for Smarty, and a drop-in replacement for the parser for the Textile text format. It works with PHP 4.0.5 or later. This version is no longer supported since February 1, 2014.

If you’re a developer using PHP 5.3 or later, you should probably use PHP Markdown Lib instead.


PHP Markdown 1.0.2 (27 Kb)
Latest version of PHP Markdown, released on November 29, 2013.
PHP Markdown Extra 1.2.8 (40 Kb)
A special version of PHP Markdown with extra features. See the PHP Markdown Extra description. Released on November 29, 2013.

Participate to the development of this project on Github. PHP Markdown and PHP Markdown Extra are also available as PEAR packages.


PHP Markdown is a port to PHP of the Markdown program written by John Gruber.

“Markdown” is two things: a plain text markup syntax, and a software tool that converts the plain text markup to HTML for publishing on the web.

The Markdown syntax allows you to write text naturally and format it without using HTML tags. More importantly: in Markdown format, your text stays enjoyable to read for a human being, and this is true enough that it makes a Markdown document publishable as-is, as plain text. If you are using text-formatted email, you already know some part of the syntax.

Visit the Concepts page for a short introduction full of examples where you will learn to write with Markdown. If you have some understanding of HTML, you can also read the full documentation of Markdown’s syntax, available on John’s web site.

PHP Markdown can work as a plug-in for WordPress, as a modifier for the Smarty templating engine, or as a remplacement for textile formatting in any software that support textile.

Installation and Requirement

PHP Markdown requires PHP version 4.0.5 or later.


PHP Markdown works with WordPress, version 1.2 or later.

  1. To use PHP Markdown with WordPress, place the “markdown.php” file in the “plugins” folder. This folder is located inside “wp-content” at the root of your site:

    (site home)/wp-content/plugins/
  2. Activate the plugin with the administrative interface of WordPress. In the “Plugins” section you will now find Markdown. To activate the plugin, click on the “Activate” button on the same line than Markdown. Your entries will now be formatted by PHP Markdown.

  3. To post Markdown content, you’ll first have to disable the “visual” editor in the User section of WordPress.

You can configure PHP Markdown to not apply to the comments on your WordPress weblog. See the “Configuration” section below.

Replacing Textile in TextPattern

TextPattern use Textile to format your text. You can replace Textile by Markdown in TextPattern without having to change any code by using the Texitle Compatibility Mode. This may work with other software that expect Textile too.

  1. Rename the “markdown.php” file to “classTextile.php”. This will make PHP Markdown behave as if it was the actual Textile parser.

  2. Replace the “classTextile.php” file TextPattern installed in your web directory. It can be found in the “lib” directory:

    (site home)/textpattern/lib/

Contrary to Textile, Markdown does not convert quotes to curly ones and does not convert multiple hyphens (-- and ---) into en- and em-dashes. If you use PHP Markdown in Textile Compatibility Mode, you can solve this problem by installing the “smartypants.php” file from PHP SmartyPants beside the “classTextile.php” file. The Textile Compatibility Mode function will use SmartyPants automatically without further modification.

In Your Own Programs

You can use PHP Markdown easily in your current PHP program. Simply include the file and then call the Markdown function on the text you want to convert:

include_once "markdown.php";
$my_html = Markdown($my_text);

If you wish to use PHP Markdown with another text filter function built to parse HTML, you should filter the text after the Markdown function call. This is an example with PHP SmartyPants:

$my_html = SmartyPants(Markdown($my_text));

With Smarty

If your program use the Smarty template engine, PHP Markdown can now be used as a modifier for your templates. Rename “markdown.php” to “modifier.markdown.php” and put it in your smarty plugins folder.

If you are using MovableType 3.1 or later, the Smarty plugin folder is located at (MT CGI root)/php/extlib/smarty/plugins. This will allow Markdown to work on dynamic pages.


By default, PHP Markdown produces XHTML output for tags with empty elements. E.g.:

<br />

Markdown can be configured to produce HTML-style tags; e.g.:


To do this, you must edit the “MARKDOWN_EMPTY_ELEMENT_SUFFIX” definition below the “Global default settings” header at the start of the “markdown.php” file.

WordPress-Specific Settings

By default, the Markdown plugin applies to both posts and comments on your WordPress weblog. To deactivate one or the other, edit the MARKDOWN_WP_POSTS or MARKDOWN_WP_COMMENTS definitions under the “WordPress settings” header at the start of the “markdown.php” file.

Updating Markdown in Other Programs

Many web applications now ship with PHP Markdown, or have plugins to perform the conversion to HTML. You can update PHP Markdown — or replace it with PHP Markdown Extra — in many of these programs by swapping the old “markdown.php” file for the new one.

Here is a short non-exhaustive list of some programs and where they hide the “markdown.php” file.

Program Path to Markdown
Pivot (site home)/pivot/includes/markdown/

If you’re unsure if you can do this with your application, ask the developer, or wait for the developer to update his application or plugin with the new version of PHP Markdown.


To file bug reports please send email to:

Please include with your report: (1) the example input; (2) the output you expected; (3) the output PHP Markdown actually produced.

Version History

Extra 1.2.8:


Extra 1.2.7 (11 Apr 2013):

1.0.1q (11 Apr 2013):

Extra 1.2.6 (13 Jan 2013):

1.0.1p (13 Jan 2013):

1.0.1o (8 Jan 2012):

Extra 1.2.5 (8 Jan 2012):

1.0.1n (10 Oct 2009):

Extra 1.2.4 (10 Oct 2009):

Extra 1.2.3 (31 Dec 2008):

Extra 1.2.2 (21 Jun 2008):

1.0.1m (21 Jun 2008):

Extra 1.2.1 (27 May 2008):

Extra 1.2 (11 May 2008):

1.0.1l (11 May 2008):

Extra 1.1.7 (26 Sep 2007):

1.0.1k (26 Sep 2007):

Extra 1.1.6 (4 Sep 2007):

1.0.1j (4 Sep 2007):

Extra 1.1.5 (31 Aug 2007):

1.0.1i (31 Aug 2007):

Extra 1.1.4 (3 Aug 2007):

1.0.1h (3 Aug 2007):

Extra 1.1.3 (3 Jul 2007):

1.0.1g (3 Jul 2007):

Extra 1.1.2 (7 Feb 2007)

1.0.1f (7 Feb 2007):

Extra 1.1.1 (28 Dec 2006)

1.0.1e (28 Dec 2006)

Extra 1.1 (1 Dec 2006)

1.0.1d (1 Dec 2006)

1.0.1c (9 Dec 2005)

1.0.1b (6 Jun 2005)

1.0.1a (15 Apr 2005)

1.0.1 (16 Dec 2004):

  • © 2003–2016 Michel Fortin.