Skip to content

chore: make every markdown file mdformat-clean - #299

Merged
robcohen merged 2 commits into
mainfrom
chore/mdformat-cleanup
Aug 22, 2026
Merged

robcohen merged 2 commits into
mainfrom
chore/mdformat-cleanup

Conversation

@robcohen

Copy link
Copy Markdown
Member

The mdformat hook only runs on files a push actually touches, so this debt surfaced one file at a time — always while someone was trying to do something else. #298 and #240 both had to reach for --no-verify. This clears all 18 remaining files so the hook stops being a tripwire.

Purely presentational: prose rewrapped to 80 columns, table separators padded, ordered lists normalized to lazy 1. numbering (renders identically), --- thematic breaks rewritten as ___.

The nine help pages got extra scrutiny

These render in the app, so I didn't want to bulk-apply and hope:

  • Every <pre> and <textarea> block is byte-identical before and after — verified by extracting and comparing them programmatically, not by eye. Those are the whitespace-significant regions, and there are 34 across the help pages.
  • The help pages are Jinja-rendered. application.py passes the rendered markdown through render_template_string(html, rustfava_version=...), so {{ rustfava_version }} in _index.md is a live substitution, not literal text. Placeholder counts match before and after in every file, and the one placeholder is unchanged.
  • Prose changes are soft line breaks only, which CommonMark collapses to spaces — including the lines that wrap <kbd> and link spans.

Content preservation

Checked across all 18 by diffing token streams before and after. The only differences are ordered-list markers (2. → 1.) and table pipes from separator padding. No prose word changed.

Verification

  • 671 passed, 1 skipped
  • mdformat --all-files now Passes — idempotent repo-wide
  • This branch was pushed without --no-verify, which is the point: the pre-push hook ran and passed on its own

Worth noting the other half of that tripwire is already gone — #240 fixed update-flake-sources.yml for prettier, so pre-push is now clean for both hooks.

The mdformat hook only runs on files a push actually touches, so this
debt surfaced one file at a time, always while someone was trying to do
something else. #298 and #240 both had to reach for --no-verify. This
clears all 18 remaining files so the hook stops being a tripwire.

Purely presentational: prose rewrapped to 80 columns, table separators
padded, ordered lists normalized to lazy `1.` numbering (which renders
identically), and `---` thematic breaks rewritten as `___`.

Nine of the eighteen are the user-facing help pages, which are rendered
in the app, so they got extra checks rather than a bulk pass:

- Every `<pre>` and `<textarea>` block is byte-identical before and
  after, verified by extracting and comparing them programmatically.
  Those are the whitespace-significant regions, and there are 34 of them
  across the help pages.
- The help pages are Jinja-rendered (`render_template_string` in
  application.py), so `{{ rustfava_version }}` in `_index.md` is a live
  substitution rather than literal text. Placeholder counts match
  before and after in every file, and the one placeholder is unchanged.
- Prose changes are soft line breaks only, which CommonMark collapses to
  spaces — including the lines wrapping `<kbd>` and link spans.

Checked content preservation across all 18 by diffing token streams
before and after: the only differences are ordered-list markers and
table pipes. No prose word changed.

671 passed. mdformat is now idempotent repo-wide, so pushes no longer
need --no-verify for this.
The previous commit broke `mkdocs build --strict`, which CI caught:

    ERROR - mkdocstrings: rustfava.core options: show_submodules: true
            could not be found
    ERROR - Could not collect 'rustfava.core options: show_submodules: true'
    Aborted with a BuildError!

docs/api.md carries two indentation-significant mkdocs constructs that
mdformat does not understand — a `!!! note` admonition and an
mkdocstrings `::: rustfava.core` block with an indented `options:`
mapping. Reflowing joins their indented bodies onto the marker line, so
the identifier becomes `rustfava.core options: show_submodules: true`
and collection fails.

Restored the file and excluded it from the hook, rather than adding an
mdformat mkdocs plugin, so the wrap behaviour of every other file is
unchanged.

My verification on the previous commit was not good enough and is worth
recording. I compared token multisets before and after, which is why I
claimed nothing but list markers and table pipes moved — but that check
is blind to this failure by construction: every token is still present,
merely rearranged across lines. It caught nothing because there was
nothing to catch at the token level. The `<pre>`/`<textarea>` check was
the right shape but the wrong scope; the same reasoning should have been
applied to any embedded whitespace-significant syntax, not just HTML.

Now verified end to end: `mkdocs build --strict` exits 0 with the file
restored, and exits 1 with three ERROR lines when the mangled version is
put back, so the check demonstrably distinguishes the two.
@robcohen
robcohen merged commit 3ac3f99 into main Aug 22, 2026
32 checks passed
@robcohen
robcohen deleted the chore/mdformat-cleanup branch August 22, 2026 17:31
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.

1 participant