Extension:UsenetSyntax

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
UsenetSyntax

Release status: beta

Implementation Extended syntax
Description Allows simple Usenet highlighting such as *bold*, /italic/ and _underline_.
Author(s) Jim R. Wilson (Jimbojw)
Last version 0.2
MediaWiki 1.6.x, 1.8.x, 1.9.x
License The MIT License
Download UsenetSyntax.php
Check usage and version matrix; stats

UsenetSyntax is a MediaWiki extension that enables Usenet style emphasis nomenclature such as *bold*, /italics/, and _underline_.

Source Code
UsenetSyntax.php
Licensing
UsenetSyntax is released under The MIT License.

Installation[edit]

  1. Download UsenetSyntax and ExtendedSyntaxParser, and be sure to rename the downloaded files to UsenetSyntax.php and ExtendedSyntaxParser respectively.
  2. Drop these scripts into $IP/extensions
    Note: $IP is your MediaWiki install dir.
  3. Enable the extension by adding these lines to your LocalSettings.php:
require_once('extensions/ExtendedSyntaxParser.php');
require_once('extensions/UsenetSyntax.php');

Configuration (optional)

If you'd rather interpret the characters differently (for example, interpreting '_' as italics instead of '/'), you may do so in your LocalSettings.php.

To do this, simply override $wgUsenetSyntaxMappings after the require statement like so:

require_once('extensions/UsenetSyntax.php');
$wgUsenetSyntaxMappings['_'] = 'italics';

 - or -

require_once('extensions/UsenetSyntax.php');
$wgUsenetSyntaxMappings = array ( '*' => 'bold', '_' => 'italics' );

Note: The latter above will disable interpretation of '/' delimited strings altogether, whereas the former will still process them as italics.

Usage[edit]

Once installed, you (or editors of your wiki) may use Usenet syntax in any article.

Usenet syntax is not a formally defined markup language, but nevertheless is understood by many systems such as Mozilla Thunderbird.

An alternate version of Usenet syntax (where '/' is not recognized, and '_' signifies italics) is used in other systems such as Google Talk. See the installation section for details on how to use this alternate syntax.

Technical Details[edit]

To perform its magic, UsenetSyntax hooks into ParserBeforeTidy. For this reason, it's not a true parser extension in the common sense of the term since that title is typically reserved for tag extensions and function extensions.

Caveats and Gotchas[edit]

One consequence of hooking into the Parser as such a late stage is that the extension has no regard for <nowiki> blocks. For example:

<nowiki> This block *contains bold* text </nowiki>

becomes:

<nowiki> This block <b>contains bold</b> text </nowiki>

This is despite the fact that standard MediaWiki syntax guarantees that any text inside <nowiki> tags will be immune to all markup interpretation.

As of version 0.1, the above also applies for preformatted text blocks (text wrapped in <pre> tags). This is, however, not a constraint of the hooking mechanism, but rather an unimplemented feature - in the interest of keeping the source code simple.

Further, this extension has not been thoroughly tested, and using it may break some pages in other ways. If you run into page-breakage issues, please feel free to report them on the talk page.

Developer Notes[edit]

For the record, I do not support integrating this syntax into the vanilla MediaWiki parser. The standard syntax already has convenient markup for '''bold''', ''italicized'' and <u>underlined</u> text.

Additionally, I do not intend to make this extension significantly more robust by correcting for all items listed under Caveats and Gotchas.

--Jim R. Wilson (Jimbojw) 16:09, 21 February 2007 (UTC)