Skip to content

Commit

Permalink
Add images to blacklist for maximum-line-length
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 13, 2015
1 parent 3f6344c commit ba6d270
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ Options: `boolean`, default: `false`.
Options: `number`, default: `80`.

Ignores nodes which cannot be wrapped, such as heasings, tables,
code, and links.
code, link, and images.

### no-auto-link-without-protocol

Expand Down
10 changes: 6 additions & 4 deletions lib/rules/maximum-line-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Options: `number`, default: `80`.
*
* Ignores nodes which cannot be wrapped, such as heasings, tables,
* code, and links.
* code, link, and images.
* @example
* <!-- Valid, when set to `40` -->
* Alpha bravo charlie delta echo.
Expand Down Expand Up @@ -113,8 +113,7 @@ function maximumLineLength(ast, file, preferred, done) {
* there’s white-space after it, they are not
* whitelisted.
*/

visit(ast, 'link', function (node, pos, parent) {
function validateLink(node, pos, parent) {
var next = parent.children[pos + 1];
var initial = start(node);
var final = end(node);
Expand Down Expand Up @@ -150,7 +149,10 @@ function maximumLineLength(ast, file, preferred, done) {
}

whitelist(initial.line - 1, final.line);
});
}

visit(ast, 'link', validateLink);
visit(ast, 'image', validateLink);

/*
* Iterate over every line, and warn for
Expand Down
10 changes: 6 additions & 4 deletions mdast-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,7 @@ module.exports = maximumHeadingLength;
* Options: `number`, default: `80`.
*
* Ignores nodes which cannot be wrapped, such as heasings, tables,
* code, and links.
* code, link, and images.
* @example
* <!-- Valid, when set to `40` -->
* Alpha bravo charlie delta echo.
Expand Down Expand Up @@ -2407,8 +2407,7 @@ function maximumLineLength(ast, file, preferred, done) {
* there’s white-space after it, they are not
* whitelisted.
*/

visit(ast, 'link', function (node, pos, parent) {
function validateLink(node, pos, parent) {
var next = parent.children[pos + 1];
var initial = start(node);
var final = end(node);
Expand Down Expand Up @@ -2444,7 +2443,10 @@ function maximumLineLength(ast, file, preferred, done) {
}

whitelist(initial.line - 1, final.line);
});
}

visit(ast, 'link', validateLink);
visit(ast, 'image', validateLink);

/*
* Iterate over every line, and warn for
Expand Down
2 changes: 1 addition & 1 deletion mdast-lint.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions test/fixtures/maximum-line-length-valid.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ This is also fine: <http://this-long-url-with-a-long-domain.co.uk/a-long-path?qu

<http://this-link-is-fine.com>

[foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables)

<http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables>

![foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables)

| An | exception | is | line | length | in | long | tables | because | those | can’t | just |
| -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- |
| be | helped | | | | | | | | | | . |
Expand Down

0 comments on commit ba6d270

Please sign in to comment.