DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:export2twiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tips:export2twiki [2013-01-25 01:24] (current)
202.37.198.25 created
Line 1: Line 1:
 +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
  
 +<code perl 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";
 +</code>
tips/export2twiki.txt ยท Last modified: 2013-01-25 01:24 by 202.37.198.25