Skip to content

Commit

Permalink
no-paragraph-content-indent: fix crash caused by empty alt
Browse files Browse the repository at this point in the history
Closes GH-173.
Closes GH-172.
  • Loading branch information
Murderlon authored and wooorm committed Mar 9, 2018
1 parent 0c028a3 commit c23a5ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/remark-lint-no-paragraph-content-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* ![image reference][] text
*
* [![][text]][text]
*
* @example {"name": "invalid.md", "label": "input"}
*
* ·Alpha
Expand All @@ -56,6 +58,8 @@
*
* ![ image reference][] text
*
* [![ ][text]][text]
*
* @example {"name": "invalid.md", "label": "output"}
*
* 1:1: Expected no indentation in paragraph content
Expand All @@ -67,6 +71,7 @@
* 17:5: Expected no indentation in paragraph content
* 19:1: Expected no indentation in paragraph content
* 21:1: Expected no indentation in paragraph content
* 23:2: Expected no indentation in paragraph content
*/

'use strict';
Expand Down Expand Up @@ -104,7 +109,7 @@ function noParagraphContentIndent(tree, file) {
return;
}

if (first === true && ws(toString(node).charAt(0))) {
if (first && ws(toString(node).charAt(0))) {
file.message(message, node.position.start);
}

Expand Down Expand Up @@ -163,7 +168,7 @@ function head(node) {
}

function applicable(node) {
return 'value' in node || 'alt' in node;
return 'value' in node || node.alt;
}

function toString(node) {
Expand Down
5 changes: 5 additions & 0 deletions packages/remark-lint-no-paragraph-content-indent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ juliett.
![image]() text

![image reference][] text

[![][text]][text]
```

###### Out
Expand Down Expand Up @@ -72,6 +74,8 @@ Bravo
![ image]() text

![ image reference][] text

[![ ][text]][text]
```

###### Out
Expand All @@ -86,6 +90,7 @@ Bravo
17:5: Expected no indentation in paragraph content
19:1: Expected no indentation in paragraph content
21:1: Expected no indentation in paragraph content
23:2: Expected no indentation in paragraph content
```

## Install
Expand Down

0 comments on commit c23a5ec

Please sign in to comment.