-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml2rst.sh
executable file
·29 lines (26 loc) · 1.1 KB
/
xml2rst.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Converts Docbook XML files in a directory to RST using pandoc.
#
# Run this script in the directory containing the XML files to convert.
# If you want to delete the XML files after conversion, remove the 'rm $file'
# line.
loc=$(pwd)/*
for file in $loc; do
if test -f $file; then
rstfile="${file%.*}.rst"
pandoc -f docbook -t rst $file -o $rstfile
xmlfile="${file##*/}"
rstfile="${rstfile##*/}"
echo "$xmlfile --> $rstfile"
# rm $file
fi
done
echo "Cleaning up RST..."
sed -i 's/programlisting/\ /g' *.rst # Delete programlisting tag
sed -i 's/screen/\ /g' *.rst # Delete screen tag
sed -i 's/literal/\ /g' *.rst # Delete litral tag
sed -i 's/\*\*Note\*\*/\.\.\ note\:\: /g' *.rst # Fix note directive
sed -i 's/\*\*Tip\*\*/\.\.\ tip\:\: /g' *.rst # Fix tip directive
sed -i 's/\*\*Warning\*\*/\.\.\ warning\:\: /g' *.rst # Fix warning directive
sed -i 's/\*\*Important\*\*/\.\.\ important\:\: /g' *.rst # Fix important directive
echo "Done"