Mdformat插件,用于将Python代码块转换为Black格式
项目描述
mdformat-black
Mdformat插件,用于将Python代码块转换为Black格式
描述
mdformat-black是一个mdformat插件,它使用Black将mdformat格式化Python代码块。
使用方法
使用以下命令安装
pip install mdformat-black
当在命令行上使用mdformat时,安装后将自动启用Black格式化。
当使用mdformat Python API时,Python代码格式化需要显式启用
import mdformat
unformatted = "```python\n'''black converts quotes'''\n```\n"
formatted = mdformat.text(unformatted, codeformatters={"python"})
assert formatted == '```python\n"""black converts quotes"""\n```\n'