# 1.7 gitbook 插件等相关设置

## 摘要

本文记录了1.7 gitbook 插件等相关设置，解决gitbook不支持latex公式等问题。

* [x] Edit By Porter, 积水成渊,蛟龙生焉。

文章同步于: [我的gitbook](https://porter.gitbook.io/)

## gitbook 插件等相关配置

### 插件安装配置方法

在你gitbook更目录中编辑book.json文件，文件配置好后，不会生效，需要先执行命令

```bash
gitbook install  # 安装命令
```

然后执行如下命令进行编译

```bash
gitbook build
```

### Mermaid

* 图和流程图(甘特图之类的)

[Mermaid 的 plugins地址](https://plugins.gitbook.com/plugin/mermaid), [Mermaid 的github地址](https://github.com/knsv/mermaid)

![Mermaid](https://1930597982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LV7JLvsYnG7y7A2o-vp%2F-LVprKVULLGwcDJfWtNL%2F-LVprLQOL5y7ifvLzuOq%2FPlugins_Mermaid.png?generation=1547091930788150\&alt=media)

* 安装方法，在book.json加入以下内容，然后gitbook install

{ "plugins": \["mermaid"] }

graph TD; A-->B; A-->C; B-->D; C-->D;

classDiagram Class01 <|-- AveryLongClass : Cool Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 --> C2 : Where am i? Class09 --* C3 Class09 --|> Class07 Class07 : equals() Class07 : Object\[] elementData Class01 : size() Class01 : int chimp Class01 : int gorilla Class08 <--> C2: Cool label

* 具体使用[帮助文档请移步github](https://github.com/knsv/mermaid)

#### KaTex

为了支持数学公式, 我们可以使用KaTex和MathJax插件, 官网上说Katex速度要快于MathJax

[插件地址](https://plugins.gitbook.com/plugin/katex)

```javascript
"plugins": [
    "katex"
]
```

用法：

```
Inline math: $$\int_{-\infty}^\infty g(x) dx$$

Block math:

$$
\int_{-\infty}^\infty g(x) dx
$$

Or using the templating syntax:

{% math %}\int_{-\infty}^\infty g(x) dx{% endblock %}
```

#### 安装视屏播放插件

[chinese-video](https://plugins.gitbook.com/plugin/chinese-video)

Install Add the below to your book.json file, then run gitbook install :

```python
{
    "plugins": ["chinese-video"]
}
```

Usage Currently, This plugin support:

Bilibili Youku Iqiyi QQ Sohu Mgtv PPTV There are each methods which you should use to insert matched website's video.

Tips:

\[xxx] is optional parameter. You can ignore it but don't ignore any @. The width x height, which is defined by you, is the largest size of the player and if you have a small screen to look through the page, Page will zoom the player with the scale of your width x height. Bilibili html5 https

```
{% bilibili %} avCode @ [section] @ [width x height] {% endbilibili %}
```

avCode is bilibili video's serial number. Just like this: <https://www.bilibili.com/video/av> 170001

avCode should be a number. Don't attach "av" to it.

section is matched video's sub video's serial number.

width x height is player's size.

Youku html5 flash https

```
{% youku %} videoCode @ [mode] @ [width x height] {% endyouku %}
```

mode is player's mode. js(html5) or flash.

videoCode just like this: <https://v.youku.com/v_show/id_> XNDU4MjQ3MzA0 .html

width x height is player's size.

Iqiyi html5 flash https(HTML5 player) http(Flash player)

Iqiyi's parameter just like shit!!!

Flash player

```python
{% iqiyi %} flash @ parameter1 @ video @ albumId @ tvId @ [width x height] {% endiqiyi %}
```

flash is key word. Don't change it.

You only can visit Iqiyi's video's Sharing page and copy its HTML to get these parameters. It just like this:

```python
{% bilibili %} 170001 @ [section] @ [640 x 480] {% endbilibili %}
```
