diff --git a/lib/md025.js b/lib/md025.js index a419fb0b9..30e1c75a2 100644 --- a/lib/md025.js +++ b/lib/md025.js @@ -23,7 +23,7 @@ module.exports = { if (hasTopLevelHeading || foundFrontMatterTitle) { addErrorContext(onError, token.lineNumber, token.line.trim()); - } else if (token.lineNumber === 1) { + } else { hasTopLevelHeading = true; } } diff --git a/style/relaxed.json b/style/relaxed.json index 1070b5982..94955f275 100644 --- a/style/relaxed.json +++ b/style/relaxed.json @@ -8,5 +8,6 @@ "no-inline-html": false, "no-bare-urls": false, "fenced-code-language": false, + "single-title": false, "first-line-h1": false } diff --git a/test/break-all-the-rules.md b/test/break-all-the-rules.md index e25a914da..a8cfb20bd 100644 --- a/test/break-all-the-rules.md +++ b/test/break-all-the-rules.md @@ -126,6 +126,7 @@ Strong **with** different style {MD050} "markdownlint" ] }, + "single-title": false, "link-image-style": { "full": false } diff --git a/test/heading_mutliple_h1_no_toplevel.md b/test/heading_mutliple_h1_no_toplevel.md index 05ffb7305..e5584c012 100644 --- a/test/heading_mutliple_h1_no_toplevel.md +++ b/test/heading_mutliple_h1_no_toplevel.md @@ -2,7 +2,7 @@ Some introductory text # Heading 1 -# Heading 2 +# Heading 2 {MD025} diff --git a/test/lists-and-headings.md b/test/lists-and-headings.md index bf60e79c4..e0c0e0205 100644 --- a/test/lists-and-headings.md +++ b/test/lists-and-headings.md @@ -20,5 +20,6 @@ Heading 3 * list diff --git a/test/markdownlint-test.js b/test/markdownlint-test.js index 09df35083..5dae5585b 100644 --- a/test/markdownlint-test.js +++ b/test/markdownlint-test.js @@ -456,6 +456,7 @@ test("styleAll", async(t) => { "MD022": [ 86 ], "MD023": [ 40 ], "MD024": [ 35 ], + "MD025": [ 27, 31, 33, 35, 40 ], "MD026": [ 40 ], "MD027": [ 42 ], "MD028": [ 43 ], diff --git a/test/snapshots/markdownlint-test-micromark.mjs.snap b/test/snapshots/markdownlint-test-micromark.mjs.snap index 3db2a9e01..a1c5d04d6 100644 Binary files a/test/snapshots/markdownlint-test-micromark.mjs.snap and b/test/snapshots/markdownlint-test-micromark.mjs.snap differ diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index 6732d7d56..4ed149958 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -7208,7 +7208,7 @@ Generated by [AVA](https://avajs.dev). insertText: `␊ `, }, - lineNumber: 134, + lineNumber: 135, ruleDescription: 'Files should end with a single newline character', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md047.md', ruleNames: [ @@ -7541,6 +7541,7 @@ Generated by [AVA](https://avajs.dev). "markdownlint"␊ ]␊ },␊ + "single-title": false,␊ "link-image-style": {␊ "full": false␊ }␊ @@ -14640,12 +14641,27 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - errors: [], + errors: [ + { + errorContext: '# Heading 2 {MD025}', + errorDetail: null, + errorRange: null, + fixInfo: null, + lineNumber: 5, + ruleDescription: 'Multiple top-level headings in the same document', + ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md025.md', + ruleNames: [ + 'MD025', + 'single-title', + 'single-h1', + ], + }, + ], fixed: `Some introductory text␊ ␊ # Heading 1␊ ␊ - # Heading 2␊ + # Heading 2 {MD025}␊ ␊ ␊ `, @@ -32071,6 +32088,7 @@ Generated by [AVA](https://avajs.dev). * list␊ ␊ ␊ `, diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index 51e3afcbd..65dd1a31e 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ