折腾:
【记录】试用Gitbook Editor去编辑Markdown的文章
后,去参考:
去试试
gitbook serve
但是好像没有说在哪个路径下运行, 那就是可以全局运行了。
结果去试试:
1 2 3 4 5 6 7 8 9 10 11 | ➜ gitbook gitbook ls GitBook Versions Installed: * 3.2.3 Run "gitbook update" to update to the latest version. ➜ gitbook gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... FileNotFoundError: No "README" file (or is ignored) ➜ gitbook ll ➜ gitbook pwd /Users/crifan/dev/dev_root/gitbook |
(通过之前的Reveal in Finder而)找到Gitbook的book所在路径:
/Users/crifan/dev/dev_root/gitbook
对应着自己的刚新建的book
/Users/crifan/GitBook/Library/Import/httpzhi_shi_zheng_li
然后再去运行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ➜ httpzhi_shi_zheng_li git:(master) gitbook serve Live reload server started on port: 35729 Press CTRL+C to quit ... info: 7 plugins are installed info: loading plugin "livereload" ... OK 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 5 pages info: found 4 asset files info: >> generation finished with success in 0.7s ! Starting server ... Serving book on http: //localhost :4000 |
打开:
看看效果:
然后右上角的导出,国内的只有weibo:
其他微信等都不支持。有机会去加上试试。
后记:
看到:
-》
https://plugins.gitbook.com/plugin/sharing-plus
支持了QQ等国内的分享。
貌似没有微信?
现在是左边的TOC目录,并没有显示出对应的编号:
1 xxx
2 xxx
之类的目录。
希望是:
TODO:
1.添加生成文章中的自动显示章节的数字编号
比如
1
1.1
1.1.1
之类的
2.添加其他,比如微信等的分享
【导出html】
去试试编译出html
貌似上面的gitbook serve,就已经先build了
-》所以本地可以看到对应的_book文件夹了
-》里面有所有的内容:
其中gitbook文件夹中有所有的字体,样式等内容:
去试试:
1 2 3 4 5 6 7 8 9 10 11 12 | ➜ httpzhi_shi_zheng_li git:(master) ✗ 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 5 pages info: found 3 asset files info: >> generation finished with success in 1.5s ! |
看看上面已经看到过的输出的内容:
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 | ➜ httpzhi_shi_zheng_li git:(master) ✗ ll total 48 -rw-r--r-- 1 crifan staff 110B 11 12 16:02 README.md -rw-r--r-- 1 crifan staff 305B 11 12 17:46 SUMMARY.md drwxr-xr-x 11 crifan staff 374B 11 12 18:12 _book drwxr-xr-x 4 crifan staff 136B 11 12 17:00 assets -rw-r--r-- 1 crifan staff 352B 11 12 17:39 ch1_http_intro.md -rw-r--r-- 1 crifan staff 825B 11 12 17:03 httpde-dai-ma-fang-mian-de-ku.md -rw-r--r-- 1 crifan staff 1.3K 11 12 17:00 httpde-dian-xing-gou-cheng.md -rw-r--r-- 1 crifan staff 1.0K 11 12 17:22 httpde-request-zhong-de-can-shu-bian-ma-parameter-encoding.md ➜ httpzhi_shi_zheng_li git:(master) ✗ ll _book total 200 drwxr-xr-x 4 crifan staff 136B 11 12 18:12 assets -rw-r--r-- 1 crifan staff 8.7K 11 12 18:12 ch1_http_intro.html drwxr-xr-x 12 crifan staff 408B 11 12 18:12 gitbook -rw-r--r-- 1 crifan staff 9.9K 11 12 18:12 httpde-dai-ma-fang-mian-de-ku.html -rw-r--r-- 1 crifan staff 10K 11 12 18:12 httpde-dian-xing-gou-cheng.html -rw-r--r-- 1 crifan staff 10K 11 12 18:12 httpde-request-zhong-de-can-shu-bian-ma-parameter-encoding.html -rw-r--r-- 1 crifan staff 7.9K 11 12 18:12 index.html -rw-r--r-- 1 crifan staff 42K 11 12 18:12 search_index.json ➜ httpzhi_shi_zheng_li git:(master) ✗ ll _book /gitbook total 536 drwxr-xr-x 3 crifan staff 102B 11 12 18:12 fonts drwxr-xr-x 4 crifan staff 136B 11 12 18:12 gitbook-plugin-fontsettings drwxr-xr-x 4 crifan staff 136B 11 12 18:12 gitbook-plugin-highlight drwxr-xr-x 4 crifan staff 136B 11 12 18:12 gitbook-plugin-lunr drwxr-xr-x 6 crifan staff 204B 11 12 18:12 gitbook-plugin-search drwxr-xr-x 3 crifan staff 102B 11 12 18:12 gitbook-plugin-sharing -rw-r--r-- 1 crifan staff 103K 11 12 18:12 gitbook.js drwxr-xr-x 4 crifan staff 136B 11 12 18:12 images -rw-r--r-- 1 crifan staff 51K 11 12 18:12 style.css -rw-r--r-- 1 crifan staff 111K 11 12 18:12 theme.js |
如此,把整个_book文件夹上传到对应目录,即可显示了。
然后用ftp传到自己网站上,打开对应的地址:
https://www.crifan.com/files/doc/gitbook/http_summary/index.html
效果是:
总体还行。
【导出为PDF】
继续参考:
然后直接把app拖动到terminal可以得到其路径
1 2 | ➜ ~ /Applications/calibre .app ➜ calibre.app |
然后去:
1 2 3 4 5 6 7 8 | ➜ calibre.app sudo ln -s /Applications/calibre .app /Contents/MacOS/ebook-convert /usr/local/bin/ebook-convert Password: ➜ calibre.app ll /usr/local/bin/ebook-convert lrwxr-xr-x 1 root admin 54B 12 1 09:44 /usr/local/bin/ebook-convert -> /Applications/calibre .app /Contents/MacOS/ebook-convert ➜ calibre.app where ebook-convert /usr/local/bin/ebook-convert ➜ calibre.app which ebook-convert /usr/local/bin/ebook-convert |
然后继续去转换为pdf等其他格式
1 2 3 4 5 6 7 8 9 10 11 12 | ➜ htttp_summary git:(master) gitbook pdf . . /output/http_summary .pdf info: 9 plugins are installed info: 5 explicitly listed info: loading plugin "highlight" ... OK info: loading plugin "lunr" ... OK info: loading plugin "sharing" ... OK info: loading plugin "fontsettings" ... OK info: loading plugin "theme-default" ... OK info: found 19 pages info: found 26 asset files info: >> generation finished with success in 14.0s ! info: >> 1 file (s) generated |
导出的pdf:
PDF的效果:
效果还可以的。
再去转换其他格式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ➜ htttp_summary git:(master) gitbook epub ./ . /output/http_summary .epub info: 9 plugins are installed info: 5 explicitly listed info: loading plugin "highlight" ... OK info: loading plugin "lunr" ... OK info: loading plugin "sharing" ... OK info: loading plugin "fontsettings" ... OK info: loading plugin "theme-default" ... OK info: found 19 pages info: found 26 asset files info: >> generation finished with success in 8.2s ! info: >> 1 file (s) generated ➜ htttp_summary git:(master) gitbook mobi ./ . /output/http_summary .mobi info: 9 plugins are installed info: 5 explicitly listed info: loading plugin "highlight" ... OK info: loading plugin "lunr" ... OK info: loading plugin "sharing" ... OK info: loading plugin "fontsettings" ... OK info: loading plugin "theme-default" ... OK info: found 19 pages info: found 26 asset files info: >> generation finished with success in 12.9s ! info: >> 1 file (s) generated |
然后用之前安装的Calibre打开看看epub和mobi的效果:
更多内容详见:
另外,顺带去看看,gitbook去build,除了默认的website还支持其他的格式
json
1 2 3 4 5 6 7 8 9 10 11 | ➜ htttp_summary git:(master) gitbook build -- format =json . . /output info: 9 plugins are installed info: 5 explicitly listed info: loading plugin "highlight" ... OK info: loading plugin "lunr" ... OK info: loading plugin "sharing" ... OK info: loading plugin "fontsettings" ... OK info: loading plugin "theme-default" ... OK info: found 19 pages info: found 26 asset files info: >> generation finished with success in 0.8s ! |
的效果:
输出ebook:
1 2 3 4 5 6 7 8 9 10 11 | ➜ htttp_summary git:(master) gitbook build -- format =ebook . . /output info: 9 plugins are installed info: 5 explicitly listed info: loading plugin "highlight" ... OK info: loading plugin "lunr" ... OK info: loading plugin "sharing" ... OK info: loading plugin "fontsettings" ... OK info: loading plugin "theme-default" ... OK info: found 19 pages info: found 26 asset files info: >> generation finished with success in 1.2s ! |
效果
【总结】
Gitbook中,导出pdf等其他格式的步骤是:
1.安装Calibre
去https://calibre-ebook.com/download下载到Mac的calibre-3.12.0.dmg
打开,拖到 应用程序中,即可看到:calibre.app
2.把calibre.app加入到PATH
sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin/ebook-convert
然后可以用:
which ebook-convert
确认的确terminal中可以找到ebook-convert
3.去转换不同格式:
创建输出目录:
mkdir output/pdf output/epub output/mobi output/website
导出不同格式,website/pdf/epub/mobi:
<code>gitbook build . ./output/website gitbook pdf . ./output/pdf/http_summary.pdf gitbook epub . ./output/epub/http_summary.epub gitbook mobi . ./output/mobi/http_summary.mobi </code>
输出的文件:
更多的文件结构方面详见:
转载请注明:在路上 » 【记录】Gitbook的本地预览和导出为html和PDF等其他格式