Merge commit 'd67975c84d4c0de906a3e3f011b3303627cf3204' into ja
This commit is contained in:
11
ebook/genepub.sh
Normal file → Executable file
11
ebook/genepub.sh
Normal file → Executable file
@@ -3,20 +3,17 @@ if ! which pandoc >/dev/null ;then
|
|||||||
echo "请先安装pandoc,然后再次运行"
|
echo "请先安装pandoc,然后再次运行"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
[ -f build-web-application-with-golang ] || go build
|
|
||||||
[ -d html ] || mkdir html
|
|
||||||
pushd html >/dev/null; cp ../*.md .
|
|
||||||
sed -i 's!https://github.com/astaxie/build-web-application-with-golang/blob/master/!!g' README.md
|
sed -i 's!https://github.com/astaxie/build-web-application-with-golang/blob/master/!!g' README.md
|
||||||
for i in *.md;do
|
for i in *.md;do
|
||||||
#重新格式化md文件
|
#重新格式化md文件
|
||||||
sed -i '/^[#]\{1,\}/s!^\([#]\{1,\}\)\([^#]\{1,\}\)!\1 \2!' $i #以#开头的行,在#后增加空格
|
sed -i '/^[#]\{1,\}/s!^\([#]\{1,\}\)\([^#]\{1,\}\)!\1 \2!' $i #以#开头的行,在#后增加空格
|
||||||
sed -i '/^[#]\{1,\}/s! ! !' $i #以#开头的行, 删除多余的空格
|
sed -i '/^[#]\{1,\}/s! ! !' $i #以#开头的行, 删除多余的空格
|
||||||
#sed -i '/!\[\](images/s#images\(.*\)?raw=true#../Images\1#' $i
|
#sed -i '/!\[\](images/s#images\(.*\)?raw=true#../Images\1#' $i
|
||||||
sed -i '/!\[\](images/s#images\(.*\)?raw=true#../images\1#' $i #处理md文件中的image src属性
|
#sed -i '/!\[\](images/s#images\(.*\)?raw=true#../images\1#' $i #处理md文件中的image src属性
|
||||||
sed -i '/[#]\{2,\} links/,/[ ]\{0,\}Id\$.*/d' $i #删除页面链接
|
sed -i '/[#]\{2,\} links/,/[ ]\{0,\}Id\$.*/d' $i #删除页面链接
|
||||||
done
|
done
|
||||||
../build-web-application-with-golang >/dev/null
|
list="`ls [0-9]*.html |sort `"
|
||||||
list="README.html `ls [0-9]*.html |sort -h` LICENSE.html"
|
|
||||||
cat > metadata.txt <<EOF
|
cat > metadata.txt <<EOF
|
||||||
<dc:creator>Astaxie</dc:creator>
|
<dc:creator>Astaxie</dc:creator>
|
||||||
<dc:description>一本开源的Go Web编程书籍</dc:description>
|
<dc:description>一本开源的Go Web编程书籍</dc:description>
|
||||||
@@ -27,6 +24,6 @@ EOF
|
|||||||
|
|
||||||
pandoc --reference-links -S --toc -f html -t epub --epub-metadata=metadata.txt --epub-cover-image=../images/cover.png \
|
pandoc --reference-links -S --toc -f html -t epub --epub-metadata=metadata.txt --epub-cover-image=../images/cover.png \
|
||||||
-o ../build-web-application-with-golang.epub $list
|
-o ../build-web-application-with-golang.epub $list
|
||||||
popd >/dev/null
|
|
||||||
rm -rf html
|
rm -rf html
|
||||||
echo "build-web-application-with-golang.epub 已经建立"
|
echo "build-web-application-with-golang.epub 已经建立"
|
||||||
|
|||||||
Reference in New Issue
Block a user