Knocked togeather by Shawn "AutoDMC" Boles of AutoDMC.org
Parser source:
<html>
<head>
<title>Rudamentary Wikimedia Syntax to Wikidot Syntax Transmorgifier</title>
</head>
<body>
<h1>Rudamentary Wikimedia To Wikidot Transmorgifier</h1>
<p><em>Knocked togeather by Shawn "AutoDMC" Boles of AutoDMC.org</em></p>
<?php if (!empty($_GET['show_yourself'])) {
echo 'Parser source:<hr>';
highlight_file(__FILE__);
echo '<hr>';
echo '<p>Click <a href="?">here</a> to hide the source code! (Don\'t laugh)</p>';
} else {
echo '<p>Click <a href="?show_yourself=true">here</a> to see the source code! (Don\'t laugh)</p>';
} ?>
<p>This tool will allow you to paste in a block of Wikipedia/Wikimedia syntax text and convert it to Wikidot Syntax. Currently translates:
<ul>
<li>Headings</li>
<li>Internal Wiki Links<li>
<li>Bold</li>
<li>Italic</li>
<li>Underline (and "ins" for inserted material)</li>
<li>Strikethrough (and "del" for deleted material)</li>
<li>Ordered, Unordered, and Mixed lists</li>
<li>Table of Content tags</li>
<li>Comments</li>
<li>"nowiki" and "pre"</li>
<li>Superscripts and Subscripts</li>
</ul>
</p>
<?php if (!empty($_POST['wikitext'])) {
$convertedText = stripslashes($_POST['wikitext']);
// [\x20-\x7E]*?
// Match everything printable, in lazy chunks (not greedy whole-line chunks)
// Convert links from Wikimedia [[Link Content]] to Wikidot [[[Link Content]]]
$convertedText = preg_replace('/\[\[([\x20-\x7E]*?)\]\]/ix', '[[[$1]]]', $convertedText);
// Convert Headings
$convertedText = preg_replace_callback('/(=+)([\x20-\x7E]*?)=+/ix',
create_function(
'$matches',
'return str_repeat("+", strlen($matches[1])) . " " . trim($matches[2]);'
), $convertedText);
// Convert Lists
$convertedText = preg_replace_callback('/([\*#]+)([\x20-\x7E]*?)\r/ix',
create_function(
'$matches',
'return str_repeat(" ", (strlen($matches[1])-1)) . substr($matches[1], (strlen($matches[1])-1), 1) . " " . trim($matches[2]);'
), $convertedText);
// Bold
$convertedText = preg_replace('/\'{3}/ix', '**', $convertedText);
// Italic
$convertedText = preg_replace('/\'{2}/ix', '//', $convertedText);
// Table of Contents
$convertedText = str_replace('__TOC__', '[[toc]]', $convertedText);
// Comments
$convertedText = preg_replace('/<!--([\x20-\x7E]*?)-->/ix', '[!-- $1 --]', $convertedText);
// Text not to be processed by the WIKI system:
$convertedText = preg_replace('/<nowiki>([\x20-\x7E]*?)<\/nowiki>/ix', '@@$1@@', $convertedText);
$convertedText = preg_replace('/<pre>([\x20-\x7E]*?)<\/pre>/ix', '@@$1@@', $convertedText);
// Strikeout
$convertedText = preg_replace('/<s>([\x20-\x7E]*?)<\/s>/ix', '--$1--', $convertedText);
$convertedText = preg_replace('/<del>([\x20-\x7E]*?)<\/del>/ix', '--$1--', $convertedText);
// Underlined
$convertedText = preg_replace('/<u>([\x20-\x7E]*?)<\/u>/ix', '__$1__', $convertedText);
$convertedText = preg_replace('/<ins>([\x20-\x7E]*?)<\/ins>/ix', '__$1__', $convertedText);
// Subscripts
$convertedText = preg_replace('/([\x20-\x7E]*?)<sub>([\x20-\x7E]*?)<\/sub>/ix', '$1,,$2,,', $convertedText);
// Superscripts
$convertedText = preg_replace('/([\x20-\x7E]*?)<sup>([\x20-\x7E]*?)<\/sup>/ix', '$1^^$2^^', $convertedText);
?>
<p><strong>Converted text:</strong></p>
<textarea name='wikitext' rows='50' cols='121'><?php echo $convertedText; ?></textarea>
</div>
<?php } ?>
<form name="guestbook" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p>Wikipedia/Wikimedia Text:</p>
<textarea name='wikitext' rows='50' cols='121'>
<?php echo (!empty($_POST['wikitext'])) ? stripslashes($_POST['wikitext']) : "Put your Wikipedia/Wikimedia text here!"; ?></textarea>
<input type='submit'/>
</form>
Click here to hide the source code! (Don't laugh)
This tool will allow you to paste in a block of Wikipedia/Wikimedia syntax text and convert it to Wikidot Syntax. Currently translates: