#!/usr/bin/perl # mediawiki2html - converts MediaWiki markup into HTML markusp # Copyright (C) 2006 Gervase Markham # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # # This software was written to the Glory of God. use lib "."; use CGI qw(:standard); use Text::MediawikiFormat; # Self-download code if (param('downloadself')) { seek(DATA, 0, SEEK_SET); print "Content-Type: text/plain\n\n", ; exit(0); } # Print header print < MediaWiki2HTML

MediaWiki2HTML

MediaWiki2HTML does exactly what it says on the tin. If you have no MediaWiki markup and want to try it out, you can find some by clicking the Edit link on any article on Wikipedia.

EOF my $wikimarkup = param('wikimarkup'); # Do we have any work to do? if ($wikimarkup) { my $decoded = Text::MediawikiFormat::format($wikimarkup); my $text = $decoded; $text =~ s/</&lt;/g; $text =~ s/>/&gt;/g; $text =~ s//>/g; print <Here is your HTML:

$text

And it will look like this:

$decoded EOF } print <Paste MediaWiki markup here:

The code for this application is available under the terms of the GNU General Public Licence. It's basically a web interface to the excellent Text::MediawikiFormat module.

EOF exit(0); # The following is required for self-download to work (presumably it sets up # the DATA filehandle) __END__