#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $query=new CGI; use HTML::WikiConverter; my $text = $query->param( "wikitext" ); if( $text ) { print "Content-type:text/html; charset=utf-8\n\nSuper amazing wikifier"; my( $title, $result, $result_wo_t, @templates ) = convertwikichan( $text ); print "

Here is your wikified version of «$title»

"; if( @templates + 0 > 0 ) { print "

There were " . ( @templates + 0 ) . " templates detected which you should(must) replace, if you do not want to do that or if it's unnecessary or borked, use the version without replacements at this pages end.

"; } print "

Result:
"; my $cnt = 0; foreach ( @templates ) { print "

{{Template$cnt}}

"; $cnt++; } print "

Result, no teplate replacement:

"; print ""; } else { print "Content-type:text/html; charset=utf-8\n\n"; print <Super amazing wikifier

Super-amazing wikifier

Super Amazing Wikifier: How to use it

Enter html source code:


HTML ; } sub convertwikichan { my $html = shift(); my $wc = new HTML::WikiConverter( dialect => 'MediaWiki', base_uri => 'http://wikichan.org/', wiki_uri => [ qr~http://wikichan.org/index.php\?title\=([^&]+)~, qr~http://wikichan.org/index.php/(.*)~, qr~http://wikichan.org/wiki/(.*)~, ], strip_tags => [ 'br', '~comment', 'head', 'script', 'style' ] ); my ( $title, $wikipart ) = ( $html =~ m~

(.*?)

(?:.*?)(.*)~gis ); $wikipart =~ s/http:\/\/web.archive.org\/web\/(?:[0-9a-z_])\///; if( !$wikipart || $wikipart eq '' ) { print( "Meh.Something went wrong, maybe preparsing failed, maybe you're just SOL, maybe you entered the wrong stuff. Reread the tutorial and see if that helps. Make sure you copied all of the source code." ); } # Wikification my $wikified = $wc->html2wiki( $wikipart ); # Edit link fuckups $wikified =~ s/\[\[index.php\?title=([^&]+)&action=edit/[[$1/gis; # Some minor replacements. $wikified =~ s/([^<]*)<\/span>/$1/gis; $wikified =~ s/([^<]*)<\/font>/$1/gis; # Stub $wikified =~ s/