Gitbook tutorial

Gitbook tutorial

GitBook is a Node.js-based command-line tool that supports Markdown and AsciiDoc syntax formats, and can output e-books in HTML, PDF, eBook and other formats

Install

Since gitbook is based on node.js, you need to install node before installing gitbook.

npm install -g gitbook-cli

Check if the installation was successful

gitbook -V

use

Create a new folder, such as myBooks, and perform the following operations in this folder.

initialization

gitbook init

At this time, two more files, README.md and SUMMARY.md, will be found in the myBooks directory. README.md is used to introduce the project, and Summary.md is used to write the chapter directory of gitbook.

start up

gitbook serve

After executing the above command, enter http://localhost:4000 in the address bar of the browser according to the prompt to visit and you can see the basic effect, as shown in the figure below.
insert image description here

Generate _book folder

gitbook build

After running this command, a _book folder will be generated in the myBooks folder, and the content inside is the generated html file. You can also use the following command to generate a web page without opening the server.

directory writing

The directory structure of gitbook is mainly determined by the SUMMARY.md file, which expresses the parent-child relationship of files through the list syntax in Markdown. A simple example is shown below.

# 目录

* [前言](README.md)
* [vue](vue/README.md)
  * [第1节:vue指令总结与介绍](vue/指令.md)
  * [第2节:vue动画总结与介绍](vue/动画.md)
* [vue-router](vue-router/README.md)
  * [第1节:vue-router的模式简介](vue-router/模式.md)
  * [第2节:命名路由](vue-router/命名路由.md)
* [vuex](vuex/README.md)
* [移动端插件](mobile/README.md)
* [PC端插件](PC/README.md)
* [问题整理](Questions/README.md)

directory generation

After the catalog is written, enter the following command on the command line, and start the project again after execution to preview the final effect.

gitbook init

GitBook looks for the directories and files described in the SUMMARY.md file and creates them if none exist.

insert image description here

Other command finishing

  1. The build command specifies the path
gitbook build [书籍路径] [输出路径]
  1. The serve command specifies the port
gitbook serve --port 2333
  1. Generate eBooks in PDF format
gitbook pdf ./ ./mybooks.pdf
  1. Generate eBooks in epub format
gitbook epub ./ ./mybooks.epub
  1. Generate eBooks in epub format
gitbook mobi ./ ./mybooks.mobi

Reference address
link 1
link 2

Guess you like

Origin blog.csdn.net/weixin_39893889/article/details/106062174