#!/bin/bash
cd source
rm -rf ContractAPI.rst
rm -rf IDEUsage.rst
rm -rf InstallTips.rst
rm -rf Introduction.rst
rm -rf YJSAPI.rst
rm -rf YJSInDepth.rst
rm -rf conf.py
rm -rf index.rst
rm -rf _static
if [ $# -lt 1 ]; then
  export src=../markdown/markdown_BDWare
elif [ $1 == "zryh" ] ; then
  export src=../markdown/markdown_ZRYH
elif [ $1 == "bdware" ] ; then
  export src=../markdown/markdown_BDWare
else
  echo "error arguments, use ./markdown"
  export src=../markdown/markdown_BDWare
fi
cp ${src}/conf.py ./conf.py
cp ${src}/index.rst ./index.rst
cp -r ${src}/_static ./_static

for f in `ls ${src} | grep .md ` ; do
   echo "convert $f -->  ${f/.md/.rst}"
   pandoc ${src}/$f -f markdown -t rst  -o ${f/.md/.rst}
done
#pandoc ${src}/IDEUsage.md -f markdown -t rst  -o IDEUsage.rst
#pandoc ${src}/InstallTips.md -f markdown -t rst  -o InstallTips.rst
#pandoc ${src}/Introduction.md -f markdown -t rst  -o Introduction.rst
#pandoc ${src}/YJSAPI.md -f markdown -t rst  -o YJSAPI.rst
#pandoc ${src}/YJSInDepth.md -f markdown -t rst  -o YJSInDepth.rst
cd ..
make clean
#make html
