diff --git a/doc/rules.md b/doc/rules.md index d5afcc57..bcc74a78 100644 --- a/doc/rules.md +++ b/doc/rules.md @@ -754,12 +754,12 @@ Options: `boolean`, default: `false`. ```md - # Foo: + # Foo Bar. - *Foo:* + *Foo* Bar. ``` @@ -767,9 +767,6 @@ Options: `boolean`, default: `false`. Warn when emphasis (including strong), instead of a heading, introduces a paragraph. - Currently, only warns when a colon (`:`) is also included, maybe that - could be omitted. - ### no-file-name-articles ```md diff --git a/lib/rules/no-emphasis-as-heading.js b/lib/rules/no-emphasis-as-heading.js index b60fd271..813c459d 100644 --- a/lib/rules/no-emphasis-as-heading.js +++ b/lib/rules/no-emphasis-as-heading.js @@ -6,17 +6,14 @@ * @fileoverview * Warn when emphasis (including strong), instead of a heading, introduces * a paragraph. - * - * Currently, only warns when a colon (`:`) is also included, maybe that - * could be omitted. * @example * - * # Foo: + * # Foo * * Bar. * * - * *Foo:* + * *Foo* * * Bar. */ @@ -30,7 +27,6 @@ */ var visit = require('unist-util-visit'); -var toString = require('mdast-util-to-string'); var position = require('mdast-util-position'); /** @@ -48,7 +44,6 @@ function noEmphasisAsHeading(ast, file, preferred, done) { var child = children[0]; var prev = parent.children[index - 1]; var next = parent.children[index + 1]; - var value; if (position.generated(node)) { return; @@ -61,16 +56,7 @@ function noEmphasisAsHeading(ast, file, preferred, done) { children.length === 1 && (child.type === 'emphasis' || child.type === 'strong') ) { - value = toString(child); - - /* - * TODO: See if removing the punctuation - * necessity is possible? - */ - - if (value.charAt(value.length - 1) === ':') { - file.warn('Don’t use emphasis to introduce a section, use a heading', node); - } + file.warn('Don’t use emphasis to introduce a section, use a heading', node); } }); diff --git a/readme.md b/readme.md index e2db8326..bfb8b24a 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ Ensuring the markdown you (and contributors) write is of great quality will provide better rendering in all the different markdown parsers, and makes sure less refactoring is needed afterwards. What is quality? That’s up to you, -but the defaults are sensible :ok\_hand:. +but the defaults are sensible :ok_hand:. **remark-lint** has lots of tests. Supports Node, io.js, and the browser. 100% coverage. 50+ rules. It’s built on [**remark**][remark], diff --git a/test/fixtures/no-emphasis-as-heading-invalid.md b/test/fixtures/no-emphasis-as-heading-invalid.md index 78a6b28e..ba044e0b 100644 --- a/test/fixtures/no-emphasis-as-heading-invalid.md +++ b/test/fixtures/no-emphasis-as-heading-invalid.md @@ -1,7 +1,7 @@ -**How to make omelets:** +**How to make omelets** Break an egg. -*How to bake bread:* +*How to bake bread* Open the flour sack. diff --git a/test/fixtures/no-emphasis-as-heading-valid.md b/test/fixtures/no-emphasis-as-heading-valid.md index 3bb504a2..b754ab7a 100644 --- a/test/fixtures/no-emphasis-as-heading-valid.md +++ b/test/fixtures/no-emphasis-as-heading-valid.md @@ -8,6 +8,9 @@ Open the flour sack. *And this is valid* +* One +* Two + This is also valid: foo diff --git a/test/index.js b/test/index.js index 573c2d43..745f81f4 100644 --- a/test/index.js +++ b/test/index.js @@ -703,8 +703,8 @@ describe('Rules', function () { describeRule('no-emphasis-as-heading', function () { describeSetting(true, function () { assertFile('no-emphasis-as-heading-invalid.md', [ - 'no-emphasis-as-heading-invalid.md:1:1-1:25: Don’t use emphasis to introduce a section, use a heading', - 'no-emphasis-as-heading-invalid.md:5:1-5:21: Don’t use emphasis to introduce a section, use a heading' + 'no-emphasis-as-heading-invalid.md:1:1-1:24: Don’t use emphasis to introduce a section, use a heading', + 'no-emphasis-as-heading-invalid.md:5:1-5:20: Don’t use emphasis to introduce a section, use a heading' ]); assertFile('no-emphasis-as-heading-valid.md', []);