skripting-section:bash:dokuwiki-foswiki-converter

Dokuwiki to Foswiki converter

Skript, welches die dokuwiki Syntax automatisiert in die foswiki Syntax konvertiert.

Filename: dokuwiki_to_foswiki.sh

#!/bin/bash
#*****************************************************************************
# Subject     : dokuwiki_to_foswiki.sh
# Description :
# Author      : Michael Reber <michael.r467@gmail.com>
# Created     : 2017.04.11
#*****************************************************************************

wikifile=$1

cp $wikifile ./NEW_$wikifile
wikifile=NEW_$wikifile

# Convert Titles
sed -ri 's/======(.*)======/---+\1/g' $wikifile
sed -ri 's/=====(.*)=====/---++\1/g' $wikifile
sed -ri 's/====(.*)====/---+++\1/g' $wikifile
sed -ri 's/===(.*)===/---++++\1/g' $wikifile
sed -ri 's/==(.*)==/---+++++\1/g' $wikifile

# Convert Textformating
sed -ri 's/\/\/(.*)\/\//_\1_/g' $wikifile
sed -ri 's/__(.*)__/\<u\>\1\<\/u\>/g' $wikifile
#sed -ri "s/''(.*)''/\<verbatim\>\1\<\/verbatim\>/g" $wikifile
sed -ri "s/''/=/g" $wikifile


#Convert other formating:
sed -ri "s/<code>/<verbatim>/g" $wikifile
sed -ri "s/<\/code>/<\/verbatim>/g" $wikifile
sed -ri "s/<sxh.*>/<verbatim>/g" $wikifile
sed -ri "s/<\/sxh>/<\/verbatim>/g" $wikifile
sed -ri 's/----/---/g' $wikifile
sed -ri 's/\|/\]\[/g' $wikifile

sed -ri 's/\*\*/\*/g' $wikifile

#sed -ri 's/<wrap em>//g' $wikifile
#sed -ri 's/<wrap>//g' $wikifile

sed -ri 's/\s\s\*/   \*/g' $wikifile
sed -ri 's/\s\s-/   1/g' $wikifile


Aufruf des Konverters:

# ./dokuwiki_to_foswiki.sh DOKUWIKI-PAGE.txt
  • skripting-section/bash/dokuwiki-foswiki-converter.txt
  • Last modified: 2017/11/13 12:48
  • by michael