Extension:MarkdownSyntax

The MarkdownSyntax enables markdown syntax. Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

For previous version of PHP Markdown to 1.4.1

 * 1) Create a folder in your $IP/extensions directory called MarkdownSyntax.
 * Note: $IP is your MediaWiki install dir.
 * You have something like this: $IP/extensions/MarkdownSyntax/
 * 1) Download Michel Fortin's PHP Markdown, unzip and look for the file markdown.php.
 * Note: Don't download PHP Markdown Extra. Only PHP Markdown is supported. PHP Markdown Extra may be supported in a future release
 * 1) Drop markdown.php into $IP/extensions/MarkdownSyntax/
 * 2) Copy the MarkdownSyntax.php source below and save it as MarkdownSyntax.php. Drop it into $IP/extensions/MarkdownSyntax/</tt> also.
 * 3) Enable the extension by adding this line to your LocalSettings.php</tt>: require_once( "$IP/extensions/MarkdownSyntax/MarkdownSyntax.php" );

For PHP Markdown version 1.4.1+

 * 1) Create a folder in your $IP/extensions</tt> directory called MarkdownSyntax</tt>.
 * Note: $IP</tt> is your MediaWiki install dir.
 * You have something like this: $IP/extensions/MarkdownSyntax/</tt>
 * 1) Download Michel Fortin's PHP Markdown, unzip the php files into your new MarkdownSyntax dir.
 * Note: Don't download PHP Markdown Extra. Only PHP Markdown is supported. PHP Markdown Extra may be supported in a future release
 * 1) Copy the MarkdownSyntax.php source below and save it as MarkdownSyntax.php</tt>.
 * 2) Change this line: require_once("markdown.php");
 * 3) to this: require_once('Michelf/Markdown.inc.php');
 * 4) Change this line: $text = Markdown($text);
 * 5) to this $text = Michelf\Markdown::defaultTransform($text);
 * 6) Drop it into $IP/extensions/MarkdownSyntax/</tt> also.
 * 7) Enable the extension by adding this line to your LocalSettings.php</tt>: require_once( "$IP/extensions/MarkdownSyntax/MarkdownSyntax.php" );

Developer notes

 * Thanks to Ian Smith for his suggestion to use UsenetSyntax as a model for this extension. Thanks to Jim R. Wilson (Jimbojw) for writing UsenetSyntax.
 * Thanks to Thomas Peri (via New Orleans 2600) for tons of help with v0.2, especially writing the parsing URLs and converting them to MediaWiki URLs.

Limitations

 * 1) Markdown links: Link titles are not supported because MediaWiki links don't support them.
 * i.e. [an example](http://example.com/ "Title") becomes <a href="http://example.com/">an example</a>, not <a href="http://example.com/" title="Title">an example</a>.

Bugs
// To fix the in the title problem, detect if the text consists only of a single // paragraph and remove the tags $multi_par_pattern = "/^ .* /i"; $par_pattern = "/^ (.*)<\/p>\n?$/i"; if (! preg_match($multi_par_pattern, $text)) { $text = preg_replace($par_pattern, '$1', $text); }
 * 1) Markdown's code blocks and spans are a little buggy
 * 2) Huy: There's an easy fix for the code block problem: edit markdown.php and change
 * 3) some   around the title tag
 * 4) Huy: Here's how I fixed that:  I added the code to the end of wfProcessMarkdownSyntax before the return statement

More Testing Needed

 * Does anyone know how these Markdown tests (written in perl) could be executed somehow on a MediaWiki with this extension installed?

Todo List

 * Create a Mediawiki toolbar replacement with Markdown versions of the existing commands. Show how to add it.
 * Consider using Control.TextArea. It can format in Markdown syntax.
 * Try PHP Markdown Extra and see if it's features work.

Code

 * MarkdownSyntax.php