一、常用命令

预览书籍:gitbook serve
构建书籍:gitbook build
默认:将生成的静态网站输出到 _book 目录
指定路径:gitbook build [书籍路径] [输出路径]
指定端口:gitbook serve --port 2333
生成pdf格式:gitbook pdf ./ ./mybook.pdf
生成epub格式:gitbook epub ./ ./mybook.epub
生成 mobi 格式:gitbook mobi ./ ./mybook.mobi

二、常用编辑

  • gitbook 初始化书籍
README.md —— 书籍的介绍写在这个文件里
  SUMMARY.md —— 书籍的目录结构在这里配置
  • gitbook serve 来预览这本书籍,执行命令后会对 Markdown 格式的文档进行转换,默认转换为 html 格式
  • 跳转链接
[baidu](http://www.baidu.com)
  • 设置视频iframe
<iframe height="400" width="400" src="//player.bilibili.com/player.html?aid=455161493&bvid=BV1g5411t7HG&cid=174553298&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
  • 添加文字颜色
<font color="red"> 红色</font>
  • 行内代码 hello world
`hello world`
  • 代码块
```
	<?python 
	for i in range(10):
		print(i)
	
	```
  • 在导航栏添加锚点 在product.md(你要跳转的文件夹)文件夹下,选择跳转到的标题 在目标页面添加锚点 HTML里添加唯一id \* mysql的介绍 <div id="sql3306"><div>以为在正常标题后加<div id="sql3306"><dev> 即可 id不能为全数字
    在 SUMMAPY.md 文件加下,上边id即可 首页目录上添加路由 目标文件名加后缀 + # + 锚点id *[mysql](./product.md#my3306)

三、常用插件

  • 插件搜索 输入gitbook gitbook-plugin-donateGitbook 捐赠打赏按钮插件
  • 使用方式 根目录下创建book.json
  • 安装方法 gitbook install
  • 导航栏折叠 chapter-fold 支持多层目录,点击导航栏的标题名就可以实现折叠扩展
{
    "plugins":[
        "chapter-fold",
        "klipse",
        "click-reveal",
        "donate"
    ]
}
  • gitbook-plugin-change_girls 一款可以自动更换背景图片的小插件 图片可以自定义, 自动切换时间也可以自定义.
  • klipse代码段中实时交互,即(输入代码 > 执行结果)
  • gitbook之编辑、运行、常用插件等_git

  • 默认隐藏,点击可显示。
{% reveal %}
要被隐藏的内容
{% endreveal %}
使用自定义显示文字:

{% reveal text="点击显示" %}
要被隐藏的内容
{% endreveal %}
用HTML语法也可以:
<div class="click_reveal"><span> 点击显示 </span><div><pre><code>隐藏的文字</code></pre></div></div>
  • donate 打赏
{
    "title": "编写gitbook电子书教程",
    "description": "gitbook电子书建教程",
    "author": "zhangjunbo",
    "language": "zh-hans",
    "root": ".",

    "plugins": [  # 插件名字
        "donate",
        "github-buttons@2.1.0",
        "edit-link"
    ],


    "pluginsConfig": {
        "donate": {
          "wechat": "微信收款的二维码URL",
          "alipay": "支付宝收款的二维码URL",
          "title": "默认空",
          "button": "打赏",
          "alipayText": "支付宝打赏",
          "wechatText": "微信捐赠"
        },
        "github-buttons": {
            "repo": "fenghuall/study",
            "types": ["start"],
            "size": "small"
        },
        "edit-link": {
            "base": "https://github.com/twbs/bootstrap/master",
            "label": "Edit This Page"
        }
    }
}

更多插件