Skip to content

Commit 019ff36

Browse files
committedJun 6, 2016
Fix checkbox lists starting with links
Closes GH-68.
1 parent 27d3444 commit 019ff36

File tree

5 files changed

+117
-99
lines changed

5 files changed

+117
-99
lines changed
 

‎doc/rules.md

+97-97
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ be null or undefined in order to be ignored.
7979
### external
8080

8181
````md
82-
<!-- Load more rules -->
83-
```json
84-
{
85-
"external": ["foo", "bar", "baz"]
86-
}
87-
```
82+
<!-- Load more rules -->
83+
```json
84+
{
85+
"external": ["foo", "bar", "baz"]
86+
}
87+
```
8888
````
8989

9090
External contains a list of extra rules to load.
@@ -99,13 +99,13 @@ rules are also loaded.
9999
### reset
100100

101101
````md
102-
<!-- Explicitly activate rules: -->
103-
```json
104-
{
105-
"reset": true,
106-
"final-newline": true
107-
}
108-
```
102+
<!-- Explicitly activate rules: -->
103+
```json
104+
{
105+
"reset": true,
106+
"final-newline": true
107+
}
108+
```
109109
````
110110

111111
By default, all rules are turned on unless explicitly set to `false`.
@@ -204,28 +204,28 @@ Options: `boolean`, default: `false`.
204204
### code-block-style
205205

206206
````md
207-
<!-- Valid, when set to `indented` or `consistent`, invalid when set to `fenced` -->
208-
Hello
207+
<!-- Valid, when set to `indented` or `consistent`, invalid when set to `fenced` -->
208+
Hello
209209

210-
...
210+
...
211211

212-
World
212+
World
213213

214-
<!-- Valid, when set to `fenced` or `consistent`, invalid when set to `indented` -->
215-
```
214+
<!-- Valid, when set to `fenced` or `consistent`, invalid when set to `indented` -->
215+
```
216+
Hello
217+
```
218+
...
219+
```bar
220+
World
221+
```
222+
223+
<!-- Always invalid -->
216224
Hello
217-
```
218-
...
219-
```bar
220-
World
221-
```
222-
223-
<!-- Always invalid -->
224-
Hello
225-
...
226-
```
227-
World
228-
```
225+
...
226+
```
227+
World
228+
```
229229
````
230230

231231
Warn when code-blocks do not adhere to a given style.
@@ -285,28 +285,28 @@ Options: `boolean`, default: `false`.
285285
### fenced-code-flag
286286

287287
````md
288-
<!-- Valid: -->
289-
```hello
290-
world();
291-
```
292-
293-
<!-- Valid: -->
294-
Hello
295-
296-
<!-- Invalid: -->
297-
```
298-
world();
299-
```
300-
301-
<!-- Valid when given `{allowEmpty: true}`: -->
302-
```
303-
world();
304-
```
305-
306-
<!-- Invalid when given `["world"]`: -->
307-
```hello
308-
world();
309-
```
288+
<!-- Valid: -->
289+
```hello
290+
world();
291+
```
292+
293+
<!-- Valid: -->
294+
Hello
295+
296+
<!-- Invalid: -->
297+
```
298+
world();
299+
```
300+
301+
<!-- Valid when given `{allowEmpty: true}`: -->
302+
```
303+
world();
304+
```
305+
306+
<!-- Invalid when given `["world"]`: -->
307+
```hello
308+
world();
309+
```
310310
````
311311

312312
Warn when fenced code blocks occur without language flag.
@@ -324,32 +324,32 @@ Options: `boolean`, default: `false`.
324324
### fenced-code-marker
325325

326326
````md
327-
<!-- Valid by default and `` '`' ``: -->
328-
```foo
329-
bar();
330-
```
331-
332-
```
333-
baz();
334-
```
335-
336-
<!-- Valid by default and `'~'`: -->
337-
~~~foo
338-
bar();
339-
~~~
340-
341-
~~~
342-
baz();
343-
~~~
344-
345-
<!-- Always invalid: -->
346-
~~~foo
347-
bar();
348-
~~~
349-
350-
```
351-
baz();
352-
```
327+
<!-- Valid by default and `` '`' ``: -->
328+
```foo
329+
bar();
330+
```
331+
332+
```
333+
baz();
334+
```
335+
336+
<!-- Valid by default and `'~'`: -->
337+
~~~foo
338+
bar();
339+
~~~
340+
341+
~~~
342+
baz();
343+
~~~
344+
345+
<!-- Always invalid: -->
346+
~~~foo
347+
bar();
348+
~~~
349+
350+
```
351+
baz();
352+
```
353353
````
354354

355355
Warn for violating fenced code markers.
@@ -970,24 +970,24 @@ Options: `boolean`, default: `false`.
970970
### no-shell-dollars
971971

972972
````md
973-
<!-- Invalid: -->
974-
```bash
975-
$ echo a
976-
$ echo a > file
977-
```
978-
979-
<!-- Valid: -->
980-
```sh
981-
echo a
982-
echo a > file
983-
```
984-
985-
<!-- Also valid: -->
986-
```zsh
987-
$ echo a
988-
a
989-
$ echo a > file
990-
```
973+
<!-- Invalid: -->
974+
```bash
975+
$ echo a
976+
$ echo a > file
977+
```
978+
979+
<!-- Valid: -->
980+
```sh
981+
echo a
982+
echo a > file
983+
```
984+
985+
<!-- Also valid: -->
986+
```zsh
987+
$ echo a
988+
a
989+
$ echo a > file
990+
```
991991
````
992992

993993
Warn when shell code is prefixed by dollar-characters.

‎lib/rules/list-item-content-indent.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ function listItemContentIndent(ast, file, preferred, done) {
6868
*/
6969

7070
if (index === 0) {
71+
/*
72+
* If there’s a checkbox before the content,
73+
* look backwards to find the start of that
74+
* checkbox.
75+
*/
76+
7177
if (Boolean(node.checked) === node.checked) {
72-
char = begin.offset;
78+
char = begin.offset - 1;
7379

7480
while (contents.charAt(char) !== '[') {
7581
char--;

‎test/fixtures/list-item-content-indent-invalid.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212

1313
1. Foo
1414
1. Bar
15+
16+
<!-- Checkboxes can be used incorrectly -->
17+
18+
1. [x] Foo
19+
1. Bar

‎test/fixtures/list-item-content-indent-valid.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@
1212

1313
1. Foo
1414
1. Bar
15+
16+
<!-- Checkboxes (and links) work OK -->
17+
18+
* [ ] [alpha](http://bravo.com)
19+
* [ ] charlie
20+
* [ ] delta

‎test/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,8 @@ describe('Rules', function () {
13011301
describeRule('list-item-content-indent', function () {
13021302
describeSetting(true, function () {
13031303
assertFile('list-item-content-indent-invalid.md', [
1304-
'list-item-content-indent-invalid.md:14:5: Don’t use mixed indentation for children, remove 1 space'
1304+
'list-item-content-indent-invalid.md:14:5: Don’t use mixed indentation for children, remove 1 space',
1305+
'list-item-content-indent-invalid.md:19:5: Don’t use mixed indentation for children, remove 1 space'
13051306
]);
13061307

13071308
assertFile('list-item-content-indent-valid.md', []);

0 commit comments

Comments
 (0)
Please sign in to comment.