This article is a mirror article of machine translation, please click here to jump to the original article.

View: 7163|Reply: 0

Getting started with GitBook tutorials

[Copy link]
Posted on 11/23/2018 2:03:54 PM | | | |
GitBook is a Node.js-based command-line tool that supports Markdown and AsciiDoc syntax formats, and can output eBooks in HTML, PDF, eBook, and other formats.

Install node.js

Before using the gitbook tool, the computer needs to install node.js environment, and after installation, you can check the version command to test whether the installation is successful:


Install Gitbook

Gitbook is installed with npm, command line:



Run the command below to see the GitBook version to verify that the installation was successful.

Install historical versions

gitbook-cli makes it easy to download and install other versions of GitBook to test your books:



Using gitbook ls-remote enumerates the versions that can be downloaded.


Markdown editor

Here we use Markdown syntax as the writing language for our documents, we need to prepare a Markdown editor, we can find many Markdown editors on the market, such as Typora, MacDown, Bear, MarkdownPad, MarkdownX, JetBrains' IDE (requires plugin installation), Atom, Jianshu, CSDN and GitBook's own one GitBook Editor and so on.

I have VS code development tools installed on my computer, vs code supports markdown by default, I only need to install a preview plugin artifact: Markdown Preview Enhanced, and I will use it!



Recommended by friends Editor typora, address:The hyperlink login is visible.

Initialize a book

GitBook can set up a boilerplate:

If you wish to create a book into a new directory, you can do so by running gitbook init ./directory.

After execution, you will see two more files - README.md and SUMMARY.md, which do the following:

README.md - The introduction of the book is written in this document
SUMMARY.md - The catalog structure of the book is configured here



I'm not familiar with markdown syntax, so just write a few sentences!






Generate static web pages

Generate static web pages and run servers

All of the above will be generated in the book catalog _book.


The serve command can also specify the port:




When generating, specify the version of gitbook, and it will not be downloaded locally first



Lists all local gitbook versions



List the versions of gitbook that are available remotely



Install the corresponding gitbook version



Update to the latest version of gitbook



Uninstall the corresponding gitbook version


Specifies the level of log



Output error message



Summary

GitBook uses SUMMARY.md files to define the structure of the book's chapters and subchapters. SUMMARY.md File is used to generate the table of contents of the book.

The format of SUMMARY.md is a list of links. The title of the link will serve as the title of the chapter, and the link will be targeted at the path to that chapter file.

Adding a nested list to the parent chapter creates a child chapter.

Simple example:


Then we go back to the command line and run the gitbook init command again in the mybook folder. GitBook looks for directories and files described in SUMMARY.md files,If not, it is created

Output PDF, ePub or mobi files

If you want to generate a pdf version, you can run gitbook pdf, in the same way, if you are exporting epub format, gitbook epub, if it is mobi format, gitbook mobi will do.



If you want to export an e-book in PDF, ePub or mobi format,Requires Calibre eBook Reader/Manager and command line tools, otherwise an error may be reported "EbookError: Error during ebook generation: 'ebook-convert'".

Features of GitBook Special Files:

file
description
book.jsonConfiguration Data (optional)
README.mdForeword or introduction to the eBook (required)
SUMMARY.mdE-book catalog (optional)
GLOSSARY.mdList of vocabulary/annotation terms (optional)
Gitbook General Settings

GitBook allows you to customize your ebook with flexible configurations.

These options are specified in the book.json file. For authors who are not familiar with JSON syntax, you can verify the syntax using tools like JSONlint.

variable
description
rootThe path to the root folder that contains all the book files, except book.json
structureSpecify paths for readme, abstracts, glossaries, etc
titleYour book title, the default value is extracted from the README. On GitBook.com, this field is pre-populated.
descrip{filter}tionThe description of your book, the default value is extracted from the README. On GitBook.com, this field is pre-populated.
authorAuthor's name. On GitBook.com, this field is pre-populated.
isbnISBN
languageThe language type of this book is ISO code. The default value is en
directionText reading order. It can be RTL (right-to-left) or LTR (left-to-right), and the default value depends on the value of the language.
gitbookThe GitBook version should be used. Use the SemVer specification and accept conditions similar to "> = 3.0.0".





Previous:Have you snapped up the Bona Cloud code?
Next:Write the correct pose for markdown in vscode
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com