跳转至

内容块增强: Admonitions

配置文件mkdocs.yml

YAML
1
2
3
4
markdown_extensions:
  - admonition
  - pymdownx.details
  - pymdownx.superfences

基本使用

(1) 普通内容块:

源码:

Markdown
!!! note
    hello world

效果:

Note

hello world

(2) 带有标题的内容块:

源码:

Markdown
!!! note "a title"
    hello world

效果:

a title

hello world

(3) 无标题的内容块:

源码:

Markdown
!!! note ""
    hello world

效果:

hello world

支持的类型

note

Note

this is a note

abstract

Abstract

this is an abstract

info

Info

this is a info

tip

Tip

this is a tip

success

Success

this is a success

question

Question

this is a question

warning

Warning

this is a warning

failure

Failure

this is a failure

danger

Danger

this is a danger

bug

Bug

this is a bug

example

Example

this is a example

quote

Quote

this is a quote

增强模组

折叠内容块

默认折叠

源码:

Markdown
??? note
    hello world

效果:

Note

hello world

默认展开

源码:

Markdown
???+ note
    hello world

效果:

Note

hello world

行内插入内容块

参考: https://squidfunk.github.io/mkdocs-material/reference/admonitions/#inline-blocks

嵌套内容块

源码:

Markdown
1
2
3
4
5
6
7
8
9
!!! note
    How to say "hello world" by Python?
    ``` python
    def say_hello():
        print("hello world!")

    say_hello()
    ```
    That is all.

效果:

Note

How to say "hello world" by Python?

Python
1
2
3
4
def say_hello():
    print("hello world!")

say_hello()
That is all.

参考