2016-03-07 11:29:31 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Convert a template file into something like RST
|
|
|
|
#
|
|
|
|
# fix <function>
|
|
|
|
# feed to pandoc
|
|
|
|
# fix \_
|
|
|
|
# title line?
|
|
|
|
#
|
2017-04-05 21:22:55 +08:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
if [ "$#" != "2" ]; then
|
|
|
|
echo "$0 <docbook file> <rst file>"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
DIR=$(dirname $0)
|
2016-03-07 11:29:31 +08:00
|
|
|
|
|
|
|
in=$1
|
|
|
|
rst=$2
|
|
|
|
tmp=$rst.tmp
|
|
|
|
|
|
|
|
cp $in $tmp
|
2017-04-05 21:22:55 +08:00
|
|
|
sed --in-place -f $DIR/convert_template.sed $tmp
|
2016-03-07 11:29:31 +08:00
|
|
|
pandoc -s -S -f docbook -t rst -o $rst $tmp
|
2017-04-05 21:22:55 +08:00
|
|
|
sed --in-place -f $DIR/post_convert.sed $rst
|
2016-03-07 11:29:31 +08:00
|
|
|
rm $tmp
|
2017-04-05 21:22:55 +08:00
|
|
|
echo "book writen to $rst"
|