mkdocs的mdformat插件。
项目描述
mdformat-mkdocs
为mdformat、mkdocs以及与MkDocs常见搭配的软件包(如mkdocs-material、mkdocstrings和python-markdown)提供的mdformat插件。
支持
- 缩进转换为四个空格而不是两个
- 注意:当指定
--align-semantic-breaks-in-lists
时,有序列表的嵌套缩进为三个,但其他情况为四个的倍数
- 注意:当指定
- 无序列表的项目符号转换为破折号(
-
)而不是星号(*
) - 默认情况下,有序列表采用单个数字(
1.
或0.
)作为编号,除非指定了--number
,则mdformat-mkdocs
将对有序列表应用连续编号,以与mdformat
保持一致[链接] - MkDocs-Material 警示
- MkDocs-Material 内容选项卡*
- *注意:此插件生成的(HTML)标记足够用于格式化,但不适用于浏览器查看。如果您需要生成有效的HTML,请提出问题。
- mkdocstrings 锚点(自动引用)
- mkdocstrings 跨引用
- Python Markdown "缩写"*
- *注意:用于缩写的标记(HTML)对渲染没有用处。如果重要,我愿意接受贡献,因为实现可能具有挑战性
请参阅示例测试文件,./tests/pre-commit-test.md 和 ./tests/format/fixtures.md
mdformat
使用方法
在任何使用 mdformat
的地方添加此包,插件将自动识别。无需额外配置。有关插件的其他信息,请参阅此处官方的 mdformat
文档
提示:此包指定了与 mkdocs
管理的典型文档兼容的插件 "额外"('recommended'
)
- mdformat-beautysh
- mdformat-black
- mdformat-config
- mdformat-footnote
- mdformat-frontmatter
- mdformat-simple-breaks
- mdformat-tables
- mdformat-web
- mdformat-wikilink
Pre-Commit
repos:
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
additional_dependencies:
- mdformat-mkdocs>=2.1.0
# Or
# - "mdformat-mkdocs[recommended]>=2.1.0"
pipx
pipx install mdformat
pipx inject mdformat mdformat-mkdocs
# Or
# pipx inject mdformat "mdformat-mkdocs[recommended]"
HTML 渲染
要生成 HTML 输出,可以从 mdit_plugins
导入 material_admon_plugin
。将来将添加更多插件。有关 MarkdownIt
的更多信息,请参阅文档:https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser
from markdown_it import MarkdownIt
from mdformat_mkdocs.mdit_plugins import material_admon_plugin
md = MarkdownIt()
md.use(material_admon_plugin)
text = "??? note\n content"
md.render(text)
# <details class="note">
# <summary>Note</summary>
# <p>content</p>
# </details>
命令行选项
mdformat-mkdocs
添加了 CLI 参数 --align-semantic-breaks-in-lists
以可选地对编号列表中的换行进行 3 个空格的对齐。如果没有指定,则遵循通用的默认缩进 4 个空格。
# with: mdformat
1. Semantic line feed where the following line is
three spaces deep
# vs. with: mdformat --align-semantic-breaks-in-lists
1. Semantic line feed where the following line is
three spaces deep
注意:目前配置文件中尚不支持 align-semantic-breaks-in-lists
设置(https://github.com/executablebooks/mdformat/issues/378)
贡献
请参阅 CONTRIBUTING.md
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
mdformat_mkdocs-3.0.0.tar.gz (20.9 kB 查看哈希值)
构建分布
mdformat_mkdocs-3.0.0-py3-none-any.whl (20.1 kB 查看哈希值)