II. Local Gitbook Builder
Contributed by Xupeng Chen
Gitbook 新版不再支持pdf和其他静态导出,也不再兼容旧版command line版本,旧版command line不支持右边栏和一些hint和embed语法,需要第三方插件,

Install command line gitbook tool

先安装brew和npm两个包管理软件
1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copied!
1
brew install node
2
brew install npm
Copied!
再用npm安装gitbook
1
npm install gitbook -g
2
npm install gitbook-cli -g
3
gitbook -V #查看版本gitbook和gitbook-cli版本
Copied!

Install packages for gitbook tool

book.json中填入插件名称,then run gitbook install就可以自动安装依赖的插件。安装新版gitbook的一些替代插件以及一些额外的美化插件。
urlembed取代embed,效果不是很完美,tabs也没有新版gitbook的效果 插件用法
1
{% urlembed %}
2
https://website.org/stuff/this-is-the-path-name
3
{% endurlembed %}
Copied!
1
{% tabs first="First Tab", second="Second Tab", third="Third Tab" %}
2
3
{% content "first" %}
4
Content for first tab ...
5
6
{% content "second" %}
7
Content for second tab ...
8
9
{% content "third" %}
10
Content for third tab ...
11
12
{% endtabs %}
Copied!

Build gitbook (html)

1
gitbook init #自动生成SUMMARY.md,但多级目录似乎无法找到,建议略过这一步用手工编辑版本
2
gitbook serve #可在浏览器预览,默认在http://localhost:4000
3
gitbook build #产生html
Copied!

How to build pdf/epub

    链接到bin
    ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin
    产生pdf gitbook pdf . training_book.pdf
Last modified 2yr ago