I knocked this up in a two hour coding session tonight. I have a wiki over at Wikia.com… unfortunatly I have two problems with them. (1) Slow, (2) Ads. 1 is kinda random… sometimes the wiki is really really fast, many times it's not. And while I don't normally mind web ads, the way they do 2 breaks standard Wiki layout. I had picked them because I wanted to import my older Mediawiki wiki without lots of personal work.
Well, I'd rather host the wiki here, but nobody wanted to volunteer to convert the Mediawiki syntax to Wikidot syntax. So I built a script to do (most of) it.
http://autodmc.org/wikimedia-to-wikidot.php
Paste your Wikimedia text into the textbox, click submit, wait a bit while my handful of regular expressions crunch over the file, and then take the output out of the top box when the page loads.
What can it convert?
- Headings
- Most Wiki Links
- Bold, Italic, Underline, Strikeout
- Ordered, Unordered, and Mixed Lists
- TOC tags
- Comments
- <nowiki> and <pre>
- Super and sub scripts
The regexes could most likely be better written, they're my first stab at flying solo in regex land.
This code currently doesn't touch images or tables. Images because I'm tired, tables because I don't want to jump into that pit.
And the code isn't perfect; sometimes it misses a tag. That's the (much of) and (mostly) bits above.
Here's an example of a conversion:
Wikia: http://usflexicon.wikia.com/wiki/USS_Lexington
Wikidot: http://thelexicon.wikidot.com/usslexington-direct-import
I added some junk code between the TOC and the first heading while doing the direct-import:
<!-- Commenty Goodness *(*&)@#(*&$(^ -->
<nowiki> '''''Do not render!''''' </nowiki>
<pre> LOL </pre>
<nowiki> <pre> WTF </nowiki> </pre>
Some <s>Strikeout</s> and <del>Deleted</del> materials, followed by <ins>Inserted</ins> and <u>underline!</u>
LOL<sub>WHUT</sub> or LOL<sup>WHUT</sup>.
Mediawiki allows you to add Category as links at the bottom of the articles… is something similar to this possible in Wikidot? If not, just cut those bits off when you're done converting.
As you can see, it doesn't do everything, but it takes some of the drudgery out of converting articles, especially for big articles. Just run a quick eye over a Preview of the page and you'll catch the errors most likely.
ideas on how to make the regexs suck less? Wanna tackle images or tables? Let me know and I'll update the code. If you guys like it, I'll spiff the page up a bit (it's just a hacked internal tool right now :D).