# linting

URL: /patitas/api/linting/
Section: linting
Description: Content linting for Patitas — a ruff-for-Markdown over the typed AST.

Lint rules are stateless objects implementing the `LintRule` protocol.
Each receives one immutable `LintContext` (the parsed Document, the raw
source, and a precomputed document-order node sequence) and yields
`Diagnostic` objects that reuse the existing ``SourceLocation``.

The headline entrypoint is `lint`(), which accepts either a Markdown string
(parsed internally) or a pre-parsed Document plus its raw source.

Thread Safety:
    Rules are stateless and the runner is created fresh per `lint`() call,
    so one `Linter` (or one `LintRuleRegistry`) is safe to share
    across threads.

Example:
    >>> from patitas import lint, Diagnostic
    >>> from patitas.linting import LintRule, Severity, LintContext, LintRuleRegistryBuilder
    >>> diags = lint("# Title\n\n### Skipped   ")
    >>> sorted({d.rule_id for d in diags})
    ['heading-increment', 'trailing-whitespace']

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/linting/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flinting%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flinting%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flinting%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flinting%2Findex.txt)

Module

#
`linting`

Content linting for Patitas — a ruff-for-Markdown over the typed AST.

Lint rules are stateless objects implementing the`LintRule`protocol.
Each receives one immutable`LintContext`(the parsed Document, the raw
source, and a precomputed document-order node sequence) and yields
`Diagnostic` objects that reuse the existing `SourceLocation`.

The headline entrypoint is`lint`(), which accepts either a Markdown string
(parsed internally) or a pre-parsed Document plus its raw source.

Thread Safety:

```
Rules are stateless and the runner is created fresh per `lint`() call,
so one `Linter` (or one `LintRuleRegistry`) is safe to share
across threads.
```

Example:

```
>>> from patitas import lint, Diagnostic
>>> from patitas.linting import LintRule, Severity, LintContext, LintRuleRegistryBuilder
>>> diags = lint("# Title\n\n### Skipped   ")
>>> sorted({d.rule_id for d in diags})
['heading-increment', 'trailing-whitespace']
```
