您的位置:首页 > 产品设计 > UI/UE

gitbook install convert pdf and build

2016-11-03 02:12 555 查看
Reference:http://blog.csdn.net/q312998164/article/details/43278177

gitboo build by node.js support ruby,python..

Mac下GitBook制作电子书

1、安装npm(Node Package Manager)。从node.js的官网上下载安装程序,即可完成Node.js和npm的安装。

2、通过npm安装Gitbook。

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

$ npm install gitbook -g

3、https://github.com/GitbookIO/editor/releases 下载gitbook-mac.dmg也就是gitbook editor。

4、创建一个 Simple Book(或者其他的也可以),必须放在空文件夹中。

5、文件夹下就会出现Gitbook需要2个基本文件:README.md和SUMMARY.md,还有个_book文件夹(稍后介绍),README.md是关于你的书的介绍,而SUMMARY.md中则包含了书目,即章节结构。

6、在浏览器中查看:

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

$ gitbook serve -p 8080

Gitbook首先把你的Markdown文件编译为HTML文件,并根据SUMMARY.md生成书的目录。所有生存的文件都保存在当前目录下的一个名为_book的子目录中。完成这些工作后,Gitbook会作为一个HTTP Server运行,并在8080端口监听HTTP请求。运行以上命令后,打开浏览器,在地址栏输入:http://localhost:8080即可看到你的书页了。其中位于左侧书目顶部的Introduction一节就编译自README.md,而书目本身自编译自SUMMARY.md。你要在自己的网站上发布新书,只需把_book目录复制到服务器相应目录即可。

7、Options for commands build and serve are(可选的编译或部署命令,这个是针对命令行下):

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

-o, –output Path to output directory, defaults to ./_book

-f, –format Change generation format, defaults to site, availables are: site, page, ebook, json

–config Configuration file to use, defaults to book.js or book.json

8、GitBook loads the default configuration from a book.json file in the repository if it exists.官网上描述的,这不用翻译了吧 = =,如果用GitBook Editor,则可以在菜单栏Book->Edit Configuration,编辑完后文件夹中就出现了book.json文件。

Here are the options that can be stored in this file:

{

// Folders to use for output

// Caution: it overrides the value from the command line

// It’s not advised this option in the book.json

“output”: null,

// Generator to use for building
// Caution: it overrides the value from the command line
// It's not advised this option in the book.json
"generator": "site",

// Book metadats (somes are extracted from the README by default)
"title": null,
"description": null,
"isbn": null,

// For ebook format, the extension to use for generation (default is detected from output extension)
// "epub", "pdf", "mobi"
// Caution: it overrides the value from the command line
// It's not advised this option in the book.json
"extension": null,

// Plugins list, can contain "-name" for removing default plugins
"plugins": [],

// Global configuration for plugins
"pluginsConfig": {
"fontSettings": {
"theme": "sepia", "night" or "white",
"family": "serif" or "sans",
"size": 1 to 4
}
},

// Variables for templating
"variables": {},

// Links in template (null: default, false: remove, string: new value)
"links": {
// Custom links at top of sidebar
"sidebar": {
"Custom link name": "https://customlink.com"
},

// Sharing links
"sharing": {
"google": null,
"facebook": null,
"twitter": null,
"weibo": null,
"all": null
}
},

// Options for PDF generation
"pdf": {
// Add page numbers to the bottom of every page
"pageNumbers": false,

// Font size for the fiel content
"fontSize": 12,

// Paper size for the pdf
// Choices are [u’a0’, u’a1’, u’a2’, u’a3’, u’a4’, u’a5’, u’a6’, u’b0’, u’b1’, u’b2’, u’b3’, u’b4’, u’b5’, u’b6’, u’legal’, u’letter’]
"paperSize": "a4",

// Margin (in pts)
// Note: 72 pts equals 1 inch
"margin": {
"right": 62,
"left": 62,
"top": 36,
"bottom": 36
},

//Header HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_.
"headerTemplate": null,

//Footer HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_.
"footerTemplate": null
}


}

9、出现下面的提示,不一定出现这个提示再去安装Calibre,所以这步就是安装Calibre(啰嗦了):

Need to install ebook-convert from Calibre

This error happens because GitBook can’t resolve a plugin (or the plugin is invalid). External plugins need to be installed using gitbook install.

解决方法:

To get around the error while trying to build your project as a PDF, ePub or mobi ebook, you must have the Calibre eBook reader/manager installed AND the command-line tools installed.

To install the Calibre command-line tools from the Mac version, from the menu select: calibre - Preferences - Miscellaneous - Install command line tools

翻译:Calibre 上下载calibre-2.17.0.dmg,之后安装,选择英文版(方便找到calibre - Preferences - Miscellaneous - Install command line tools),找不到Install command line tools则可以终端执行 :

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin

10、把GitBook Editor跟自己的账号关联起来,然后菜单栏中Book->Publish as..就可以发布到网站中了(这样其他读者可以浏览器中阅读或者下载生成自己需要的文件格式)。

11、终端编译,选择你要生成的一种格式即可,没安装Calibre会提示Need to install ebook-convert from Calibre

[plain] view plain copy 在CODE上查看代码片派生到我的代码片

gitbookpdf gitbook mobi

$ gitbook epub

最后文件夹中就会生成相对应的文件。

12、https://github.com/GitbookIO/gitbook 这个是官方的github地址

最后的最后,1、2、3、4、9、10、11 按照这个步骤就可以成功制作自己的电子书了 = =,有些细节的地方没说完整,笔者认为读者都能自己摸索出来。







gitbook editor use:http://blog.csdn.net/bao_libra/article/details/51364699
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: