diff --git a/packages/remark-lint-maximum-line-length/index.js b/packages/remark-lint-maximum-line-length/index.js index 8b699f66..a806eb6b 100644 --- a/packages/remark-lint-maximum-line-length/index.js +++ b/packages/remark-lint-maximum-line-length/index.js @@ -8,14 +8,11 @@ * * Options: `number`, default: `80`. * - * Ignores nodes which cannot be wrapped, such as headings, tables, + * Ignores nodes that cannot be wrapped, such as headings, tables, * code, and definitions. * - * Ignores nodes which cannot be wrapped, such as headings, tables, - * code, and definitions. - * - * URLs in images and links are okay if they occur at or after the wrap, - * except when there’s white-space after them. + * Ignores images, links, and inline code if they start before the wrap, end + * after the wrap, and there’s no white-space after them. * * @example {"name": "valid.md", "config": {"positionless": true}} * @@ -26,6 +23,8 @@ * * * + * `alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscarPapaQuebec.romeo()` + * * [foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables) * * @@ -55,11 +54,17 @@ * * and such. * + * And this one is also very wrong: because the code starts aaaaaaafter the column: `alpha.bravo()` + * + * `alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscar.papa()` and such. + * * @example {"name": "invalid.md", "setting": 80, "label": "output", "config": {"positionless": true}} * * 4:86: Line must be at most 80 characters * 6:99: Line must be at most 80 characters * 8:97: Line must be at most 80 characters + * 10:97: Line must be at most 80 characters + * 12:99: Line must be at most 80 characters * * @example {"name": "valid-mixed-line-endings.md", "setting": 10, "config": {"positionless": true}} * @@ -104,7 +109,7 @@ function maximumLineLength(tree, file, pref) { var lineLength visit(tree, ['heading', 'table', 'code', 'definition'], ignore) - visit(tree, ['link', 'image'], validateLink) + visit(tree, ['link', 'image', 'inlineCode'], inline) /* Iterate over every line, and warn for violating lines. */ while (++index < length) { @@ -118,11 +123,10 @@ function maximumLineLength(tree, file, pref) { } } - /* Finally, whitelist URLs, but only if they occur at - * or after the wrap. However, when they do, and - * there’s white-space after it, they are not - * whitelisted. */ - function validateLink(node, pos, parent) { + /* Finally, whitelist some inline spans, but only if they occur at or after + * the wrap. However, when they do, and there’s white-space after it, they + * are not whitelisted. */ + function inline(node, pos, parent) { var next = parent.children[pos + 1] var initial var final diff --git a/packages/remark-lint-maximum-line-length/readme.md b/packages/remark-lint-maximum-line-length/readme.md index fe43579c..d30c18fb 100644 --- a/packages/remark-lint-maximum-line-length/readme.md +++ b/packages/remark-lint-maximum-line-length/readme.md @@ -6,14 +6,11 @@ Warn when lines are too long. Options: `number`, default: `80`. -Ignores nodes which cannot be wrapped, such as headings, tables, +Ignores nodes that cannot be wrapped, such as headings, tables, code, and definitions. -Ignores nodes which cannot be wrapped, such as headings, tables, -code, and definitions. - -URLs in images and links are okay if they occur at or after the wrap, -except when there’s white-space after them. +Ignores images, links, and inline code if they start before the wrap, end +after the wrap, and there’s no white-space after them. ## Presets @@ -87,6 +84,10 @@ Just like thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis And this one is also very wrong: because the link starts aaaaaaafter the column: and such. + +And this one is also very wrong: because the code starts aaaaaaafter the column: `alpha.bravo()` + +`alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscar.papa()` and such. ``` ###### Out @@ -95,6 +96,8 @@ And this one is also very wrong: because the link starts aaaaaaafter the column: 4:86: Line must be at most 80 characters 6:99: Line must be at most 80 characters 8:97: Line must be at most 80 characters +10:97: Line must be at most 80 characters +12:99: Line must be at most 80 characters ``` ##### `valid.md` @@ -109,6 +112,8 @@ This is also fine: +`alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscarPapaQuebec.romeo()` + [foo](http://this-long-url-with-a-long-domain-is-valid.co.uk/a-long-path?query=variables)