Gitbook environment to build and production - October 24, 2019

1.gitbook Introduction

GitBook is a Node.js based command-line tools, support and AsciiDoc two syntaxes Markdown format, e-books can output HTML, PDF, eBook and other formats. GitBook can be defined as a document format conversion tools.

So, GitBook not Markdown editing tools, nor Git version management tool. The market we can find a lot of Markdown editor, such as Typora, MacDown, Bear, MarkdownPad, MarkdownX, JetBrains's IDE (need to install plug-ins), Atom, Jane books, CSDN and GitBook own GitBook Editor, and so on.

Write pictures described here

GitBook but also with Markdown and Git are closely related, because only they are used in combination, in order to have their power into full play! So, usually we will choose the right Markdown editing tools to get the experience of flying in general writing; use GitBook document management, preview, making e-books; at the same time by changing the Git book content management and hosting it in the cloud (such as GitHub, GitLab , code cloud, or build their own Git server), to achieve more than collaboration.

In fact, GitBook Editor for the novice is a good choice, it integrates GitBook, Git, Markdown and other functions, also supports sync books to gitbook.com site, so that we can easily edit and manage books.

2. Install gitbook

#npm install -g gitbook-cli

#gitbook

gitbook

  Usage: gitbook [options] [command]

  Options:
    -v, --gitbook [version]  specify GitBook version to use
    -d, --debug              enable verbose error
    -V, --version            Display running versions of gitbook and gitbook-cli
    -h, --help               output usage information


  Commands:
    ls                        List versions installed locally
    current                   Display currently activated version
    ls-remote                 List remote versions available for install
    fetch [version]           Download and install a <version>
    alias [folder] [version]  Set an alias named <version> pointing to <folder>
    uninstall [version]       Uninstall a version
    update [tag]              Update to the latest version of GitBook
    help                      List commands for GitBook
    *                         run a command with a specific gitbook version

Recommended is GitBook + Typora + Git, you need to install Typora and Git version management tool.

3. Use

初始化
gitbook init

apple$ gitbook init
warn: no summary file in this book 
info: create README.md 
info: create SUMMARY.md 
info: initialization is finished 

修改SUMMARY.md

# Summary

* [前言](README.md)
* [第一章](Chapter1/README.md)
    * [第1节:衣](Chapter1/衣.md)
    * [第2节:食](Chapter1/食.md)
    * [第3节:住](Chapter1/住.md)
    * [第4节:行](Chapter1/行.md)
* [第二章](Chapter2/README.md)
* [第三章](Chapter3/README.md)
* [第四章](Chapter4/README.md)

再次gitbook init

本地起服务
gitbook serve

访问链接
localhost:4000

gitbook serve --port 2333

image-20191024201523003

4. Generate pdf

生成 PDF 格式的电子书
gitbook pdf ./ ./mybook.pdf

ryks-MacBook-Pro-4:gitbook_collections apple$ gitbook pdf ./ ./mybook.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 9 pages 
info: found 0 asset files 
info: >> generation finished with success in 5.4s ! 
info: >> 1 file(s) generated 

生成 epub 格式的电子书
gitbook epub ./ ./mybook.epub

生成 mobi 格式的电子书
gitbook mobi ./ ./mybook.mobi

4.1 remind missing components

InstallRequiredError: “ebook-convert” is not installed.

1.下载calibre,并链接
ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin

2.在线下载

sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"

Installing to /opt/calibre
Downloading tarball signature securely...
Will download and install calibre-4.2.0-x86_64.txz 
                      Downloading calibre-4.2.0-x86_64.txz                      
  0% [-------------------------------------------------------]
                                                                               

October 24, 2019 20:17:34

Guess you like

Origin www.cnblogs.com/oneapple/p/12023665.html
Recommended