|
1 | | -#!/bin/bash |
2 | | -if ! which pandoc >/dev/null ;then |
3 | | - echo "请先安装pandoc,然后再次运行" |
4 | | - exit 0 |
5 | | -fi |
6 | | -[ -f build-web-application-with-golang ] || go build |
7 | | -[ -d html ] || mkdir html |
8 | | -pushd html >/dev/null; cp ../*.md . |
9 | | -sed -i 's!https://github.com/astaxie/build-web-application-with-golang/blob/master/!!g' README.md |
10 | | -for i in *.md;do |
11 | | - #重新格式化md文件 |
12 | | - sed -i '/^[#]\{1,\}/s!^\([#]\{1,\}\)\([^#]\{1,\}\)!\1 \2!' $i #以#开头的行,在#后增加空格 |
13 | | - sed -i '/^[#]\{1,\}/s! ! !' $i #以#开头的行, 删除多余的空格 |
14 | | - #sed -i '/!\[\](images/s#images\(.*\)?raw=true#../Images\1#' $i |
15 | | - sed -i '/!\[\](images/s#images\(.*\)?raw=true#../images\1#' $i #处理md文件中的image src属性 |
16 | | - sed -i '/[#]\{2,\} links/,/[ ]\{0,\}Id\$.*/d' $i #删除页面链接 |
17 | | -done |
18 | | -../build-web-application-with-golang >/dev/null |
19 | | -list="README.html `ls [0-9]*.html |sort -h` LICENSE.html" |
20 | | -cat > metadata.txt <<EOF |
21 | | -<dc:creator>Astaxie</dc:creator> |
22 | | -<dc:description>一本开源的Go Web编程书籍</dc:description> |
23 | | -<dc:language>zh-CN</dc:language> |
24 | | -<dc:rights>Creative Commons</dc:rights> |
25 | | -<dc:title>Go Web编程</dc:title> |
26 | | -EOF |
27 | | - |
28 | | -pandoc --reference-links -S --toc -f html -t epub --epub-metadata=metadata.txt --epub-cover-image=../images/cover.png \ |
29 | | --o ../build-web-application-with-golang.epub $list |
30 | | -popd >/dev/null |
31 | | -rm -rf html |
32 | | -echo "build-web-application-with-golang.epub 已经建立" |
| 1 | +#!/bin/bash |
| 2 | +if ! which pandoc >/dev/null ;then |
| 3 | + echo "请先安装pandoc,然后再次运行" |
| 4 | + exit 0 |
| 5 | +fi |
| 6 | +[ -f build-web-application-with-golang ] || go build |
| 7 | +[ -d html ] || mkdir html |
| 8 | +pushd html >/dev/null; cp ../*.md . |
| 9 | +sed -i 's!https://github.com/astaxie/build-web-application-with-golang/blob/master/!!g' README.md |
| 10 | +for i in *.md;do |
| 11 | + #重新格式化md文件 |
| 12 | + sed -i '/^[#]\{1,\}/s!^\([#]\{1,\}\)\([^#]\{1,\}\)!\1 \2!' $i #以#开头的行,在#后增加空格 |
| 13 | + sed -i '/^[#]\{1,\}/s! ! !' $i #以#开头的行, 删除多余的空格 |
| 14 | + #sed -i '/!\[\](images/s#images\(.*\)?raw=true#../Images\1#' $i |
| 15 | + sed -i '/!\[\](images/s#images\(.*\)?raw=true#../images\1#' $i #处理md文件中的image src属性 |
| 16 | + sed -i '/[#]\{2,\} links/,/[ ]\{0,\}Id\$.*/d' $i #删除页面链接 |
| 17 | +done |
| 18 | +../build-web-application-with-golang >/dev/null |
| 19 | +list="README.html `ls [0-9]*.html |sort -h` LICENSE.html" |
| 20 | +cat > metadata.txt <<EOF |
| 21 | +<dc:creator>Astaxie</dc:creator> |
| 22 | +<dc:description>一本开源的Go Web编程书籍</dc:description> |
| 23 | +<dc:language>zh-CN</dc:language> |
| 24 | +<dc:rights>Creative Commons</dc:rights> |
| 25 | +<dc:title>Go Web编程</dc:title> |
| 26 | +EOF |
| 27 | + |
| 28 | +pandoc --reference-links -S --toc -f html -t epub --epub-metadata=metadata.txt --epub-cover-image=../images/cover.png \ |
| 29 | +-o ../build-web-application-with-golang.epub $list |
| 30 | +popd >/dev/null |
| 31 | +rm -rf html |
| 32 | +echo "build-web-application-with-golang.epub 已经建立" |
0 commit comments