Skip to content

格式化

Material for MkDocs 提供了对几个 HTML 元素的支持,可以用于突出显示文档的某些部分或应用特定的格式。此外,还支持Critic Markup,可以显示文档的建议更改。

配置

此配置启用了对键盘按键的支持,在文档中跟踪更改,定义上标和下标,并突出显示文本。在mkdocs.yml中添加以下行:

markdown_extensions:
  - pymdownx.critic
  - pymdownx.caret
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.tilde

查看附加的配置选项:

使用方法

突出显示更改

当启用Critic时,可以使用Critic Markup来突出显示建议的更改,并在文档中添加内联评论:

带有建议更改的文本
Text can be deleted and replacement text added. This can also be
combined into onea single operation. Highlighting is also
possible and comments can be added inline.



Formatting can also be applied to blocks by putting the opening and closing
tags on separate lines and adding new lines between the tags and the content.


Text can be deleted and replacement text added. This can also be combined into onea single operation. Highlighting is also possible and comments can be added inline.

Formatting can also be applied to blocks by putting the opening and closing tags on separate lines and adding new lines between the tags and the content.

突出显示文本

当启用Caret, Mark & Tilde时,可以使用简单的语法来突出显示文本,这比直接使用相应的markinsdel HTML 标签更方便:

带有突出显示的文本
- ==This was marked==
- ^^This was inserted^^
- ~~This was deleted~~
  • This was marked
  • This was inserted
  • This was deleted

上标和下标

当启用Caret & Tilde时,可以使用简单的语法来设置文本的上标和下标,这比直接使用相应的subsup HTML 标签更方便:

带有上标和下标的文本
- H~2~O
- A^T^A
  • H2O
  • ATA

添加键盘按键

当启用Keys时,可以使用简单的语法来渲染键盘按键。请参阅Python Markdown Extensions文档,了解所有可用的简码:

键盘按键
++ctrl+alt+del++

Ctrl+Alt+Del