You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a75fca1
Browse filesBrowse the repository at this point in the historyBrowse files
feat(no-heading-like-lines): short title-case colon + prose, convertToHeading true by default
- Detect short (≤5 words) title-case lines ending in colon when prose follows.
- Default fix now converts to ATX heading (convertToHeading true); set false to strip emphasis.
- Add getMatchForLine helper to satisfy eslint complexity.
- Add positive_heading_like and negative fixtures, unit and Python fix tests.
- Fix no-empty-heading README heading for heading-min-words (Rule behavior).
# To override: Uncomment the block; set convertToHeading, defaultHeadingLevel, fixedHeadingLevel, punctuationMarks, or excludePathPatterns. Report lines that look like headings but are not (e.g. **Text:**, MD036-style). Fixable.
337
337
# Options (all optional):
338
-
# convertToHeading: bool (default false); when true, fix converts to ATX heading; when false, fix strips emphasis
338
+
# convertToHeading: bool (default true); when true, fix converts to ATX heading; when false, fix strips emphasis
339
339
# defaultHeadingLevel: number 1–6 (default 2); used when converting and there is no preceding heading
340
340
# fixedHeadingLevel: number 1–6; when set, suggested heading uses this level and ignores context
341
341
# punctuationMarks: string (default ".,;!?"); for whole-line emphasis, skip when content ends with one of these
Copy file name to clipboardExpand all lines: markdownlint-rules/README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,16 +184,16 @@ Entries may be a plain regex string (no placement) or `{ pattern: "regex", place
184
184
185
185
```yaml
186
186
no-heading-like-lines:
187
-
convertToHeading: false# when true, fix converts to ATX heading instead of stripping emphasis
187
+
convertToHeading: true # default; set false to strip emphasis to plain text instead of converting to ATX heading
188
188
defaultHeadingLevel: 2 # level when there is no preceding heading (1-6)
189
189
fixedHeadingLevel: 3 # if set, force this level and ignore context
190
190
punctuationMarks: ".,;!?" # for whole-line emphasis, skip when content ends with one of these (default omits : so colon lines are caught)
191
191
excludePathPatterns: # optional; skip this rule for matching paths
192
192
- "**/README.md"
193
193
```
194
194
195
-
- **`convertToHeading`** (boolean, default `false`): When false, the default fix strips emphasis to plain text (e.g. `**Summary:**` -> `Summary:`).
196
-
When true, the fix converts the line to an ATX heading with context-aware level (one below the last preceding heading; no prior heading -> `defaultHeadingLevel`).
195
+
- **`convertToHeading`** (boolean, default `true`): When true, the fix converts the line to an ATX heading with context-aware level (one below the last preceding heading; no prior heading -> `defaultHeadingLevel`).
196
+
When false, the fix strips emphasis to plain text (e.g. `**Summary:**` -> `Summary`).
197
197
- **`defaultHeadingLevel`** (number 1-6, default 2): Used when converting to a heading and there is no preceding heading in the document.
198
198
- **`fixedHeadingLevel`** (number 1-6, optional): When set, the suggested heading uses this level and ignores context.
199
199
- **`punctuationMarks`** (string, default `".,;!?"`): For whole-line emphasis (`**Text**` / `*Text*`), the rule does not report when the emphasized content ends with one of these (treats as sentences).
@@ -202,19 +202,21 @@ no-heading-like-lines:
202
202
When the file path matches any pattern, the rule does not report for that file.
203
203
204
204
**Fixable:** Yes (config-controlled).
205
-
Default fix strips emphasis to plain text.
205
+
Default fix converts to an ATX heading.
206
+
When `convertToHeading` is false, the fix strips emphasis to plain text.
206
207
When `convertToHeading` is true, the fix converts to an ATX heading with context-aware level, adds a blank line after the heading when the next line is non-blank, and when the optional dependency files are present respects numbering (adds the correct number prefix when the section uses numbered headings) and applies AP title case to the heading text (same rules as heading-title-case).
207
208
208
-
**Behavior:** Reports lines that look like headings but are not(e.g. `**Text:**`, `**Text**:`, `1. **Text**`, italic variants, whole-line emphasis).
209
+
**Behavior:** Reports lines that look like headings but are not: bold/italic with colon (e.g. `**Text:**`, `**Text**:`, `1. **Text**`, italic variants), whole-line emphasis, and short (up to 5 words) title-case lines ending in a colon when followed by longer prose (e.g. `View Activity History:` with a paragraph below).
209
210
Whole-line emphasis ending with a `punctuationMarks` character is not reported; default omits colon so colon lines are always caught (greedier than MD036).
210
211
fixInfo replaces with stripped text or ATX heading.
211
212
Disable MD036 to avoid duplicates and use this rule's fixInfo for `--fix`.
212
213
213
214
#### Using Without Heading-Title-Case And/Or Heading-Numbering
214
215
215
216
You can use `no-heading-like-lines.js` with only `utils.js`; the other rule files are optional.
216
-
For the default fix (strip emphasis), no other files are needed.
217
-
For `convertToHeading: true`:
217
+
For the default fix (convert to ATX heading), no other files are needed; optional deps add title case and numbering.
218
+
For `convertToHeading: false` (strip emphasis), no other files are needed.
219
+
When `convertToHeading` is true:
218
220
219
221
- If `heading-title-case.js` is not in the same rules directory, suggested headings use the extracted title as-is (no AP title case).
220
222
- If `heading-numbering.js` is not in the same rules directory, no number prefix is added to suggested headings.
@@ -312,7 +314,7 @@ no-empty-heading:
312
314
- **`stripNumberingForAllowList`** (boolean, default `true`): When `true`, leading numbering (e.g. `1.2.3`) is stripped from the heading text before comparing to `allowList`.
313
315
- **`excludePathPatterns`** (list of strings, default none): Glob patterns for file paths where this rule is skipped.
314
316
315
-
Behavior:
317
+
#### Rule Behavior
316
318
317
319
- For each H2-H6 heading, only _direct_ content counts: lines that appear **before** the next heading (any level).
318
320
Content under subheadings does **not** count for the parent heading.
Copy file name to clipboardExpand all lines: md_test_files/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@
15
15
-`**positive_general_index.md**` - Index-style page (filename matches `**/*_index.md`); excluded from no-empty-heading so empty H2 sections are allowed; passes with 0 errors.
16
16
-`**positive_heading_numbering_zero.md**` - 0-indexed H2 numbering (## 0., 1., 2. and subsections); passes with 0 errors.
17
17
-`**positive_heading_title_case.md**` - Valid AP title case and headings with identifiers/file names in backticks (e.g. `sba_result`, `README.md`); passes with 0 errors.
18
+
-`**positive_heading_like.md**` - Proper ATX headings and prose only; short title-case lines ending in colon with no prose after (or with a heading next) are not reported; passes with 0 errors.
18
19
-`**negative_*.md**` - One file per failing scenario; lint each to verify the expected custom rule(s) fail.
0 commit comments