Skip to content

Commit 9982ad3

Browse files
amyreesentBre
andauthored
Document extension mapping for markdown code formatting (#23574)
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
1 parent f14edd8 commit 9982ad3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/formatter.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,25 @@ with [`extend-include`](settings.md#extend-include) in your project settings:
322322
extend-include = ["docs/*.md"]
323323
```
324324

325+
To format Markdown files with extensions other than `.md`, configure custom
326+
[`extension`](settings.md#extension) mappings. Ruff will automatically include
327+
these mapped extensions in file discovery:
328+
329+
=== "pyproject.toml"
330+
331+
```toml
332+
[tool.ruff]
333+
# Treat `.mdx` and `.qmd` files as Markdown
334+
extension = { mdx = "markdown", qmd = "markdown" }
335+
```
336+
337+
=== "ruff.toml"
338+
339+
```toml
340+
# Treat `.mdx` and `.qmd` files as Markdown
341+
extension = {mdx="markdown", qmd="markdown"}
342+
```
343+
325344
If you run Ruff via [`ruff-pre-commit`](https://github.com/astral-sh/ruff-pre-commit), Markdown
326345
support needs to be explicitly included by adding it to `types_or`:
327346

0 commit comments

Comments
 (0)