Extension:AlternateSyntaxParser

From MediaWiki.org
Jump to: navigation, search

Other languages:
Deutsch • ‎English • ‎British English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil
MediaWiki extensions manual
Crystal Clear action run.png
AlternateSyntaxParser

Release status: unmaintained

Implementation Extended syntax
Description Provides ability to use alternate syntax engines (such as Markdown and Textile) instead of the standard wikitext parser.
Author(s) Jim R. Wilson (Jimbojwtalk)
Latest version 0.1 (2007-06-03)
MediaWiki 1.6.x, 1.9.x, 1.10.x or higher
Database changes No
License The MIT License
Download AlternateSyntaxParser.php
Hooks used
ParserBeforeStrip

ParserBeforeTidy

Translate the AlternateSyntaxParser extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The AlternateSyntaxParser Extension provides the ability to use alternate syntax engines (such as Markdown and Textile) instead of the standard wikitext parser.

This can be done on a page-by-page basis, or by setting a site-wide default.

Project Homepage
AlternateSyntaxParser Extension - Jimbojw.com
Source Code
AlternateSyntaxParser.php
Licensing
AlternateSyntaxParser is released under The MIT License.

Installation[edit | edit source]

  1. Create a folder in your $IP/extensions directory called AlternateSyntaxParser.
    Note: $IP is your MediaWiki install dir.
  2. Download AlternateSyntaxParser, and be sure to rename the downloaded file to AlternateSyntaxParser.php.
  3. Drop this script in $IP/extensions/AlternateSyntaxParser/
  4. Enable the extension by adding this line to your LocalSettings.php:
require_once('extensions/AlternateSyntaxParser/AlternateSyntaxParser.php');
$wgEnableParserCache = false;
  1. Download the required libraries for chosen alternate syntaxes as specified below
    Note: If you don't download the libraries, the extension won't work!

Configuration (optional)

If you'd like to specify a site-wide default alternate syntax, set the $wgAlternateSyntaxParserLanguage global variable to the chosen language in your LocalSettings.php file. For example, to set Markdown as the site-wide default, you'd put:

$wgAlternateSyntaxParserLanguage = 'markdown';

Markdown[edit | edit source]

To support Markdown syntax you must:

  1. Download Michel Fortin's PHP Markdown or PHP Markdown Extra library (either one):
    http://www.michelf.com/projects/php-markdown/
  2. Extract the file 'markdown.php' from the zip archive.
  3. Drop markdown.php into $IP/extensions/AlternateSyntaxParser/

Textile[edit | edit source]

To support Textile syntax you must:

  1. Download Textpattern's TextilePHP library:
    https://code.google.com/p/textpattern/source/browse/releases/4.3.0/source/textpattern/lib/classTextile.php
  2. Drop classTextile.php into $IP/extensions/AlternateSyntaxParser/

Usage[edit | edit source]

To use an alternate syntax in a page, if you haven't set a site-wide default, put the following at the top of the page:

#MARKUP language

Where 'language' is the markup language - examples include 'markdown' and 'textile'.

Below that, add any desired page content in the markup language specified. That's it!

Implementation notes[edit | edit source]

The inspiration for this extension was born out of Simon Dorfman's work on Extension:MarkdownSyntax, which takes a different approach to rendering the content. AlternateSyntaxParser bypasses nearly all of the MediaWiki Parser's steps in order to preserve the alternate language's output, while MarkdownSyntax renders the markup according to Markdown rules prior to MediaWiki's wikitext parsing.

This means that MarkdownSyntax will still be able to use the category, namespace and template systems (among other MediaWiki features), while AlternateSyntaxParser will not. On the other hand, AlternateSyntaxParser does not suffer from syntactical conflicts such as header/section mapping (as described on the MarkdownSyntax extension page).

It is left as an exercise for the user to decide which method is more appropriate for their particular use case.

--Jimbojw 20:33, 3 June 2007 (UTC)

See also[edit | edit source]

See also modified version 5 Fix apr. 2013, MW 1.20 - v 0.1p1 on the Talk page.