<?php //{{MediaWikiExtension}}<source lang="php">
/*
* AlternateSyntaxParserTextile2.php - Adds Textile2 parser to Jim R. Wilson's AlternateSyntaxParser.
* @author Nigel S. Ball
* @version 0.1
* @copyright Copyright (C) 2007 Nigel S. Ball
* @license The MIT License - http://www.opensource.org/licenses/mit-license.php
* -----------------------------------------------------------------------
* Description:
* This is a MediaWiki (http://www.mediawiki.org/) extension which extends
* AlternateSyntaxParser to include the Textile2 markup class.
* Requirements:
* Mediawiki 1.6.x, 1.9.x, 1.10.x or higher
* PHP 4.x, 5.x or higher
* AlternateSyntaxParser
* http://jimbojw.com/wiki/index.php?title=AlternateSyntaxParser_Extension
* Textile2:
* http://textile.thresholdstate.com/file_download/2/textile-2.0.0.tar.gz
*
* Installation:
* 1. Install the AlternateSyntaxParser extension.
* 2. Drop this script (AlternateSyntaxParserTextile2.php) into $IP/extensions/AlternateSyntaxParser
* 3. Enable the extension by adding this line to your LocalSettings.php:
* require_once('extensions/AlternateSyntaxParser/MarkdownSyntax.php');
* after the line enabling the AlternateSyntaxParser
* 4. Download the Textile2 library:
* http://jimandlissa.com/project/textilephp
* 2. Extract the file 'classTextile.php' from the downloaded archive.
* 3. Drop classTextile.php into $IP/extensions/AlternateSyntaxParser/
* Usage:
* To use an Textile2 in a page, put the following at the top of the page:
* #MARKUP textile2
* Alternatively, you may specify a site-wide default alternate language by setting
* the $wgAlternateSyntaxParserLanguage variable in your LocalSettings.php.
* $wgAlternateSyntaxParserLanguage = 'textile2';
* Version Notes:
* version 0.1:
* Initial release.
* -----------------------------------------------------------------------
* Copyright (c) 2007 Nigel S. Ball
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
* -----------------------------------------------------------------------
*/
# Confirm MediaWiki environment
if (defined('MEDIAWIKI')) {
# Credits
$wgExtensionCredits['parserhook'][] = array(
'name'=>'AlternateSyntaxParserTextile2',
'author'=>'Nigel S. Ball - nigel<at>nigelball.org',
'url'=>'http://nigelball.org/2007/09/04/textile-markup-with-mediawiki-revisited',
'description'=>'Adds Textile2 syntax to AlternativeSyntaxParser',
'version'=>'0.1'
);
$wgHooks['AlternateSyntaxParser'][] = 'useTextile2';
function useTextile2(&$parser, &$text, $pn) {
if (strtolower($pn) == 'textile2') {
require_once('classTextile.php');
$textile = new Textile();
$text = $textile->TextileThis($parser->mSwappedOutText);
return false;
}
return true;
}
} # End MW Environment wrapper
//</source>
?>