最近需要研究ELK,然后在網上發現了有本書寫的不錯,然后搜到是在 github 上開源過的。這本書的時間有點久了,就想通過源碼自己來生成一個 pdf
我使用的是 ubuntu 系統
step1:安裝 gitbook 工具
gitbook 依賴與nodejs,我剛開始嘗試源碼安裝,后來遇到 npm 的一個環境問題放棄了。如果需要手動安裝的自行查找教程。
我使用的是:apt-get install -y node
sudo apt-get install nodejs
sudo apt-get install npm
使用 npm 安裝 gitbook
npm install gitbook-cli -g
step2:下載源碼
root@pc:/mnt/share# git clone https://github.com/chenryn/ELKstack-guide-cn.git 正克隆到 'ELKstack-guide-cn'... remote: Enumerating objects: 1, done. remote: Counting objects: 100% (1/1), done. remote: Total 2349 (delta 0), reused 0 (delta 0), pack-reused 2348 接收對象中: 100% (2349/2349), 8.61 MiB | 1.53 MiB/s, 完成. 處理 delta 中: 100% (1395/1395), 完成. 正在檢出文件: 100% (287/287), 完成.
step3:進入到源碼目錄,執行命令 gitbook build
root@pc:/mnt/share/ELKstack-guide-cn# gitbook build
info: 7 plugins are installed info: 6 explicitly listed info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 157 pages info: found 128 asset files info: >> generation finished with success in 43.8s !
step4:gitbook pdf 生成pdf
root@pc:/mnt/share/ELKstack-guide-cn# gitbook pdf info: 7 plugins are installed info: 6 explicitly listed info: loading plugin "highlight"... OK info: loading plugin "search"... OK info: loading plugin "lunr"... OK info: loading plugin "sharing"... OK info: loading plugin "fontsettings"... OK info: loading plugin "theme-default"... OK info: found 157 pages info: found 128 asset files info: >> generation finished with success in 266.9s ! info: >> 1 file(s) generated
注意:如果 gitbook 命令執行過程中,提示缺少插件,再執行 gitbook install 安裝
最后會在當前目錄生成 pdf 文件
gitbook 支持的格式有 ePub, Mobi, PDF