• Please indicate the source of reprint, thank you

Elementary (suitable for children with no programming background)

Use GitBook Editor to write open source books

This is gitbook official editor, easy to use

First download the GitBook Editor





GitBook Editor

Download it at www.gitbook.com/editor

Supports Mac, Linux, and Windows

The installation
Windows
  • downloadgitbook-win.zip;
  • Decompression;
  • Open theGitBook.exeInstallation;
Mac
  • downloadgitbook-mac.dmgCan be installed
Linux
  • downloadgitbook-linux32.tar.gz
  • usetar -xvzf gitbook-linux32.tar.gzUnpack the
  • Run the scriptcd GitBook && ./install.shThe installation

use

After the installation, if you have a Github account, log in directly, but after logging in with Github, you also need to set the mailbox and password of Gitbook, which will be used later. If you do not have an account, you can register directly.

After login, you can create books directly on GitBook. It is recommended to create books on gitbook website and clone them through Gitbook Editor.

Clone can directly write books after the first feeling is not particularly easy? Don’t worry, for more fun writing needs to continue to see the following.

How to sync with Github?

If you don’t have a github account, register with github https://www.gitbook.com/@quanke/settings#social.

Github: https://www.gitbook.com/@quanke/settings#github Reconnect GitHub Account Select With Access to Public Repositories

Once the authorization is done, we go to the Settings page of the book, Click Settings making https://www.gitbook.com/book/quanke/vert-x-core-manual-for-java/settings/github (quanke replaced with your user name, Replace vert-X-core-manual-for-java with title)

If the book was originally written on Github, enter the Address of Github directly. If the account is newly created and nothing is available, click Export to Github.

If the above steps work, just click Add WebHook to Add a hook to Github, which tells Gitbook when your Github updates

In your GitBook Editor, open the Book we just cloned, go to Book -> Repository Settings, and set this to the github address. Then you can write in the GitBook Editor. Have what don’t understand, can leave a message to ask me directly

Advanced (suitable for children with programming foundation)

Gitbook installation

  1. INSTALL NPM Download the Node. js source code from nodejs.org/#download (click the green INSTALL) and decompress it
./configure
make
make install 
Copy the code

After successful execution, NPM is installed.

  1. Gitbook installation
npm install -g gitbook-cli
Copy the code
gitbook -V 
Copy the code

Check whether gitBook is installed successfully.

Gitbook use

  1. Generate a book structure from a catalog
1.1 Readme. md and SUMMARY writingCopy the code

README.md

This file is the equivalent of an introduction to a Gitbook.

$ mkdir test_gitbook
$ touch README.md
Copy the code

SUMMARY.md

This file is the directory structure of a book, using Markdown syntax, as in our book summary.md:

$ touch SUMMARY.md
$ vim SUMMARY.md
Copy the code

The input

- [section1](chapter1/section1.md) - [section2](chapter1/section2.md) * (chapter2/section1.md) - (chapter2/section2.md) - (chapter2/section2.md) * (end/ readme.md)Copy the code

1.2 Generate the book structure

Once the directory file is created, we can use the command line tools of Gitbook to generate the corresponding directories and files from the directory structure:

$gitbook init $treeCopy the code
. ├ ─ ─ chapter1 │ ├ ─ ─ the README. Md │ ├ ─ ─ section1. Md │ └ ─ ─ section2. Md ├ ─ ─ chapter2 │ ├ ─ ─ the README. Md │ ├ ─ ─ section1. Md │ └ ─ ─ ├── bass exercises, exercises, exercises, exercises, exercisesCopy the code

As you can see, Gitbook gives us the directories and files that correspond to summary.md.

In each directory, there is a readme.md file, equivalent to a chapter of description.

  1. Generate the books

2.1 Output as static website

You can output a static site in two ways:

2.1.1 Automatically generated during local preview

Once you’ve edited the book on your computer, you can preview it locally using Gitbook’s command line:

$ gitbook serve .
Copy the code

Then type http://localhost:4000 into your browser to preview the resulting book organized as a web page.

Here you will notice that you have added a file directory named _book to your book project directory, and the files in this directory are the generated static site content.

Instead of previewing a static website file, you can use this command to type content into the desired directory:

$ mkdir /tmp/gitbook
$ gitbook build --output=/tmp/gitbook
Copy the code

2.2 the output PDF

Input as PDF file, you need to install gitbook PDF using NPM first:

$ sudo npm install gitbook-pdf -g
Copy the code

I have the following error while executing the above command:

*************************************************** Downloading Saving to http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-i686.tar.bz2 / usr/local/lib/node_modules/gitbook - PDF/node_modules/phantomjs/phantomjs/phantomjs - 1.9.7 - Linux - i686. Tar. The.bz2 Error: connect ETIMEDOUT at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19) npm ERR! Linux 3.2.0-4-686 - pae NPM ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "gitbook-pdf" "-g" npm ERR! The node v0.12.7 NPM ERR! NPM v2.11.3 NPM ERR! code ELIFECYCLE npm ERR! [email protected] install: 'node install.js' NPM ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script 'node install.js'. NPM ERR! This is most likely a problem with the phantomjs package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node install.js npm ERR! You can get their info via: npm ERR! npm owner ls phantomjs npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /home/wangxq/repository/phantomjs/npm-debug.log ***************************************************Copy the code

As you can see from the first line of the error report, the error occurred because phantomJS had been downloaded incorrectly, so we needed to download and install it manually.

Solutions: [1]

$ git clone git://github.com/ariya/phantomjs.git $ sudo apt-get install build-essential g++ flex bison gperf ruby perl \  libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \ libpng-dev libjpeg-dev python libx11-dev $CD Phantomjs $git checkout 1.9.7 Here 1.9.7 is the phantom version number, /build.sh --jobs 4 $sudo cp bin/phantomjs /bin/ $sudo NPM install gitbook-pdf -g #Copy the code

Then, to get the PDF file, install the dependent libraries first using the following command:

$sudo apt-get install Calibre $gitbook -v 2.1.0 PDF.Copy the code

Error:

***************************************************** info: start conversion to pdf .... ERROR Error: Command failed: /bin/sh -c ebook-convert /tmp/tmp-29384ctltwbk/SUMMARY.html /tmp/tmp-29384ctltwbk/index.pdf --title="" -- Comments =" This book is an example of gitbook "--language="en" --book-producer=" gitbook" -- Publisher =" gitbook" --chapter="descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]" --chapter-mark="pagebreak" --page-breaks-before="/" --level1-toc="descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]" --level2-toc="descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]" --level3-toc="descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]" --no-chapters-in-toc --max-levels="1" --breadth-first --margin-left="62" --margin-right="62" --margin-top="56" --margin-bottom="56" --pdf-default-font-size="12" --pdf-mono-font-size="12" --paper-size="a4" --pdf-header-template="<p class='header'><span></span></p>" --pdf-footer-template="<p class='footer'><span>_SECTION_</span> <span style='float:right; '>_PAGENUM_</span></p>" Usage: ebook-convert input_file output_file [options] Convert an ebook from one format to another. input_file is the input and output_file is the output. Both must be specified as the first two arguments to the command. The output ebook format is guessed from the file extension of output_file. output_file can also be of the special format .EXT where EXT is the output file extension. In this case, the name of the output file is derived the name of the input file. Note that the filenames must not start with a hyphen.  Finally, if output_file has no extension, then it is treated as a directory and an "open ebook" (OEB) consisting of HTML files is written to that directory. These  files are the files that would normally have been passed to the output plugin. After specifying the input and output file you can customize the conversion by specifying various options. The available options depend on the input and output file types. To get help on them specify the input and output file and then use the -h option. For full documentation of the conversion system see http://manual.calibre-ebook.com/conversion.html Whenever you pass arguments to ebook-convert that have spaces in them, enclose the arguments in quotation marks. ebook-convert: error: no such option: --pdf-default-font-size *****************************************************Copy the code

Solution [2]

$ sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); Main ()" $gitbook -v 2.1.0 PDFCopy the code

The problem

If you enter the gitbook init command, Installing Version 2.1.0 appears, and you need to wait patiently for the installation.

General Department Longting ▼ promotion and salary increase





image