Skip to content

扩展markdown功能

Warning

这里的语法并不是Markdown通用语法,其它主题或软件可能并不支持,慎用!

content tabs

Configuration

This configuration enables content tabs, and allows to nest arbitrary content inside content tabs, including code blocks and ... more content tabs! Add the following lines to mkdocs.yml:

Text Only
markdown_extensions:
  - pymdownx.superfences
  - pymdownx.tabbed:
      alternate_style: true

Usage

Grouping code blocks

Code blocks are one of the primary targets to be grouped, and can be considered a special case of content tabs, as tabs with a single code block are always rendered without horizontal spacing:

Content tabs with code blocks
=== "C"

    ``` c
    #include <stdio.h>

    int main(void) {
      printf("Hello world!\n");
      return 0;
    }
    ```

=== "C++"

    ``` c++
    #include <iostream>

    int main(void) {
      std::cout << "Hello world!" << std::endl;
      return 0;
    }
    ```
C
#include <stdio.h>

int main(void) {
  printf("Hello world!\n");
  return 0;
}
C++
#include <iostream>

int main(void) {
  std::cout << "Hello world!" << std::endl;
  return 0;
}

Grouping other content

Content tabs
=== "Unordered list"

    * Sed sagittis eleifend rutrum
    * Donec vitae suscipit est
    * Nulla tempor lobortis orci

=== "Ordered list"

    1. Sed sagittis eleifend rutrum
    2. Donec vitae suscipit est
    3. Nulla tempor lobortis orci
  • Sed sagittis eleifend rutrum
  • Donec vitae suscipit est
  • Nulla tempor lobortis orci
  1. Sed sagittis eleifend rutrum
  2. Donec vitae suscipit est
  3. Nulla tempor lobortis orci

Embedded content

Content tabs in admonition
!!! example

    === "Unordered List"

        ``` markdown
        * Sed sagittis eleifend rutrum
        * Donec vitae suscipit est
        * Nulla tempor lobortis orci
        ```

    === "Ordered List"

        ``` markdown
        1. Sed sagittis eleifend rutrum
        2. Donec vitae suscipit est
        3. Nulla tempor lobortis orci
        ```

Example

Markdown
* Sed sagittis eleifend rutrum
* Donec vitae suscipit est
* Nulla tempor lobortis orci
Markdown
1. Sed sagittis eleifend rutrum
2. Donec vitae suscipit est
3. Nulla tempor lobortis orci

Admonitions

Demo

mkdocs支持Admonitions,在网页上显示类似警告信息。

Admonition

Action is the antidote to despair.

Text Only
???+ note "Admonition"
    Action is the antidote to despair.
Quote
  • Adding a + after the ??? token renders the block expanded

  • 通过缩进控制Tab和Admonition结构

Supported types

Note

Action is the antidote to despair.

Abstract

Action is the antidote to despair.

Info

Action is the antidote to despair.

Tip

Action is the antidote to despair.

Success

Action is the antidote to despair.

Question

Action is the antidote to despair.

Warning

Action is the antidote to despair.

Failure

Action is the antidote to despair.

Danger

Action is the antidote to despair.

Bug

Action is the antidote to despair.

Example

Action is the antidote to despair.

Quote

Action is the antidote to despair.


Last update: October 7, 2023
Created: October 7, 2023