跳转至

目录块分标签: Content tabs

在MkDocs中使用pymdownx.tabbed实现分标签的目录块

配置项

YAML
1
2
3
4
markdown_extensions:
  - pymdownx.tabbed
  - pymdownx.superfences:
      alternate_style: true

示例

效果:

Python
print("Hello world!")
C
1
2
3
4
5
6
#include <stdio.h>

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

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

源码:

Markdown
=== "Python"

    ``` python
    print("Hello world!")
    ```

=== "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;
    }
    ```

参考资料