Skip to content

Instantly share code, notes, and snippets.

@brozkeff
Forked from hugorodgerbrown/md_to_rst.sh
Last active October 22, 2018 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brozkeff/5196968cc159317573c00832ff0ff6eb to your computer and use it in GitHub Desktop.
Save brozkeff/5196968cc159317573c00832ff0ff6eb to your computer and use it in GitHub Desktop.
Shell script for converting a batch of *.txt dokuwiki-syntax files into *.html using dokuwiki2mediawiki and then pandoc.
# This script was created to convert a directory full
# of dokuwiki files into html. It uses dokuwiki2mediawiki.php for intermediate step converting to mediawiki, and
# pandoc to do the conversion from mediawiki to html.
#
# 1. Install pandoc from http://johnmacfarlane.net/pandoc/
# 2. Copy this script into the directory containing the .txt files
# 3. Copy script (https://github.com/tstaerk/mediasyntax/blob/master/tools/dokuwiki2mediawiki.php) to the same directory, make sure you have PHP installed and capable running scripts
# 3. Ensure that the script has execute permissions
# 4. Run the script
#
# By default this will keep the original .txt and intermediate .txt.mod file
FILES=*.txt
for f in $FILES
do
# extension="${f##*.}"
filename="${f%.*}"
echo "Intermediate step: Converting $f to mediawiki format"
`php ./dokuwiki2mediawiki.php $f`
done
FILESMOD=*.txt.mod
for f in $FILESMOD
do
# extension="${f##*.}"
filename="${f%.*}"
echo "Converting $f to $filename.html"
`pandoc -f mediawiki $f -t html -o $filename.html`
# uncomment this line to delete the source file.
# rm $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment