Gitbook to make an ebook detailed tutorial _linux shell

Source: Internet
Author: User
Tags bz2 mkdir touch git clone

Gitbook Installation:

 

Download Node.js source code (click on the Green install),

Extract

./configure Make

After successful execution, NPM is installed.

2. Gitbook installation command

NPM install-g GITBOOK-CLI


See if the Gitbook is installed successfully.

Ref

===

1. wanqingwong.com/gitbook-zh/index.html

Gitbook use

===========

1. Build the book structure according to the catalogue

1.1 Readme.md and summary writing

Readme.md

This file is equivalent to a gitbook introduction.

$ mkdir test_gitbook
$ touch readme.md

Summary.md

This file is the directory structure of a book, using Markdown syntax,

Like the summary.md of our book:

$ touch summary.md
$ vim summary.md

Input

* [Introduction] (README.MD)
* [First chapter] (CHAPTER1/README.MD)
-[first section] (CHAPTER1/SECTION1.MD)
-[Sect. II] (CHAPTER1/SECTION2.MD)
* [Chapter II] (CHAPTER2/README.MD)
-[first section] (CHAPTER2/SECTION1.MD)
-[Sect. II] (CHAPTER2/SECTION2.MD)
* [end] (END/README.MD)

1.2 Build book Structure

When this directory file is created, we can use the Gitbook

Command line tool to generate the appropriate directories and files for this directory structure:

$ gitbook init
$ tree. #查看建立的目录和文件

├──chapter1
│├──readme.md
│├──section1.md
│└──section2.md
├──chapter2
│├──readme.md
│├──section1.md
│└──section2.md
├──end
│└──readme.md
├──readme.md
└──summary.md

We can see that Gitbook gives us a build up with summary.md
The corresponding directory and file.

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

2. Generate Books

2.1 Output as static web site

You have two ways of outputting a static Web:

Automatically generated when 2.1.1 Local preview

When you edit a good book on your computer, you can use the Gitbook
For a local preview of the command line:

$ gitbook serve.

Then enter in the browser:

 

This allows you to preview the live
into a book organized in the form of a Web page.

Here you will find that you have a more than one in the directory of your book project called
_book file directory, and the files in this directory, that is, the generated static
Website content.

Using the build parameter to generate to the specified directory

Unlike the static web site files generated directly from the preview, using this command,
You can enter the content into the directory you want:

$ mkdir/tmp/gitbook
$ gitbook Build--output=/tmp/gitbook

2.2 Output PDF

As a PDF file, you need to first use NPM to install the Gitbook PDF:

$ sudo npm install gitbook-pdf-g

The following error occurred while I was executing the above command:

***************************************************

Downloading http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-i686.tar.bz2 saving to/usr/ LOCAL/LIB/NODE_MODULES/GITBOOK-PDF/NODE_MODULES/PHANTOMJS/PHANTOMJS/PHANTOMJS-1.9.7-LINUX-I686.TAR.BZ2 Error: Connect etimedout at Exports._errnoexception (util.js:746:11) at tcpconnectwrap.afterconnect [as OnComplete] (net.js:1 010: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! Phantomjs@1.9.7-5 Install: ' node Install.js ' NPM err!
Exit Status 1 npm err! NPM err!
Failed at the phantomjs@1.9.7-5 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, this is 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 and any support REQUEST:NPM err! /home/wangxq/repository/phantomjs/npm-debug.log

***************************************************

The first line of the error report content can tell that the error occurred because the download

Phantomjs An error occurred, so we need to download and install it manually.

WORKAROUND: [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 Libxext-dev    #安装编译需要的工具和依赖
$ cd phantomjs
$ git Checkout 1.9.7 # Note: The 1.9.7 here is the Phantom version number, which can be found in the first line of the error report 
$./build.sh--jobs 4
$ sudo cp bin/phantomjs/bin/
$ sudo npm Install Gitbook-pdf-g #重新进行安装

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

$ 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/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 (@ 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=" "--margin-right=" 62 "-- margin-top= "--margin-bottom=" "--pdf-default-font-size=" "--pdf-mono-font-size="--paper-size= "A4"-- pdf-header-template= "<p class= ' header ' &GT;<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 fo


Rmat to another. Input_file is the input and output_file is the output.


Both must be specified as the "the" "the" the "the" the "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. The filenames must not start with a hyphen. Finally, if Output_file has no extension, then it is treated as a directory and a "open ebook" (Oeb) consisting of HTML F Iles is written to that directory.


These files are the "files" would normally have been passed to the output plugin. After specifying the input and output filE 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 with Use the-h option. For full documentation of the conversion system http://manual.calibre-ebook.com/conversion.html whenever your pass AR


Guments to Ebook-convert which have spaces in them, enclose the arguments in quotation. Ebook-convert:error:no such option:--pdf-default-font-size

*****************************************************

Workaround [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 PDF. # re-execute command to generate PDF, target file is Book.pdf

Ref

===

1. http://phantomjs.org/build.html
2 Http://calibre-ebook.com/download_linux

Problem

===

1. If you enter the Gitbook init command, installing version 2.1.0 appears,

Patience is required to wait for installation.

The above is I tidy up the Gitbook installation and use of information, thank you for your support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.