-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
72 lines (52 loc) · 1.45 KB
/
Makefile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ============================================================
# Author: 凍仁翔 / chusiang.lai (at) gmail.com
# Blog: http://note.drx.tw
# Filename: makefile
# Modified: 2015-10-11 16:16
# Description: deploy tool for working-on-gnu-linux books.
# ===========================================================
OS_NAME := $(shell uname)
include Makefile.target
.PHONY: main html cp2clipboard install build pdf epub mobi update review push clean
main: build review
# 將 *.md 轉成 HTML 並複製到剪貼簿 (clipboard)。
cp2clipboard: $(md)
markdown_py $(md) > tmp.html
# remove <p> tags.
sed -i 's/<p>//g' tmp.html
sed -i 's/<\/p>//g' tmp.html
# remove <pre> tags.
sed -i 's/<pre>//g' tmp.html
sed -i 's/<\/pre>//g' tmp.html
# replace <code> to <blockquote> tags.
sed -i 's/<code>/<blockquote>/g' tmp.html
sed -i 's/<\/code>/<\/blockquote>/g' tmp.html
# add target="_blank" option into <a> tags.
sed -i 's/<a\ href/<a\ target="_blank"\ href/g' tmp.html
# copy html to 'clipboard'.
cat tmp.html | xclip
# 將 *.md 轉成 HTML 並使用 Chromium 開啟。
html: $(md)
markdown_py $(md) > tmp.html
chromium tmp.html
install:
gitbook install .
build:
gitbook build .
pdf:
gitbook pdf .
epub:
gitbook epub .
mobi:
gitbook mobi .
review:
ifeq (${OS_NAME}, Darwin)
open _book/index.html
else
firefox _book/index.html
endif
server:
gitbook serve
# 移除暫存檔。
clean:
-rm -rf tmp.html _book/ _books/ book.pdf book.epub book.mobi