markdownlint 0.20.3 → 0.20.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -1
- package/README.md +17 -9
- package/demo/markdownlint-browser.js +22 -18
- package/doc/Rules.md +52 -0
- package/helpers/helpers.js +1 -1
- package/helpers/package.json +1 -1
- package/lib/md037.js +3 -1
- package/lib/md044.js +19 -16
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -43,5 +43,5 @@ Open pull requests against the `next` branch.
|
|
|
43
43
|
That's where the latest changes are staged for the next release.
|
|
44
44
|
Include the text "(fixes #??)" at the end of the commit message so the pull request will be associated with the relevant issue.
|
|
45
45
|
Once accepted, the tag `fixed in next` will be added to the issue.
|
|
46
|
-
When the commit is merged to
|
|
46
|
+
When the commit is merged to the main branch during the release process, the issue will be closed automatically.
|
|
47
47
|
(See [Closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/) for details.)
|
package/README.md
CHANGED
|
@@ -32,14 +32,21 @@ and test cases came directly from that project.
|
|
|
32
32
|
|
|
33
33
|
### Related
|
|
34
34
|
|
|
35
|
-
*
|
|
36
|
-
* [
|
|
37
|
-
*
|
|
38
|
-
* [
|
|
39
|
-
* [
|
|
40
|
-
*
|
|
41
|
-
* [markdownlint
|
|
42
|
-
* [
|
|
35
|
+
* CLI
|
|
36
|
+
* [markdownlint-cli command-line interface for Node.js](https://github.com/igorshubovych/markdownlint-cli)
|
|
37
|
+
* GitHub
|
|
38
|
+
* [GitHub Super-Linter Action](https://github.com/github/super-linter)
|
|
39
|
+
* [GitHub Actions problem matcher for markdownlint-cli](https://github.com/xt0rted/markdownlint-problem-matcher)
|
|
40
|
+
* Editor
|
|
41
|
+
* [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items/DavidAnson.vscode-markdownlint)
|
|
42
|
+
* [Sublime Text markdownlint for Sublime Text](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint)
|
|
43
|
+
* [linter-node-markdownlint extension for Atom](https://atom.io/packages/linter-node-markdownlint)
|
|
44
|
+
* [coc-markdownlint extension for Vim/Neovim](https://github.com/fannheyward/coc-markdownlint)
|
|
45
|
+
* Tooling
|
|
46
|
+
* [grunt-markdownlint for the Grunt task runner](https://github.com/sagiegurari/grunt-markdownlint)
|
|
47
|
+
* [Cake.Markdownlint addin for Cake build automation system](https://github.com/cake-contrib/Cake.Markdownlint)
|
|
48
|
+
* Ruby
|
|
49
|
+
* [markdownlint/mdl gem for Ruby](https://rubygems.org/gems/mdl)
|
|
43
50
|
|
|
44
51
|
## Demonstration
|
|
45
52
|
|
|
@@ -199,7 +206,7 @@ This can be used to "hide" `markdownlint` comments at the bottom of a file.
|
|
|
199
206
|
In cases where it is desirable to change the configuration of one or more rules
|
|
200
207
|
for a file, the following more advanced syntax is supported:
|
|
201
208
|
|
|
202
|
-
*
|
|
209
|
+
* Configure: `<!-- markdownlint-configure-file { options.config JSON } -->`
|
|
203
210
|
|
|
204
211
|
For example:
|
|
205
212
|
|
|
@@ -864,6 +871,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
|
864
871
|
* 0.20.1 - Fix regression in MD037.
|
|
865
872
|
* 0.20.2 - Fix regression in MD037, improve MD038.
|
|
866
873
|
* 0.20.3 - Fix regression in MD037, improve MD044, add automatic regression testing.
|
|
874
|
+
* 0.20.4 - Fix regression in MD037, improve MD034/MD044, improve documentation.
|
|
867
875
|
|
|
868
876
|
[npm-image]: https://img.shields.io/npm/v/markdownlint.svg
|
|
869
877
|
[npm-url]: https://www.npmjs.com/package/markdownlint
|
|
@@ -33,7 +33,7 @@ var inlineCommentRe =
|
|
|
33
33
|
/<!--\s*markdownlint-(?:(?:(disable|enable|capture|restore|disable-file|enable-file)((?:\s+[a-z0-9_-]+)*))|(?:(configure-file)\s+([\s\S]*?)))\s*-->/ig;
|
|
34
34
|
module.exports.inlineCommentRe = inlineCommentRe;
|
|
35
35
|
// Regular expressions for range matching
|
|
36
|
-
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']
|
|
36
|
+
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*(?:\/|[^\s\]"'\W])/ig;
|
|
37
37
|
module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
|
|
38
38
|
module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
|
|
39
39
|
// Regular expression for all instances of emphasis markers
|
|
@@ -2879,7 +2879,9 @@ module.exports = {
|
|
|
2879
2879
|
}
|
|
2880
2880
|
// Back up one character so RegExp has a chance to match the
|
|
2881
2881
|
// next marker (ex: "**star**_underscore_")
|
|
2882
|
-
emphasisRe.lastIndex
|
|
2882
|
+
if (emphasisRe.lastIndex > 1) {
|
|
2883
|
+
emphasisRe.lastIndex--;
|
|
2884
|
+
}
|
|
2883
2885
|
}
|
|
2884
2886
|
else if (emphasisRe.lastIndex > 1) {
|
|
2885
2887
|
// Back up one character so RegExp has a chance to match the
|
|
@@ -3138,6 +3140,8 @@ module.exports = {
|
|
|
3138
3140
|
// @ts-check
|
|
3139
3141
|
"use strict";
|
|
3140
3142
|
var _a = require("../helpers"), addErrorDetailIf = _a.addErrorDetailIf, bareUrlRe = _a.bareUrlRe, escapeForRegExp = _a.escapeForRegExp, filterTokens = _a.filterTokens, forEachInlineChild = _a.forEachInlineChild, newLineRe = _a.newLineRe;
|
|
3143
|
+
var startNonWordRe = /^\W/;
|
|
3144
|
+
var endNonWordRe = /\W$/;
|
|
3141
3145
|
module.exports = {
|
|
3142
3146
|
"names": ["MD044", "proper-names"],
|
|
3143
3147
|
"description": "Proper names should have the correct capitalization",
|
|
@@ -3149,7 +3153,9 @@ module.exports = {
|
|
|
3149
3153
|
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
3150
3154
|
names.forEach(function (name) {
|
|
3151
3155
|
var escapedName = escapeForRegExp(name);
|
|
3152
|
-
var
|
|
3156
|
+
var startNamePattern = startNonWordRe.test(name) ? "" : "\\S*\\b";
|
|
3157
|
+
var endNamePattern = endNonWordRe.test(name) ? "" : "\\b\\S*";
|
|
3158
|
+
var namePattern = "(" + startNamePattern + ")(" + escapedName + ")(" + endNamePattern + ")";
|
|
3153
3159
|
var anyNameRe = new RegExp(namePattern, "gi");
|
|
3154
3160
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
3155
3161
|
function forToken(token) {
|
|
@@ -3158,29 +3164,27 @@ module.exports = {
|
|
|
3158
3164
|
.forEach(function (line, index) {
|
|
3159
3165
|
var match = null;
|
|
3160
3166
|
while ((match = anyNameRe.exec(line)) !== null) {
|
|
3161
|
-
var fullMatch = match[0];
|
|
3167
|
+
var fullMatch = match[0], leftMatch = match[1], nameMatch = match[2], rightMatch = match[3];
|
|
3162
3168
|
if (fullMatch.search(bareUrlRe) === -1) {
|
|
3163
3169
|
var wordMatch = fullMatch
|
|
3164
|
-
.replace(
|
|
3170
|
+
.replace(new RegExp("^\\W{0," + leftMatch.length + "}"), "")
|
|
3171
|
+
.replace(new RegExp("\\W{0," + rightMatch.length + "}$"), "");
|
|
3165
3172
|
if (!names.includes(wordMatch)) {
|
|
3166
3173
|
var lineNumber = token.lineNumber + index + fenceOffset;
|
|
3167
3174
|
var fullLine = params.lines[lineNumber - 1];
|
|
3168
|
-
var matchIndex = match.index;
|
|
3169
3175
|
var matchLength = wordMatch.length;
|
|
3170
|
-
var
|
|
3171
|
-
if (fullLineWord !== wordMatch) {
|
|
3172
|
-
// Attempt to fix bad offset due to inline content
|
|
3173
|
-
matchIndex = fullLine.indexOf(wordMatch);
|
|
3174
|
-
}
|
|
3176
|
+
var matchIndex = fullLine.indexOf(wordMatch);
|
|
3175
3177
|
var range = (matchIndex === -1) ?
|
|
3176
3178
|
null :
|
|
3177
3179
|
[matchIndex + 1, matchLength];
|
|
3178
|
-
var fixInfo = (matchIndex === -1) ?
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3180
|
+
var fixInfo = (matchIndex === -1) ?
|
|
3181
|
+
null :
|
|
3182
|
+
{
|
|
3183
|
+
"editColumn": matchIndex + 1,
|
|
3184
|
+
"deleteCount": matchLength,
|
|
3185
|
+
"insertText": name
|
|
3186
|
+
};
|
|
3187
|
+
addErrorDetailIf(onError, lineNumber, name, nameMatch, null, null, range, fixInfo);
|
|
3184
3188
|
}
|
|
3185
3189
|
}
|
|
3186
3190
|
}
|
|
@@ -3345,7 +3349,7 @@ module.exports = rules;
|
|
|
3345
3349
|
},{"../package.json":50,"./md001":5,"./md002":6,"./md003":7,"./md004":8,"./md005":9,"./md006":10,"./md007":11,"./md009":12,"./md010":13,"./md011":14,"./md012":15,"./md013":16,"./md014":17,"./md018":18,"./md019":19,"./md020":20,"./md021":21,"./md022":22,"./md023":23,"./md024":24,"./md025":25,"./md026":26,"./md027":27,"./md028":28,"./md029":29,"./md030":30,"./md031":31,"./md032":32,"./md033":33,"./md034":34,"./md035":35,"./md036":36,"./md037":37,"./md038":38,"./md039":39,"./md040":40,"./md041":41,"./md042":42,"./md043":43,"./md044":44,"./md045":45,"./md046":46,"./md047":47,"./md048":48,"url":59}],50:[function(require,module,exports){
|
|
3346
3350
|
module.exports={
|
|
3347
3351
|
"name": "markdownlint",
|
|
3348
|
-
"version": "0.20.
|
|
3352
|
+
"version": "0.20.4",
|
|
3349
3353
|
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
|
3350
3354
|
"main": "lib/markdownlint.js",
|
|
3351
3355
|
"types": "lib/markdownlint.d.ts",
|
package/doc/Rules.md
CHANGED
|
@@ -186,6 +186,8 @@ Tags: bullet, ul, indentation
|
|
|
186
186
|
|
|
187
187
|
Aliases: list-indent
|
|
188
188
|
|
|
189
|
+
Fixable: Most violations can be fixed by tooling
|
|
190
|
+
|
|
189
191
|
This rule is triggered when list items are parsed as being at the same level,
|
|
190
192
|
but don't have the same indentation:
|
|
191
193
|
|
|
@@ -240,6 +242,8 @@ Tags: bullet, ul, indentation
|
|
|
240
242
|
|
|
241
243
|
Aliases: ul-start-left
|
|
242
244
|
|
|
245
|
+
Fixable: Most violations can be fixed by tooling
|
|
246
|
+
|
|
243
247
|
This rule is triggered when top level lists don't start at the beginning of a
|
|
244
248
|
line:
|
|
245
249
|
|
|
@@ -287,6 +291,8 @@ Aliases: ul-indent
|
|
|
287
291
|
|
|
288
292
|
Parameters: indent, start_indented (number; default 2, boolean; default false)
|
|
289
293
|
|
|
294
|
+
Fixable: Most violations can be fixed by tooling
|
|
295
|
+
|
|
290
296
|
This rule is triggered when list items are not indented by the configured
|
|
291
297
|
number of spaces (default: 2).
|
|
292
298
|
|
|
@@ -330,6 +336,8 @@ Aliases: no-trailing-spaces
|
|
|
330
336
|
|
|
331
337
|
Parameters: br_spaces, list_item_empty_lines, strict (number; default 2, boolean; default false, boolean; default false)
|
|
332
338
|
|
|
339
|
+
Fixable: Most violations can be fixed by tooling
|
|
340
|
+
|
|
333
341
|
This rule is triggered on any lines that end with unexpected whitespace. To fix this,
|
|
334
342
|
remove the trailing space from the end of the line.
|
|
335
343
|
|
|
@@ -372,6 +380,8 @@ Aliases: no-hard-tabs
|
|
|
372
380
|
|
|
373
381
|
Parameters: code_blocks (boolean; default true)
|
|
374
382
|
|
|
383
|
+
Fixable: Most violations can be fixed by tooling
|
|
384
|
+
|
|
375
385
|
This rule is triggered by any lines that contain hard tab characters instead
|
|
376
386
|
of using spaces for indentation. To fix this, replace any hard tab characters
|
|
377
387
|
with spaces instead.
|
|
@@ -407,6 +417,8 @@ Tags: links
|
|
|
407
417
|
|
|
408
418
|
Aliases: no-reversed-links
|
|
409
419
|
|
|
420
|
+
Fixable: Most violations can be fixed by tooling
|
|
421
|
+
|
|
410
422
|
This rule is triggered when text that appears to be a link is encountered, but
|
|
411
423
|
where the syntax appears to have been reversed (the `[]` and `()` are
|
|
412
424
|
reversed):
|
|
@@ -439,6 +451,8 @@ Aliases: no-multiple-blanks
|
|
|
439
451
|
|
|
440
452
|
Parameters: maximum (number; default 1)
|
|
441
453
|
|
|
454
|
+
Fixable: Most violations can be fixed by tooling
|
|
455
|
+
|
|
442
456
|
This rule is triggered when there are multiple consecutive blank lines in the
|
|
443
457
|
document:
|
|
444
458
|
|
|
@@ -521,6 +535,8 @@ Tags: code
|
|
|
521
535
|
|
|
522
536
|
Aliases: commands-show-output
|
|
523
537
|
|
|
538
|
+
Fixable: Most violations can be fixed by tooling
|
|
539
|
+
|
|
524
540
|
This rule is triggered when there are code blocks showing shell commands to be
|
|
525
541
|
typed, and *all* of the shell commands are preceded by dollar signs ($):
|
|
526
542
|
|
|
@@ -572,6 +588,8 @@ Tags: headings, headers, atx, spaces
|
|
|
572
588
|
|
|
573
589
|
Aliases: no-missing-space-atx
|
|
574
590
|
|
|
591
|
+
Fixable: Most violations can be fixed by tooling
|
|
592
|
+
|
|
575
593
|
This rule is triggered when spaces are missing after the hash characters
|
|
576
594
|
in an atx style heading:
|
|
577
595
|
|
|
@@ -600,6 +618,8 @@ Tags: headings, headers, atx, spaces
|
|
|
600
618
|
|
|
601
619
|
Aliases: no-multiple-space-atx
|
|
602
620
|
|
|
621
|
+
Fixable: Most violations can be fixed by tooling
|
|
622
|
+
|
|
603
623
|
This rule is triggered when more than one space is used to separate the
|
|
604
624
|
heading text from the hash characters in an atx style heading:
|
|
605
625
|
|
|
@@ -629,6 +649,8 @@ Tags: headings, headers, atx_closed, spaces
|
|
|
629
649
|
|
|
630
650
|
Aliases: no-missing-space-closed-atx
|
|
631
651
|
|
|
652
|
+
Fixable: Most violations can be fixed by tooling
|
|
653
|
+
|
|
632
654
|
This rule is triggered when spaces are missing inside the hash characters
|
|
633
655
|
in a closed atx style heading:
|
|
634
656
|
|
|
@@ -659,6 +681,8 @@ Tags: headings, headers, atx_closed, spaces
|
|
|
659
681
|
|
|
660
682
|
Aliases: no-multiple-space-closed-atx
|
|
661
683
|
|
|
684
|
+
Fixable: Most violations can be fixed by tooling
|
|
685
|
+
|
|
662
686
|
This rule is triggered when more than one space is used to separate the
|
|
663
687
|
heading text from the hash characters in a closed atx style heading:
|
|
664
688
|
|
|
@@ -693,6 +717,8 @@ Aliases: blanks-around-headings, blanks-around-headers
|
|
|
693
717
|
|
|
694
718
|
Parameters: lines_above, lines_below (number; default 1)
|
|
695
719
|
|
|
720
|
+
Fixable: Most violations can be fixed by tooling
|
|
721
|
+
|
|
696
722
|
This rule is triggered when headings (any style) are either not preceded or not
|
|
697
723
|
followed by at least one blank line:
|
|
698
724
|
|
|
@@ -735,6 +761,8 @@ Tags: headings, headers, spaces
|
|
|
735
761
|
|
|
736
762
|
Aliases: heading-start-left, header-start-left
|
|
737
763
|
|
|
764
|
+
Fixable: Most violations can be fixed by tooling
|
|
765
|
+
|
|
738
766
|
This rule is triggered when a heading is indented by one or more spaces:
|
|
739
767
|
|
|
740
768
|
```markdown
|
|
@@ -857,6 +885,8 @@ Aliases: no-trailing-punctuation
|
|
|
857
885
|
|
|
858
886
|
Parameters: punctuation (string; default ".,;:!?。,;:!?")
|
|
859
887
|
|
|
888
|
+
Fixable: Most violations can be fixed by tooling
|
|
889
|
+
|
|
860
890
|
This rule is triggered on any heading that has one of the specified normal or
|
|
861
891
|
full-width punctuation characters as the last character in the line:
|
|
862
892
|
|
|
@@ -887,6 +917,8 @@ Tags: blockquote, whitespace, indentation
|
|
|
887
917
|
|
|
888
918
|
Aliases: no-multiple-space-blockquote
|
|
889
919
|
|
|
920
|
+
Fixable: Most violations can be fixed by tooling
|
|
921
|
+
|
|
890
922
|
This rule is triggered when blockquotes have more than one space after the
|
|
891
923
|
blockquote (`>`) symbol:
|
|
892
924
|
|
|
@@ -912,6 +944,8 @@ Tags: blockquote, whitespace
|
|
|
912
944
|
|
|
913
945
|
Aliases: no-blanks-blockquote
|
|
914
946
|
|
|
947
|
+
Fixable: Most violations can be fixed by tooling
|
|
948
|
+
|
|
915
949
|
This rule is triggered when two blockquote blocks are separated by nothing
|
|
916
950
|
except for a blank line:
|
|
917
951
|
|
|
@@ -1048,6 +1082,8 @@ Aliases: list-marker-space
|
|
|
1048
1082
|
|
|
1049
1083
|
Parameters: ul_single, ol_single, ul_multi, ol_multi (number; default 1)
|
|
1050
1084
|
|
|
1085
|
+
Fixable: Most violations can be fixed by tooling
|
|
1086
|
+
|
|
1051
1087
|
This rule checks for the number of spaces between a list marker (e.g. '`-`',
|
|
1052
1088
|
'`*`', '`+`' or '`1.`') and the text of the list item.
|
|
1053
1089
|
|
|
@@ -1121,6 +1157,8 @@ Aliases: blanks-around-fences
|
|
|
1121
1157
|
|
|
1122
1158
|
Parameters: list_items (boolean; default true)
|
|
1123
1159
|
|
|
1160
|
+
Fixable: Most violations can be fixed by tooling
|
|
1161
|
+
|
|
1124
1162
|
This rule is triggered when fenced code blocks are either not preceded or not
|
|
1125
1163
|
followed by a blank line:
|
|
1126
1164
|
|
|
@@ -1168,6 +1206,8 @@ Tags: bullet, ul, ol, blank_lines
|
|
|
1168
1206
|
|
|
1169
1207
|
Aliases: blanks-around-lists
|
|
1170
1208
|
|
|
1209
|
+
Fixable: Most violations can be fixed by tooling
|
|
1210
|
+
|
|
1171
1211
|
This rule is triggered when lists (of any kind) are either not preceded or not
|
|
1172
1212
|
followed by a blank line:
|
|
1173
1213
|
|
|
@@ -1235,6 +1275,8 @@ Tags: links, url
|
|
|
1235
1275
|
|
|
1236
1276
|
Aliases: no-bare-urls
|
|
1237
1277
|
|
|
1278
|
+
Fixable: Most violations can be fixed by tooling
|
|
1279
|
+
|
|
1238
1280
|
This rule is triggered whenever a URL is given that isn't surrounded by angle
|
|
1239
1281
|
brackets:
|
|
1240
1282
|
|
|
@@ -1370,6 +1412,8 @@ Tags: whitespace, emphasis
|
|
|
1370
1412
|
|
|
1371
1413
|
Aliases: no-space-in-emphasis
|
|
1372
1414
|
|
|
1415
|
+
Fixable: Most violations can be fixed by tooling
|
|
1416
|
+
|
|
1373
1417
|
This rule is triggered when emphasis markers (bold, italic) are used, but they
|
|
1374
1418
|
have spaces between the markers and the text:
|
|
1375
1419
|
|
|
@@ -1408,6 +1452,8 @@ Tags: whitespace, code
|
|
|
1408
1452
|
|
|
1409
1453
|
Aliases: no-space-in-code
|
|
1410
1454
|
|
|
1455
|
+
Fixable: Most violations can be fixed by tooling
|
|
1456
|
+
|
|
1411
1457
|
This rule is triggered for code span elements that have spaces adjacent to the
|
|
1412
1458
|
backticks:
|
|
1413
1459
|
|
|
@@ -1447,6 +1493,8 @@ Tags: whitespace, links
|
|
|
1447
1493
|
|
|
1448
1494
|
Aliases: no-space-in-links
|
|
1449
1495
|
|
|
1496
|
+
Fixable: Most violations can be fixed by tooling
|
|
1497
|
+
|
|
1450
1498
|
This rule is triggered on links that have spaces surrounding the link text:
|
|
1451
1499
|
|
|
1452
1500
|
```markdown
|
|
@@ -1639,6 +1687,8 @@ Aliases: proper-names
|
|
|
1639
1687
|
|
|
1640
1688
|
Parameters: names, code_blocks (string array; default `null`, boolean; default `true`)
|
|
1641
1689
|
|
|
1690
|
+
Fixable: Most violations can be fixed by tooling
|
|
1691
|
+
|
|
1642
1692
|
This rule is triggered when any of the strings in the `names` array do not have
|
|
1643
1693
|
the specified capitalization. It can be used to enforce a standard letter case
|
|
1644
1694
|
for the names of projects and products.
|
|
@@ -1732,6 +1782,8 @@ Tags: blank_lines
|
|
|
1732
1782
|
|
|
1733
1783
|
Aliases: single-trailing-newline
|
|
1734
1784
|
|
|
1785
|
+
Fixable: Most violations can be fixed by tooling
|
|
1786
|
+
|
|
1735
1787
|
This rule is triggered when there is not a single newline character at the end of a file.
|
|
1736
1788
|
|
|
1737
1789
|
Example that triggers the rule:
|
package/helpers/helpers.js
CHANGED
|
@@ -21,7 +21,7 @@ const inlineCommentRe =
|
|
|
21
21
|
module.exports.inlineCommentRe = inlineCommentRe;
|
|
22
22
|
|
|
23
23
|
// Regular expressions for range matching
|
|
24
|
-
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']
|
|
24
|
+
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*(?:\/|[^\s\]"'\W])/ig;
|
|
25
25
|
module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
|
|
26
26
|
module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
|
|
27
27
|
|
package/helpers/package.json
CHANGED
package/lib/md037.js
CHANGED
|
@@ -128,7 +128,9 @@ module.exports = {
|
|
|
128
128
|
}
|
|
129
129
|
// Back up one character so RegExp has a chance to match the
|
|
130
130
|
// next marker (ex: "**star**_underscore_")
|
|
131
|
-
emphasisRe.lastIndex
|
|
131
|
+
if (emphasisRe.lastIndex > 1) {
|
|
132
|
+
emphasisRe.lastIndex--;
|
|
133
|
+
}
|
|
132
134
|
} else if (emphasisRe.lastIndex > 1) {
|
|
133
135
|
// Back up one character so RegExp has a chance to match the
|
|
134
136
|
// mis-matched marker (ex: "*text_*")
|
package/lib/md044.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
const { addErrorDetailIf, bareUrlRe, escapeForRegExp, filterTokens,
|
|
6
6
|
forEachInlineChild, newLineRe } = require("../helpers");
|
|
7
7
|
|
|
8
|
+
const startNonWordRe = /^\W/;
|
|
9
|
+
const endNonWordRe = /\W$/;
|
|
10
|
+
|
|
8
11
|
module.exports = {
|
|
9
12
|
"names": [ "MD044", "proper-names" ],
|
|
10
13
|
"description": "Proper names should have the correct capitalization",
|
|
@@ -16,7 +19,10 @@ module.exports = {
|
|
|
16
19
|
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
|
17
20
|
names.forEach((name) => {
|
|
18
21
|
const escapedName = escapeForRegExp(name);
|
|
19
|
-
const
|
|
22
|
+
const startNamePattern = startNonWordRe.test(name) ? "" : "\\S*\\b";
|
|
23
|
+
const endNamePattern = endNonWordRe.test(name) ? "" : "\\b\\S*";
|
|
24
|
+
const namePattern =
|
|
25
|
+
`(${startNamePattern})(${escapedName})(${endNamePattern})`;
|
|
20
26
|
const anyNameRe = new RegExp(namePattern, "gi");
|
|
21
27
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
22
28
|
function forToken(token) {
|
|
@@ -25,34 +31,31 @@ module.exports = {
|
|
|
25
31
|
.forEach((line, index) => {
|
|
26
32
|
let match = null;
|
|
27
33
|
while ((match = anyNameRe.exec(line)) !== null) {
|
|
28
|
-
const fullMatch = match
|
|
34
|
+
const [ fullMatch, leftMatch, nameMatch, rightMatch ] = match;
|
|
29
35
|
if (fullMatch.search(bareUrlRe) === -1) {
|
|
30
36
|
const wordMatch = fullMatch
|
|
31
|
-
.replace(
|
|
37
|
+
.replace(new RegExp(`^\\W{0,${leftMatch.length}}`), "")
|
|
38
|
+
.replace(new RegExp(`\\W{0,${rightMatch.length}}$`), "");
|
|
32
39
|
if (!names.includes(wordMatch)) {
|
|
33
40
|
const lineNumber = token.lineNumber + index + fenceOffset;
|
|
34
41
|
const fullLine = params.lines[lineNumber - 1];
|
|
35
|
-
let matchIndex = match.index;
|
|
36
42
|
const matchLength = wordMatch.length;
|
|
37
|
-
const
|
|
38
|
-
fullLine.slice(matchIndex, matchIndex + matchLength);
|
|
39
|
-
if (fullLineWord !== wordMatch) {
|
|
40
|
-
// Attempt to fix bad offset due to inline content
|
|
41
|
-
matchIndex = fullLine.indexOf(wordMatch);
|
|
42
|
-
}
|
|
43
|
+
const matchIndex = fullLine.indexOf(wordMatch);
|
|
43
44
|
const range = (matchIndex === -1) ?
|
|
44
45
|
null :
|
|
45
46
|
[ matchIndex + 1, matchLength ];
|
|
46
|
-
const fixInfo = (matchIndex === -1) ?
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const fixInfo = (matchIndex === -1) ?
|
|
48
|
+
null :
|
|
49
|
+
{
|
|
50
|
+
"editColumn": matchIndex + 1,
|
|
51
|
+
"deleteCount": matchLength,
|
|
52
|
+
"insertText": name
|
|
53
|
+
};
|
|
51
54
|
addErrorDetailIf(
|
|
52
55
|
onError,
|
|
53
56
|
lineNumber,
|
|
54
57
|
name,
|
|
55
|
-
|
|
58
|
+
nameMatch,
|
|
56
59
|
null,
|
|
57
60
|
null,
|
|
58
61
|
range,
|