@@ -42,6 +42,8 @@ Line exceeds maximum length.
4242| ` code-block-max ` | int | -- | Max length for code block lines; inherits ` max ` when unset |
4343| ` stern ` | bool | false | Only flag long lines that contain a space past the limit |
4444| ` exclude ` | list | ` ["code-blocks", "tables", "urls"] ` | Categories to exclude from checking |
45+ | ` reflow ` | bool | false | Auto-fix over-long prose paragraphs by rewrapping to ` max ` |
46+ | ` abbreviations ` | list | ` [] ` | Extra abbreviations the reflow fixer keeps unbroken |
4547
4648Valid ` exclude ` values:
4749
@@ -76,6 +78,44 @@ is excluded via `exclude: [code-blocks]` is still skipped regardless of stern.
7678Stern uses the active max for each line type, so it respects ` heading-max ` and
7779` code-block-max ` when set.
7880
81+ ### Reflow (auto-fix)
82+
83+ By default the rule reports long lines but does not rewrite them: ` mdsmith fix `
84+ leaves prose untouched. Set ` reflow: true ` to opt into the auto-fix, which
85+ rewraps over-long top-level prose paragraphs so every line fits within ` max ` .
86+
87+ Reflow is deliberately conservative. It rewraps only paragraphs that sit
88+ directly in the document body and contain a flagged long line. It skips
89+ headings, list items, block quotes, tables, generated sections, paragraphs that
90+ carry a Markdown hard line break, and paragraphs that contain inline raw HTML.
91+ Inline code spans are preserved verbatim, and a single word wider than ` max ` (a
92+ long URL or link) keeps its own over-long line rather than being broken.
93+
94+ Wrapping is abbreviation-aware. It never ends a wrapped line on an abbreviation,
95+ and it never splits a run of initials. So ` e.g. ` stays with the word it
96+ introduces, and ` J. R. R. Tolkien ` is never broken across lines. Detection
97+ reuses mdsmith's trained abbreviation model — the same one the readability rules
98+ use to split sentences. It recognises honorifics (` Dr. ` , ` Mr. ` ), reference forms
99+ (` vs. ` , ` No. ` ), initials (` J. ` ), and dotted forms (` e.g. ` , ` i.e. ` , ` U.S.A. ` ). The
100+ ` abbreviations ` setting adds project-specific entries the model does not know
101+ (` etc. ` , ` approx. ` ), and append-merges across config layers so a kind can extend
102+ the inherited list without restating it.
103+
104+ The payoff is clearest at the wrap boundary. A naive word wrap of this line at 80
105+ columns splits the spaced acronym across the break:
106+
107+ ``` text
108+ Historians traced the founding and the early constitutional debates of the U. S.
109+ A. with real care.
110+ ```
111+
112+ Reflow breaks before the acronym instead, keeping ` U. S. A. ` whole on one line:
113+
114+ ``` text
115+ Historians traced the founding and the early constitutional debates of the
116+ U. S. A. with real care.
117+ ```
118+
79119## Config
80120
81121Enable (default):
@@ -128,6 +168,18 @@ rules:
128168 exclude : []
129169` ` `
130170
171+ Custom (enable the reflow auto-fix and add project abbreviations):
172+
173+ ` ` ` yaml
174+ rules :
175+ line-length :
176+ max : 80
177+ reflow : true
178+ abbreviations :
179+ - etc.
180+ - approx.
181+ ` ` `
182+
131183Custom (skip only code blocks and URLs; check tables):
132184
133185` ` ` yaml
@@ -269,7 +321,7 @@ This line inside a code block is over 80 characters but within the code-block-ma
269321- ** Name** : ` line-length `
270322- ** Status** : ready
271323- ** Default** : enabled, max: 80
272- - ** Fixable** : no
324+ - ** Fixable** : yes (opt-in via ` reflow ` )
273325- ** Implementation** :
274326 [ source] ( ./ )
275327- ** Category** : line
0 commit comments