如何用gitbook 书籍下载写书

GitBook 制作电子书详细教程
字体:[ ] 类型:转载 时间:
本文主要介绍GitBook如何制作电子书,在使用过程中经常出现的问题以及解决办法,希望能帮助到有需要的同学
gitbook安装:
https://nodejs.org/#download
下载node.js源代码(点击绿色的INSTALL),
./configure
make install
成功执行后,npm就被安装好了。
2. gitbook 安装命令
npm install -g gitbook-cli
gitbook -V
查看gitbook是否安装成功。
1. /gitbook-zh/index.html
gitbook使用
===========
1. 根据目录生成图书结构
1.1 README.md 与 SUMMARY编写
这个文件相当于一本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! 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:
node install.js
npm ERR! You can get their info via:
npm owner ls phantomjs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
/home/wangxq/repository/phantomjs/npm-debug.log
***************************************************
&由错误报告内容的第一行可以知道,发生错误的原因是下载
&phantomjs发生了错误,因此我们需要手动下载和安装。
&解决方法:[1]
$ git clone git:///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:'&_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./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- /kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c " main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
$ gitbook -v 2.1.0 pdf . # 重新执行命令生成pdf,目标文件为book.pdf
1. http://phantomjs.org/build.html
2. /download_linux
1. 如果输入gitbook init命令,出现Installing version 2.1.0,
需要耐性等待安装。
&&&&&& 以上就是我整理的gitbook的安装与使用资料,谢谢大家支持!
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具Gitbook使用入门_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Gitbook使用入门
阅读已结束,下载文档到电脑
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩12页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢使用gitbook 来写作 - 为程序员服务
使用gitbook 来写作
之前写过一些东西,比如:
velocity的文档, checkstyle的文档等等。用的是docbook
, 一种使用XML语言来写代码,然后生成多种 格式的技术(html, single html, pdf )
为什么不用word写呢?
因为无法做diff.
纯文本的力量比word大很多。(不过也看编辑的要求了)
14年接触到了 swift的翻译, 使用了gitbook, (梁杰选择了 它,很有灵气)
markdown化果然是大势所趋。
只需要很短的时间,记住几个常用的markdown, 就可以写书了。
放到了github上,可以把它从private 做成了 public repo, 希望大家都可以参与。
希望在我们写作这本书的过程中,大家能多提意见,毕竟好书是改出来的。
1. 注册gitbook.
organization
3. 新建 book, 可以直接选择 import ,
4. 新建完book之后,也可以在设置中, 设置某本书与git repo中的关联,然后直接在中修改git repo中的内容。
5. 写好的东西,还可以直接发布。给人看。
6. 提供了非常友好的操作界面。如下图。
7. 新建SUMMARY.md 文件:
* [序言](chapter1.md)
* [概述](chapter2.md)
* [入门](chapter3.md)
关联到帐号的时候,要使用...
而不是git://的形式。
我是申思维,从事于WEB 和移动app开发 熟悉js (coffeescript), CSS, HTML,跟web相关的服务器(apache, nginx, passenger, mongrel, t
原文地址:, 感谢原作者分享。
您可能感兴趣的代码达尔文曾经说过:「任何一个项目都应该有一个 README」。
恩,README.md 对于任何一个项目来说都是不可或缺的一部分,无论是对于使用者还是后续维护者都是灰常重要哒:p
对于小型项目,一个 README.md 足以,但是如果是一个大项目的话(如 midway),那就不是一个 READ
达尔文曾经说过:「任何一个项目都应该有一个 README」。
恩,README.md 对于任何一个项目来说都是不可或缺的一部分,无论是对于使用者还是后续维护者都是灰常重要哒:p
对于小型项目,一个 README.md 足以,但是如果是一个大项目的话(如 midway),那就不是一个 README.md 可以搞定的啦。本文就来扯一下使用 gitbook 为你的项目写一本**书**。
-g gitbook
2. 初始化:
在你的文档目录下新建文件 SUMMARY.md,这个文件就是这本书的目录啦:
touch SUMMARY.md
SUMMARY.md 的格式规范如下:
# uitest 文档
- [uitest 是什么](users/index.md)
- [如何使用 uitest](users/use.md)
- [如何编写自定义的测试用例](users/case.md)
- [browserjs API 文档](users/api.md)
- [uitest 开发者文档](devs/index.md)
- [browserjs 开发者文档](devs/browserjs.md)
- [utci 文档](devs/utci.md)
- [utserver & utclient 文档](devs/utserver.md)
- [相关文章沉淀](artical.md)
- [关于 gitbook](gitbook.md)
然后执行 gitbook init 初始化,gitbook 会根据 SUMMARY 的结构生成对应的目录文件:
├── README.md
├── SUMMARY.md
└── users
└── index.md
├── use.md
├── api.md
├── case.md
├── devs
├── index.md
├── browserjs.md
├── utci.md
└── utserver.md
├── artical.md
├── gitbook.md
3. 本地调试:
在对应的文档目录下运行 gitbook serve 会启动一个本地的静态服务器:
访问 http://localhost:4000/ 就可以实时的预览啦,并且支持 livereload, 灰常赞~接下来结合预览的功能编辑对应的文档,完成之后就可以发布啦。
在文档目录下执行 gitbook build 会生成一个 _book 的目录,这个目录就是我们的静态网站啦,然后通过 demo 平台或者 github pages 就可以很简单的完成部署了。
因为 uitest 的 docs 本身就是在 Express 应用中的,因此我只需要在 express 中增加一个静态服务器即可:
app.use('/docs', express.static('docs/_book'));
上面说的都是做项目文档,但是如果你想写本书,那么 gitbook 提供了更为方便的服务,请移步
文章转载自:http://sobear.me/
作者:大果
版权声明:本文内容由互联网用户自发贡献,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至: 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
用云栖社区APP,舒服~
【云栖快讯】数据库技术天团集体亮相,分享一线生产实践经验,告诉你踩过的坑、走过的路,都是老司机,靠谱!干货分享,不可错过!&&
业内领先的面向企业的一站式研发提效平台,通过项目流程管理和专项自动化提效工具,能够很好地支持互联网敏捷项目的快速...
云数据库HybridDB(ApsaraDB HybridDB)是一种在线MPP大规模并行处理数据仓库服务。云数据...
为企业和开发者提供稳定、安全、智能的把网站域名或应用资源转换为计算机用于互连的数字 IP地址,从而将最终用户的访...
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效率,降低 IT 成本...
2017杭州云栖大会火热抢票
Loading...

我要回帖

更多关于 gitbook 书籍下载 的文章

 

随机推荐