gitbook安装与使用
废话不说,直接主题:
gitbook安装
===========
1. 安装npm
从站点 https://nodejs.org/#download 下载node.js源码(点击绿色的INSTALL),
解压
./configure
make
make install
成功运行后。npm就被安装好了。
2. gitbook 安装
npm install -g gitbook-cli
gitbook -V
查看gitbook是否成功安装。
ref
===
1. wanqingwong.com/gitbook-zh/index.html
gitbook使用
===========
1. 依据文件夹生成图书结构
1.1 README.md 与 SUMMARY编写
README.md
这个文件相当于一本Gitbook的简单介绍。
$ mkdir test_gitbook
$ touch README.md
SUMMARY.md
这个文件是一本书的文件夹结构,使用Markdown语法。
如我们这本书的SUMMARY.md:
$ touch SUMMARY.md
$ vim SUMMARY.md
输入
* [简单介绍](README.md)
* [第一章](chapter1/README.md)
- [第一节](chapter1/section1.md)
- [第二节](chapter1/section2.md)
* [第二章](chapter2/README.md)
- [第一节](chapter2/section1.md)
- [第二节](chapter2/section2.md)
* [结束](end/README.md)
1.2 生成图书结构
当这个文件夹文件创建好之后,我们能够使用Gitbook
的命令行工具将这个文件夹结构生成对应的文件夹及文件:
$ gitbook init
$ tree . #查看建立的文件夹和文件
.
├── chapter1
│ ├── README.md
│ ├── section1.md
│ └── section2.md
├── chapter2
│ ├── README.md
│ ├── section1.md
│ └── section2.md
├── end
│ └── README.md
├── README.md
└── SUMMARY.md
我们能够看到,gitbook给我们生成了与SUMMARY.md所
相应的文件夹及文件。
每一个文件夹中,都有一个README.md文件,相当于一章的说明。
2. 生成图书
2.1 输出为静态站点
你有两种方式输出一个静态站点:
2.1.1 本地预览时自己主动生成
当你在自己的电脑上编辑好图书之后,你能够使用Gitbook
的命令行进行本地预览:
$ gitbook serve .
然后浏览器中输入 http://localhost:4000 就能够预览生
成的以网页形式组织的书籍。
这里你会发现。你在你的图书项目的文件夹中多了一个名为
_book的文件文件夹,而这个文件夹中的文件,即是生成的静态
站点内容。
使用build參数生成到指定文件夹
与直接预览生成的静态站点文件不一样的是,使用这个命令,
你能够将内容输入到你所想要的文件夹中去:
$ mkdir /tmp/gitbook
$ gitbook build --output=/tmp/gitbook
2.2 输出PDF
输入为PDF文件。须要先使用NPM安装上gitbook pdf:
$ sudo npm install gitbook-pdf -g
我在运行上面这条命令的时候出现了以下的错误:
***************************************************
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: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! 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 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
***************************************************
由错误报告内容的第一行能够知道。错误发生的原因是下载
phantomjs发生了错误。因此我们须要手动下载和安装。
解决方法:[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 #注意:这里的1.9.7是phantom的版本。能够由错误报告的第一行找出
$ ./build.sh --jobs 4
$ sudo cp bin/phantomjs /bin/
$ sudo npm install gitbook-pdf -g #又一次进行安装
然后。使用以下的命令,要PDF文件。首先安装依赖库:
$ sudo apt-get install calibre
$ gitbook -v 2.1.0 pdf .
错误发生:
*****************************************************
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="这本书是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
*****************************************************
解决方法[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 . # 又一次运行命令生成pdf,目标文件为book.pdf
ref
===
1. http://phantomjs.org/build.html
2. http://calibre-ebook.com/download_linux
问题
===
1. 假设输入gitbook init命令。出现Installing version 2.1.0,
须要耐性等待安装。
gitbook安装与使用的更多相关文章
- gitbook安装与使用之windows下搭建gitbook平台
最近需要在GitBook中去阅读电子书 安装nodejs cnpm安装gitbook 解压书籍文件,并cd到书籍文件目录 gitbook serve 浏览器访问localhost:4000 先在win ...
- Gitbook安装
Gitbook安装 Gitbook是从NMP安装的,命令行: $ npm install gitbook -g 安装完之后,你可以检验下是否安装成功: $ gitbook -V 0.4.2 如果你看到 ...
- [转载] gitbook安装与使用
转载自http://blog.csdn.net/xiaocainiaoshangxiao/article/details/46882921 废话不说,直接主题: gitbook安装 ========= ...
- gitbook安装及初步使用
gitbook安装 https://www.jianshu.com/p/421cc442f06c https://blog.csdn.net/lu_embedded/article/details/8 ...
- gitbook 安装和使用
gitbook 安装和使用 安装nodejs wget https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-arm64.tar.xz tar - ...
- gitbook安装与使用,并使用docker部署
本文简单介绍如何安装并使用gitbook,最后如何使用docker构建书籍镜像. 1. 前置条件 需要Nodejs环境,安装npm,国内用户再安装cnpm npm install -g cnpm -- ...
- GitBook安装部署实操手册
前言 GitBook是一个基于Node.js的命令行工具,可使用Git和Markdown来编写文档,赞誉太多,不再赘述. Node.js 下载安装包 cd /tmp wget https://node ...
- gitbook安装使用教程
以下是gitbook的简略安装使用过程,可以参考一下.后续有时间我再回头修改完善实验目的:安装gitbook后,将相关的文件发布到gitlab上安装node.js在cmd下执行安装npm instal ...
- node.js 下载安装及gitbook环境安装、搭建
最近需要gitbook看文档,于是各种百度,各种安装,很多都是无法正常安装完成的,比较纠结啊 最后,终于发现一个好用的,现分享一下地址(也是给自己做个记录): 1.node.js下载地址: http: ...
随机推荐
- NSDate 时区转换问题
一: NSDateFormatter *dateFormater = [[NSDateFormatter alloc]init]; [dateFormater setDateFormat:@" ...
- php之快速入门学习-7(运算符)
PHP 运算符 本章节我们将讨论 PHP 中不同运算符的应用. 在 PHP 中,赋值运算符 = 用于给变量赋值. 在 PHP 中,算术运算符 + 用于把值加在一起. PHP 算术运算符 运算符 名称 ...
- spring boot 1.5.2 操作mongodb3.4.0
1:build.gradle 添加mongodb依赖 dependencies { compile('org.springframework.boot:spring-boot-starter-web' ...
- Linux虚拟机下使用USB转串口线——配置minicom、以及screen的使用
转自:http://bbs.ednchina.com/BLOG_ARTICLE_637212.HTM 环境:Windows XP + (VMware Workstation - Linux) 1.确保 ...
- MySQL 数据库几种类型
关系数据库(MySQL.Oracle.SQL Server.DB2.Postgres)键-值存储数据库(Riak和Redis)面向列的数据库(HBase) 面向文档的数据库(MongoDB 和Couc ...
- vue provide和inject使用
provide和inject使用场景也是组件传值,尤其是祖父组件--孙组件等有跨度的组件间传值,单向传值(由provide的组件传递给inject的组件). provide 选项应该是一个对象或返回一 ...
- exception PLS-00403: expression 'V_END' cannot be used as an INTO-target of a SELECT/FETCH statement
exception PLS-00403: expression 'V_END' cannot be used as an INTO-target of a SELECT/FETCH stateme ...
- 函数式编程工具:filter和reduce
# -*- coding: utf-8 -*- #python 27 #xiaodeng #函数式编程工具:filter和reduce #python内置函数中,map函数是用来进行函数式编程这类工具 ...
- Windows 消息机制浅析
1. Windows 的历史 中国人喜欢以史为鉴,而事实也确实是,如果你能知道一件事情的来龙去脉,往往可以更容易地理解事物为什么会表现为当前这样的现状.所以,我的介绍性开场白通常会以一段历 ...
- js图片加载效果(延迟加载+瀑布流加载)
概述 两种图片加载的效果:一种是遇到图片较多时,带读条效果的加载提示:另一种是根据滑块的位置进行预加载,用户不察觉的情况下,实现瀑布流的加载效果 详细 代码下载:http://www.demodash ...