DokuWiki

It's better when it's simple

User Tools

Site Tools


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: by 202.37.198.25

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki