Extension:MarkdownExtraParser

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
MarkdownExtraParser
Release status: beta
Implementation Parser function
Description A quick MediaWiki hook for using a Markdown parser
Author(s) Trevor N. Suarez (Rican7talk)
MediaWiki 1.20+
PHP >= 5.3
Database changes No
License MIT License
Download
README
Parameters
$MarkdownExtraParserOptions
Hooks used
ParserBeforeStrip
InternalParseBeforeSanitize
InternalParseBeforeLinks
Translate the MarkdownExtraParser extension if it is available at translatewiki.net
Check usage and version matrix.

The MarkdownExtraParser extension allows for hooking MediaWiki's parser to use Michael Fortin's PHP Markdown Extra library.

It works additional to the out of box Mediawiki Markup spec beside some conflicts.

Download[edit]

Clone the GitHub repo or download the zip

Installation[edit]

  1. Create a folder in your "$IP/extensions" directory called "MarkdownExtraParser"
    Note: $IP is your MediaWiki install directory
    You should have something like this: $IP/extensions/MarkdownExtraParser/
  2. Clone the GitHub repo into your new directory (or download the zip)
  3. Download Michael Fortin's PHP Markdown Extra library
  4. Extract and copy the "markdown.php" file into your new "$IP/extensions/MarkdownExtraParser/" directory
  5. Enable the extension by adding the following line to your "LocalSettings.php" file:
    require_once "$IP/extensions/MarkdownExtraParser/MarkdownExtraParser.php";
    

Configuration[edit]

Before "requiring" the extension, you can set an array variable to hold some configuration settings for MarkdownExtraParser, like so:

// MarkdownExtraParser
$MarkdownExtraParserOptions = array(
    'use_raw_html' => true,
);
Available Options
  • 'use_raw_html' - Allows for more advanced markdown-to-HTML conversions, such as image tags, etc.

Conflicts[edit]

You can mix MediaWiki markup (wikitext) and Markdown markup except for some logical and programmatical tags:

disfunctions:

  • If you want an [edit section] link, you have to use MediaWiki headings (== Heading ==)
  • Magic words (like __TOC__, __NOEDITSECTION__) are not supported

notes:

  • # are used in MediaWiki as numbered lists, but with Markdown you will get a heading
  • In Markdown Extra, three or more tilde characters (~) denote a codeblock. However, Mediawiki uses the same Syntax for Signatures. With this plugin, all codeblocks created this way will start and end with a signature of the person creating the codeblock.
  • MediaWiki Definition list ; defines terms : description will only work inline. Not with a newline before :.
  • does not work in Templates, there you have to use still MediaWiki markup

Differences[edit]

Next to the different but mostly more usable syntax from markdown, there are several differences regarding MediaWiki-Syntax:

  • Markdown has no internal links and images. So you can use [[MediaWiki]] and [[File:Markdown-mark.svg]]. Only the order of title in titled links like [[MediaWiki|Mainpage]] is inverted to Markdown[Mainpage](https://www.mediawiki.org/wiki/MediaWiki).
  • Extension:Cite which creates references as footnotes on a page (used <ref>lorem ipsum itigur</ref>) is not needed. Markdown Extra has built in footnotes ([^book] and [^book]: lorem ipsum itigur). You don't have to mess up your continuous text with the long content. You can shift it to the bottom of paragraph or page, sense and purpose of a footnote.

See also[edit]