tips:export2twiki
This code only converts the following:
- headings
- code blocks
- double space code blocks
- unordered lists
- order lists
Usage: cat dokuwikisyntaxpage.txt | ./dokuwiki2twiki-converter.pl > twikisyntaxpage.txt
- dokuwiki2twiki-converter.pl
#!/usr/bin/perl # my $incode = 0; my $buffer = ''; while (<>) { s/''/\=/g; # Adding DokuWiki syntax to the headings s/======\s*(.*)\s*======/---+ $1/g; s/=====\s*(.*)\s*=====/---++ $1/g; s/====\s*(.*)\s*====/---+++ $1/g; s/===\s*(.*)\s*===/---++++ $1/g; s/==\s*(.*)\s*==/---+++++ $1/g; if (s/^\<code/<verbatim/g) { $incode = 1;} if (s/code\>/verbatim\>/g) {$incode = 0;} unless ($incode) { if ($buffer) { unless (/^ *[a-zA-Z0-9]+/) { $buffer .= "</verbatim>"; print $buffer; $buffer = ''; } else { print $buffer; if (s/^ *([a-zA-Z0-9]+)/$1/g) { $buffer = $_; next; } } } if (/^ *[a-zA-Z0-9]+/) { s/^ *([a-zA-Z0-9]+)(.*)/\<verbatim\>$1$2/g; $buffer = $_; next; } } s/^ \*/ \*/g; s/^ \-/ 1\./g; s/^ \*/ \*/g; s/^ \-/ 1\./g; s/^ \*/ \*/g; s/^ \-/ 1\./g; # print; } print "\n";
tips/export2twiki.txt · Last modified: 2013-01-25 01:24 by 202.37.198.25