-
Notifications
You must be signed in to change notification settings - Fork 119
/
run_web.sh
48 lines (43 loc) · 1.18 KB
/
run_web.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#########################################################################
# File Name: run_web.sh
# Author: Bill
# mail:
# Created Time: 2016-10-12 13:17:27
#########################################################################
#!/bin/bash
# 通过markdown文件生成html文件,并建立web service访问html
HTML_DIR='html_tmp'
PORT=8000
if [ $# -ne 0 ]
then
if [[ $1 =~ ^[0-9]+$ ]]
then
PORT=$1
echo ${PORT}
fi
fi
CHECK=`rpm -qa | grep 'pandoc'| wc -l`
if [[ w${CHECK} == w0 ]]
then
echo "this system not have pandoc!"
echo "you must run:yum -y install pandoc"
exit
fi
[[ -d "${HTML_DIR}" ]] && rm -rf ${HTML_DIR}
mkdir -p ${HTML_DIR}
cp -rf ./images ${HTML_DIR}
find . -name "*.md" | while read md_file
do
#echo ${md_file}
PATH_FILE=`dirname ${md_file}`
if [ ! -d "${HTML_DIR}/${PATH_FILE}" ]
then
mkdir -p ${HTML_DIR}/${PATH_FILE}
fi
file_name=$(echo ${md_file} | sed "s/\.md$//")
pandoc -f markdown -t html --html5 --atx-headers ${md_file} > ${HTML_DIR}/${file_name}.html
sed -i "s/.md/.html/g" ${HTML_DIR}/${file_name}.html
done
cd ${HTML_DIR}
echo "http://localhost:${PORT}"
python -m SimpleHTTPServer ${PORT}