zoukankan      html  css  js  c++  java
  • Gitbook环境搭建及制作——2019年10月24日

    1.gitbook介绍

    GitBook 是一个基于 Node.js 的命令行工具,支持 Markdown 和 AsciiDoc 两种语法格式,可以输出 HTML、PDF、eBook 等格式的电子书。可以把 GitBook 定义为文档格式转换工具。

    所以,GitBook 不是 Markdown 编辑工具,也不是 Git 版本管理工具。市面上我们可以找到很多 Markdown 编辑器,比如 Typora、MacDown、Bear、MarkdownPad、MarkdownX、JetBrains’s IDE(需要安装插件)、Atom、简书、CSDN 以及 GitBook 自家的 GitBook Editor 等等。

    这里写图片描述

    但 GitBook 又与 Markdown 和 Git 息息相关,因为只有将它们结合起来使用,才能将它们的威力发挥到极致!因此,通常我们会选择合适的 Markdown 编辑工具以获得飞一般的写作体验;使用 GitBook 管理文档,预览、制作电子书;同时通过 Git 管理书籍内容的变更,并将其托管到云端(比如 GitHub、GitLab、码云,或者是自己搭建的 Git 服务器),实现多人协作。

    实际上,GitBook Editor 对于新手来说是个不错的选择,它集成了 GitBook、Git、Markdown 等功能,还支持将书籍同步到 gitbook.com 网站,使我们可以很方便地编辑和管理书籍。

    2.安装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
    

    推荐的是 GitBook + Typora + Git,需要安装 Typora和 Git 版本管理工具。

    3.使用

    初始化
    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.生成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 提醒缺少组件

    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
    '); 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% [-------------------------------------------------------]
                                                                                   
    

    2019年10月24日20:17:34

  • 相关阅读:
    LeetCode153 Find Minimum in Rotated Sorted Array. LeetCode162 Find Peak Element
    LeetCode208 Implement Trie (Prefix Tree). LeetCode211 Add and Search Word
    LeetCode172 Factorial Trailing Zeroes. LeetCode258 Add Digits. LeetCode268 Missing Number
    LeetCode191 Number of 1 Bits. LeetCode231 Power of Two. LeetCode342 Power of Four
    LeetCode225 Implement Stack using Queues
    LeetCode150 Evaluate Reverse Polish Notation
    LeetCode125 Valid Palindrome
    LeetCode128 Longest Consecutive Sequence
    LeetCode124 Binary Tree Maximum Path Sum
    LeetCode123 Best Time to Buy and Sell Stock III
  • 原文地址:https://www.cnblogs.com/oneapple/p/12023665.html
Copyright © 2011-2022 走看看