Skip to content

Instantly share code, notes, and snippets.

@donghee
Forked from anonymous/migrate.pl
Last active August 29, 2015 14:13
Show Gist options
  • Save donghee/69e331bfdf7fe3d2452b to your computer and use it in GitHub Desktop.
Save donghee/69e331bfdf7fe3d2452b to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -ni.bak
# from: http://www.emilsit.net/blog/archives/migrating-from-moinmoin-to-dokuwiki/
BEGIN { $readblank = 0; }
$readblank = 1 if /^$/;
# Fix line-endings for Unix
# $//;
# Ignore all pragmas
next if !$readblank and /^#/;
# Fix different a href linking styles
s/\[(http:\S+)\s+(.*?)]/[\[$1|$2\]]/g;
# Fix lists that aren't indented enough
s/^ \*/ \*/;
# Fix ordered lists
s/^(\s+)\d+\./$1-/;
# Fix code blocks
s/^{{{$/<code>/;
s/^}}}$/<\/code>/;
# Fix monospace/code text
s/`/''/g;
s/{{{(.*?)}}}/''$1''/g;
# Fix headers
s/^= (.*) =$/====== $1 ======/g;
s/^== (.*) ==$/===== $1 =====/g;
s/^=== (.*) ===$/==== $1 ====/g;
print;
#!/usr/bin/python
from dokuwiki import DokuWiki, DokuWikiError
import sys
import subprocess
import fileinput
import glob
def to_doku(d, page_id, txt):
try:
d.pages.set(page_id, txt)
except DokuWikiError as err:
print err
def cat(f):
return subprocess.check_output('cat '+ f +' | iconv -f cp949 -t utf8' , shell=True)
def moin2doku(f):
return subprocess.check_output('cat '+ f+' | iconv -f cp949 -t utf8 | perl migrate.pl' , shell=True)
d = DokuWiki('http://xx.xx/wiki', 'xx', 'xx', allow_none=True)
for f in glob.glob('*'):
print f
to_doku(d, f, moin2doku(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment