gitbook installation:
/#download
Download the source code (click on the green INSTALL),
Decompression
./configure make make install
After successful execution, npm is installed.
2. gitbook installation command
npm install -g gitbook-cli gitbook -V
Check whether the gitbook is installed successfully.
ref
===
1. /gitbook-zh/
gitbook usage
===========
1. Generate book structure from the directory
1.1 Written with SUMMARY
This file is equivalent to an introduction to a Gitbook.
$ mkdir test_gitbook $ touch
This file is a directory structure of a book, using Markdown syntax.
As in our book:
$ touch $ vim
enter
* [Introduction]()
* [Chapter 1](chapter1/)
- [Section 1](chapter1/)
- [Section 2](chapter1/)
* [Chapter 2](chapter 2/)
- [Section 1](chapter2/)
- [Section 2](chapter2/)
* [End](end/)
1.2 Generate a book structure
After this directory file is created, we can use Gitbook
The command line tool generates the corresponding directory and files for this directory structure:
$ gitbook init $ tree . #View created directories and files
├── chapter1
│ ├──
│ ├──
│ └──
├── chapter2
│ ├──
│ ├──
│ └──
├── end
│ └──
├──
└──
We can see that gitbook generates the
Corresponding directories and files.
In each directory, there is a file, which is equivalent to the description of a chapter.
2. Generate a book
2.1 Output as a static website
There are two ways to output a static website:
2.1.1 Automatically generate during local preview
After you have edited your book on your computer, you can use Gitbook
The command line is previewed locally:
$ gitbook serve .
Then enter:
http://localhost:4000
This allows you to preview your students
Books organized in web form.
Here you will find that you have an additional name in the directory of your book project
_book file directory, and the files in this directory are generated static
Website content.
Use the build parameter to generate to the specified directory
Unlike the static website file generated directly preview, use this command,
You can enter the content into the directory you want:
$ mkdir /tmp/gitbook $ gitbook build --output=/tmp/gitbook
2.2 Output PDF
Enter as a PDF file, you need to use NPM to install gitbook pdf:
$ sudo npm install gitbook-pdf -g
I got the following error when executing the above command:
***************************************************
Downloading /ariya/phantomjs/downloads/phantomjs-1.9..bz2 Saving to /usr/local/lib/node_modules/gitbook-pdf/node_modules/phantomjs/phantomjs/phantomjs-1.9..bz2 Error: connect ETIMEDOUT at exports._errnoException (:746:11) at [as oncomplete] (: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! node v0.12.7 npm ERR! npm v2.11.3 npm ERR! code ELIFECYCLE npm ERR! [email protected] install: `node ` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script 'node '. 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 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/
***************************************************
From the first line of the error report content, we can know that the reason for the error is download
There was an error in phantomjs, so we need to download and install it manually.
Solution: [1]
$ git clone git:///ariya/ $ 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 libxext-dev #Installing and compiling tools and dependencies$ cd phantomjs $ git checkout 1.9.7 #Note: 1.9.7 here is the version number of phantom, which can be found by the first line of the error report$ ./ --jobs 4 $ sudo cp bin/phantomjs /bin/ $ sudo npm install gitbook-pdf -g #Reinstall
Then, use the following command to install the dependency library to PDF file:
$ sudo apt-get install calibre $ gitbook -v 2.1.0 pdf .
An error occurred:
*****************************************************
info: start conversion to pdf ....ERROR Error: Command failed: /bin/sh -c ebook-convert /tmp/tmp-29384ctltwbk/ /tmp/tmp-29384ctltwbk/ --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 / 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
*****************************************************
Solution[2]
$ sudo -v && wget -nv -O- /kovidgoyal/calibre/master/setup/ | sudo python -c "import sys; main=lambda:('Download failed\n'); exec(()); main()" $ gitbook -v 2.1.0 pdf . # Re-execute the command to generate pdf, the target file is
ref
===
1. / 2. /download_linux
question
===
1. If you enter the gitbook init command, Installing version 2.1.0 appears.
Need to wait for installation.
The above are the installation and use information of gitbook I compiled. Thank you for your support!