Skip to content

Commit d54441e

Browse files
benbalterwooorm
authored andcommitted
Remove : requirement for no-emphasis-as-heading
Closes GH-48.
1 parent 0c78a52 commit d54441e

File tree

6 files changed

+13
-27
lines changed

6 files changed

+13
-27
lines changed

doc/rules.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -754,22 +754,19 @@ Options: `boolean`, default: `false`.
754754

755755
```md
756756
<!-- Valid: -->
757-
# Foo:
757+
# Foo
758758

759759
Bar.
760760

761761
<!-- Invalid: -->
762-
*Foo:*
762+
*Foo*
763763

764764
Bar.
765765
```
766766

767767
Warn when emphasis (including strong), instead of a heading, introduces
768768
a paragraph.
769769

770-
Currently, only warns when a colon (`:`) is also included, maybe that
771-
could be omitted.
772-
773770
### no-file-name-articles
774771

775772
```md

lib/rules/no-emphasis-as-heading.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
* @fileoverview
77
* Warn when emphasis (including strong), instead of a heading, introduces
88
* a paragraph.
9-
*
10-
* Currently, only warns when a colon (`:`) is also included, maybe that
11-
* could be omitted.
129
* @example
1310
* <!-- Valid: -->
14-
* # Foo:
11+
* # Foo
1512
*
1613
* Bar.
1714
*
1815
* <!-- Invalid: -->
19-
* *Foo:*
16+
* *Foo*
2017
*
2118
* Bar.
2219
*/
@@ -30,7 +27,6 @@
3027
*/
3128

3229
var visit = require('unist-util-visit');
33-
var toString = require('mdast-util-to-string');
3430
var position = require('mdast-util-position');
3531

3632
/**
@@ -48,7 +44,6 @@ function noEmphasisAsHeading(ast, file, preferred, done) {
4844
var child = children[0];
4945
var prev = parent.children[index - 1];
5046
var next = parent.children[index + 1];
51-
var value;
5247

5348
if (position.generated(node)) {
5449
return;
@@ -61,16 +56,7 @@ function noEmphasisAsHeading(ast, file, preferred, done) {
6156
children.length === 1 &&
6257
(child.type === 'emphasis' || child.type === 'strong')
6358
) {
64-
value = toString(child);
65-
66-
/*
67-
* TODO: See if removing the punctuation
68-
* necessity is possible?
69-
*/
70-
71-
if (value.charAt(value.length - 1) === ':') {
72-
file.warn('Don’t use emphasis to introduce a section, use a heading', node);
73-
}
59+
file.warn('Don’t use emphasis to introduce a section, use a heading', node);
7460
}
7561
});
7662

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Ensuring the markdown you (and contributors) write is of great quality will
88
provide better rendering in all the different markdown parsers, and makes
99
sure less refactoring is needed afterwards. What is quality? That’s up to you,
10-
but the defaults are sensible :ok\_hand:.
10+
but the defaults are sensible :ok_hand:.
1111

1212
**remark-lint** has lots of tests. Supports Node, io.js, and the browser.
1313
100% coverage. 50+ rules. It’s built on [**remark**][remark],
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
**How to make omelets:**
1+
**How to make omelets**
22

33
Break an egg.
44

5-
*How to bake bread:*
5+
*How to bake bread*
66

77
Open the flour sack.

test/fixtures/no-emphasis-as-heading-valid.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Open the flour sack.
88

99
*And this is valid*
1010

11+
* One
12+
* Two
13+
1114
This is also valid:
1215

1316
foo

test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ describe('Rules', function () {
703703
describeRule('no-emphasis-as-heading', function () {
704704
describeSetting(true, function () {
705705
assertFile('no-emphasis-as-heading-invalid.md', [
706-
'no-emphasis-as-heading-invalid.md:1:1-1:25: Don’t use emphasis to introduce a section, use a heading',
707-
'no-emphasis-as-heading-invalid.md:5:1-5:21: Don’t use emphasis to introduce a section, use a heading'
706+
'no-emphasis-as-heading-invalid.md:1:1-1:24: Don’t use emphasis to introduce a section, use a heading',
707+
'no-emphasis-as-heading-invalid.md:5:1-5:20: Don’t use emphasis to introduce a section, use a heading'
708708
]);
709709

710710
assertFile('no-emphasis-as-heading-valid.md', []);

0 commit comments

Comments
 (0)