Skip to content

Material 主题使用说明

Cipher Saw edited this page Mar 17, 2018 · 2 revisions

Material 主题 是针对 MkDocs 开发的遵从 Google Material UI 规范的第三方主题。

Material 主题针对项目文档撰写中的特定语法、功能做了渲染优化;可根据客户端浏览器页面尺寸自动缩放,对PC、移动设备都友好;拥有丰富的页面配色,多达 19 种主体配色和 16 种悬停链接文字配色。

安装

通过 pip 安装。

pip install mkdocs-material

插件

Admonition

Admonition 提供了在文档中添加摘要、提示、警告区块的功能。

使用 !!! 标记开启区块。

!!! note
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
    nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
    massa, nec semper lorem quam in massa.

效果可见 Admonition - Material for MkDocs

CodeHilite

CodeHilite 提供代码高亮功能,基于 pygments。

``` python
import tensorflow as tf
```
import tensorflow as tf

可以添加行号,在配置文件中开启。

markdown_extensions:
  - codehilite:
      linenums:true
``` python
""" Bubble sort """
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
```

可高亮制定行

``` python hl_lines="3 4"
""" Bubble sort """
def bubble_sort(items):
    for i in range(len(items)):
        for j in range(len(items) - 1 - i):
            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]
```

效果可见 CodeHilite - Material for MkDocs

Arithmatex

支持 MathJax。

# 行内公式(Inline
$ a + b = c $

# 行间公式(Display)
$$
a + b = c
$$

更多支持的插件可见 Extensions

注意事项

嵌套

由于 MkDocs 依赖 Python 的 Markdown 库提供渲染,而 Markdown 库认为默认只支持 4 空格缩进,故在嵌套的情况下,只有 4 空格缩进生效。

列表嵌套

- aaa
    - bbb
  • aaa
    • bbb

引用嵌套

> 区块引用  
>> 嵌套引用   

区块引用

嵌套引用

列表代码块嵌套

- list1

    ```python
    text1 = "Hello, "
    text2 = "world!"
    print text1 + text2
    ```
  • list1

    text1 = "Hello, "
    text2 = "world!"
    print text1 + text2

更多情况请参考 嵌套 - Material

Clone this wiki locally