Mdformat插件,用于格式化Python代码块
项目描述
mdformat-ruff
Mdformat插件,用于格式化Python代码块
描述
mdformat-ruff 是一个 mdformat 插件,用于使用 ruff 格式化 mdformat 的 Python 代码块。
用法
使用以下命令安装
pip install mdformat-ruff
您可以将 ruff 依赖项固定,以确保格式化稳定性
pip install mdformat-ruff ruff==22.1.0
在命令行上使用 mdformat 时,安装后将会自动启用 ruff 格式化。
在使用 mdformat Python API 时,需要显式启用 Python 代码的格式化
import mdformat
unformatted = "```python\n'''ruff converts quotes'''\n```\n"
formatted = mdformat.text(unformatted, codeformatters={"python"})
assert formatted == '```python\n"""ruff converts quotes"""\n```\n'
作为 pre-commit 钩子使用
将以下内容添加到您的 .pre-commit-config.yaml
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.13 # Use the ref you want to point at
hooks:
- id: mdformat
additional_dependencies:
- mdformat-ruff
- ruff==22.1.0 # Pinning ruff here is optional
项目详情
下载文件
根据您的平台下载文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源代码分发
mdformat_ruff-0.1.3.tar.gz (3.4 kB 查看散列)
构建分发包
mdformat_ruff-0.1.3-py3-none-any.whl (3.9 kB 查看散列)
关闭
mdformat_ruff-0.1.3.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 2ddd2758dd3f6738c1c7bfbeb89320d271454f4cd8c28a99968a50d3578b15d6 |
|
MD5 | 6eb875a3e0924ebdd22e0fc3448e8299 |
|
BLAKE2b-256 | 3ae29003dc57c78aea34b21f67854d842985ceac48028d288432efa113df3887 |
关闭
mdformat_ruff-0.1.3-py3-none-any.whl 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 9c0cf7bfe6bf99b9e0e617e960041d06e9fa84300d5645f922306dd2ed0d1296 |
|
MD5 | 704263346a7f761c992f7ef082ec453a |
|
BLAKE2b-256 | b1223f2464d478f145bbcb731cee9fe720b9e4d69efb6ffd8bc4491f14ca20a2 |