Skip to content

mdformat breaks mkdocstrings-python injection blocks #79

@distractor

Description

@distractor

Hi,

I have a mkdocs project where I'm trying to use the mdformat-mkdocs.

While I love this tool, there is a small issue I'm having in combination with mkdocstrings-python. Namely the fact that:

::: preonpy._preonpy.Buffer
    options:
        heading_level: 2

gets formatted to

::: preonpy.\_preonpy.Buffer options: heading_level: 2

Which that breaks the building of the documentation.

I'm running mdformat with --ignore-missing-references --align-semantic-breaks-in-lists flags. Is there an easy fix to this?

In case it helps, this is my toml:

dependencies = [
    "mdformat-front-matters>=2.0.0",
    "mdformat-mkdocs>=5.1.4",
    "mdformat-pyproject>=0.1.1",
    "mkdocs-bibtex>=4.4.0",
    "mkdocs-glightbox>=0.5.2",
    "mkdocs-macros-plugin>=1.5.0",
    "mkdocs-material>=9.7.1",
    "mkdocstrings>=1.0.3",
    "mkdocstrings-python>=2.0.2",
    "pint>=0.25.2",
    "ruff>=0.15.1",
]

[tool.mdformat]
wrap = 100
validate = false
number = true

[tool.ruff]
line-length = 120

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions