DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:mediawiki_to_dokuwiki_converter

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:mediawiki_to_dokuwiki_converter [2013-04-24 05:24] – Project at GitHub is always newer than anything pasted here. Better to use the link than broken code. 74.243.147.85tips:mediawiki_to_dokuwiki_converter [2017-10-12 17:51] (current) – [yamdwe tool] 207.191.190.131
Line 1: Line 1:
 ====== MediaWiki to DokuWiki Converter ====== ====== MediaWiki to DokuWiki Converter ======
  
 +===== Automatic script =====
 +
 +This script will automatically convert a MediaWiki install to DokuWiki. No configuration is required as all it needs is the path to ''LocalSettings.php''. The shell script, as was presented in sections below, did not work as expected as DokuWiki did not find the pages after they were injected manually. Instead, this script uses DokuWiki's own API to programmatically insert pages from MediaWiki.
 +
 +The ''mw2dw-conv_sed.sh'' script, which you can find below, has been converted into native PHP so shell access is not required. Also runs from the web server if desired.
 +
 +Find on GitHub: \\ https://github.com/tetsuo13/MediaWiki-to-DokuWiki-Importer
 +
 +===== yamdwe tool =====
 +
 +"yamdwe" (Yet Another Mediawiki to DokuWiki Exporter) is another export tool.
 +
 +https://github.com/projectgus/yamdwe/
 +
 +**Pros**: 
 +  * It uses the MediaWiki API so can create a local DokuWiki from a remote MediaWiki install. Automatically imports full revision history for each page, imports media and (optionally) imports users & passwords if it has database access. 
 +  * Uses [[http://mwlib.readthedocs.org/|mwlib]] to parse MediaWiki syntax so complex pages import more cleanly.
 +
 +**Cons**: 
 +  * Is Python based so it's more involved to set up than most of the other tools listed here (install steps for Linux are provided.)
 +  * Slow for large amounts of Mediawiki content
 +  * Categories are not converted (the content within the category pages)
 +===== Older scripts: =====
 ===== Updated Scripts for Converting Mediawiki 1.15.1 to Anteater. ===== ===== Updated Scripts for Converting Mediawiki 1.15.1 to Anteater. =====
  
Line 44: Line 67:
 ==== Source ===== ==== Source =====
 File mediawiki2dokuwiki.sh: File mediawiki2dokuwiki.sh:
-<code bash>+<code bash mediawiki2dokuwiki.sh>
 #! /bin/sh #! /bin/sh
 # Mediawiki2Dokuwiki Converter # Mediawiki2Dokuwiki Converter
Line 469: Line 492:
  --- [[user>gtournat|gtournat]] //2011/11/06 13:16//  --- [[user>gtournat|gtournat]] //2011/11/06 13:16//
  
-===== Another automatic script ===== 
  
-This script will automatically convert a MediaWiki install to DokuWiki. No configuration is required as all it needs is the path to LocalSettings.php. The above shell script did not work as expected as DokuWiki did not find the pages after they were injected manually. Instead, this script uses DokuWiki's own API to programmatically insert pages from MediaWiki.+====== Mediawiki 2 Dokuwiki Converter ======
  
-The mw2dw-conv_sed.sh script has been converted into native PHP so shell access is not requiredAlso runs from the web server if desired.+<code perl> 
 +#! /bin/sh 
 +# Mediawiki2Dokuwiki Converter 
 +# originally by Johannes Buchner <buchner.johannes [at] gmx.at> 
 +# License: GPL (http://www.gnu.org/licenses/gpl.txt) 
 + 
 +# Headings 
 +cat mediawiki | \ 
 +   perl -pe 's/^[ ]*=([^=])/<h1> ${1}/g' | \ 
 +   perl -pe 's/([^=])=[ ]*$/${1} <\/h1>/g' | \ 
 +   perl -pe 's/^[ ]*==([^=])/<h2> ${1}/g' | \ 
 +   perl -pe 's/([^=])==[ ]*$/${1} <\/h2>/g' | \ 
 +   perl -pe 's/^[ ]*===([^=])/<h3> ${1}/g' | \ 
 +   perl -pe 's/([^=])===[ ]*$/${1} <\/h3>/g' | \ 
 +   perl -pe 's/^[ ]*====([^=])/<h4> ${1}/g' | \ 
 +   perl -pe 's/([^=])====[ ]*$/${1} <\/h4>/g' | \ 
 +   perl -pe 's/^[ ]*=====([^=])/<h5> ${1}/g' | \ 
 +   perl -pe 's/([^=])=====[ ]*$/${1} <\/h5>/g' | \ 
 +   perl -pe 's/^[ ]*======([^=])/<h6> ${1}/g' | \ 
 +   perl -pe 's/([^=])======[ ]*$/${1} <\/h6>/g'
 +    > mediawiki1 
 + 
 +cat mediawiki1 | \ 
 +   perl -pe 's/<\/?h1>/======/g' | \ 
 +   perl -pe 's/<\/?h2>/=====/g' | \ 
 +   perl -pe 's/<\/?h3>/====/g' | \ 
 +   perl -pe 's/<\/?h4>/===/g' | \ 
 +   perl -pe 's/<\/?h5>/==/g' | \ 
 +   perl -pe 's/<\/?h6>/=/g' | \ 
 +   cat > mediawiki2 
 + 
 +# lists 
 +cat mediawiki2 | 
 +  perl -pe 's/^[\*#]{4}\*/          * /g'  | \ 
 +  perl -pe 's/^[\*#]{3}\*/        * /g'    | \ 
 +  perl -pe 's/^[\*#]{2}\*/      * /g'      | \ 
 +  perl -pe 's/^[\*#]{1}\*/    * /g'        | \ 
 +  perl -pe 's/^\*/  * /g'                  | \ 
 +  perl -pe 's/^[\*#]{4}#/          \- /g'  | \ 
 +  perl -pe 's/^[\*\#]{3}\#/      \- /g'    | \ 
 +  perl -pe 's/^[\*\#]{2}\#/    \- /g'      | \ 
 +  perl -pe 's/^[\*\#]{1}\#/  \- /g'        | \ 
 +  perl -pe 's/^\#/  - /g'                  | \ 
 +  cat > mediawiki3 
 + 
 +#[link] => [[link]] 
 +cat mediawiki3 | 
 +  perl -pe 's/([^\[])\[([^\[])/${1}[[${2}/g'
 +  perl -pe 's/^\[([^\[])/[[${1}/g'
 +  perl -pe 's/([^\]])\]([^\]])/${1}]]${2}/g'
 +  perl -pe 's/([^\]])\]$/${1}]]/g'
 +  > mediawiki4 
 + 
 +#[[url text]] => [[url|text]] 
 +cat mediawiki4 | 
 +  perl -pe 's/(\[\[[^| \]]*) ([^|\]]*\]\])/${1}|${2}/g'
 +  > mediawiki5 
 + 
 +# bold, italic 
 +cat mediawiki5 | 
 +  perl -pe "s/'''/**/g"
 +  perl -pe "s/''/\/\//g"
 +  > mediawiki6 
 + 
 +# talks 
 +cat mediawiki6 | 
 +  perl -pe "s/^[ ]*:/>/g"
 +  perl -pe "s/>:/>>/g"
 +  perl -pe "s/>>:/>>>/g"
 +  perl -pe "s/>>>:/>>>>/g"
 +  perl -pe "s/>>>>:/>>>>>/g"
 +  perl -pe "s/>>>>>:/>>>>>>/g"
 +  perl -pe "s/>>>>>>:/>>>>>>>/g"
 +  > mediawiki7 
 + 
 +cat mediawiki7 | 
 +  perl -pe "s/<pre>/<code>/g"
 +  perl -pe "s/<\/pre>/<\/code>/g"
 +  > mediawiki8 
 + 
 +cat mediawiki8 > dokuwiki 
 +</code>
  
-Find on GitHub: https://github.com/tetsuo13/MediaWiki-to-DokuWiki-Importer 
tips/mediawiki_to_dokuwiki_converter.1366773879.txt.gz · Last modified: 2013-04-24 05:24 by 74.243.147.85

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