Skip to content

chore: re-enable the mdformat pre-commit hook and reformat markdown - #602

Draft
leoschwarz wants to merge 2 commits into
mainfrom
chore/reenable-mdformat
Draft

chore: re-enable the mdformat pre-commit hook and reformat markdown#602
leoschwarz wants to merge 2 commits into
mainfrom
chore/reenable-mdformat

Conversation

@leoschwarz

Copy link
Copy Markdown
Member
  • Re-enable the mdformat pre-commit hook, pinned to mdformat 1.0.0 with mdformat-gfm (tables) and mdformat-simple-breaks (--- rather than a row of 70 underscores). Markdown formatting is deterministic again after being off since February.
  • Reformat 45 markdown files once: table padding, CommonMark nested-list indent, blank lines around fences. Changelog headings lose their backslash escaping, ## \[1.20.0\] becomes ## [1.20.0], so nox -s changelog now accepts both forms and the extract-changelog action gained a test for the unescaped one.
  • The February regression came from Docs improvements #424 bumping the hook 0.7.17 -> 1.0.0 while also dropping mdformat-mkdocs. The reformat committed in 989f4bc is byte-for-byte the output of the old pin, so it came from a stale local mdformat, not from the pinned hook.
  • Caveat: 45 reformatted files will conflict with any in-flight branch that edits a changelog. Resolve by taking either side and re-running pre-commit run mdformat --all-files.

Closes #437

🤖 Prepared with assistance from Claude Opus 5 via Claude Code.

The hook was commented out in 989f4bc as a workaround for #437, where
markdown formatting appeared to change for no reason. The cause was #424
bumping mdformat 0.7.17 -> 1.0.0 while also dropping mdformat-mkdocs: the
plugin was what produced 4-space nested list indents, and 0.7.17 escaped
`[Unreleased]` as `\[Unreleased\]` (fixed upstream in 0.7.18). The diff
committed in 989f4bc is byte-for-byte the output of the *old* pin, so it
came from a stale local mdformat rather than the pinned hook.

Pin mdformat 1.0.0 with mdformat-gfm (tables) and mdformat-simple-breaks
(`---` instead of 70 underscores). mdformat-myst is unusable: 0.3.0
escapes `:::{note}` to `:::\{note}`, breaking MyST colon fences.

Since the hook now unescapes changelog headings, relax the nox changelog
check to accept both forms, matching what the extract-changelog action
already did, and cover the unescaped form in that action's tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown formatting suddenly changed

1 participant