markdownlint 0.23.0 → 0.25.1

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.
@@ -1,5 +1,5 @@
1
- /*! markdownlint 0.23.0 https://github.com/DavidAnson/markdownlint @license MIT */
2
- var markdownlint;markdownlint =
1
+ /*! markdownlint 0.25.1 https://github.com/DavidAnson/markdownlint @license MIT */
2
+ var markdownlint;
3
3
  /******/ (() => { // webpackBootstrap
4
4
  /******/ var __webpack_modules__ = ({
5
5
 
@@ -25,12 +25,11 @@ module.exports = webpackEmptyContext;
25
25
  /*!*****************************!*\
26
26
  !*** ../helpers/helpers.js ***!
27
27
  \*****************************/
28
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
28
+ /***/ ((module) => {
29
29
 
30
30
  "use strict";
31
31
  // @ts-check
32
32
 
33
- var os = __webpack_require__(/*! os */ "?5533");
34
33
  // Regular expression for matching common newline characters
35
34
  // See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
36
35
  var newLineRe = /\r\n?|\n/g;
@@ -51,9 +50,10 @@ module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
51
50
  // Regular expression for all instances of emphasis markers
52
51
  var emphasisMarkersRe = /[_*]/g;
53
52
  // Regular expression for inline links and shortcut reference links
54
- var linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
55
- // readFile options for reading with the UTF-8 encoding
56
- module.exports.utf8Encoding = "utf8";
53
+ var linkRe = /(\[(?:[^[\]]|\[[^\]]*\])*\])(\(\S*\)|\[\S*\])?/g;
54
+ module.exports.linkRe = linkRe;
55
+ // Regular expression for link reference definition lines
56
+ module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/;
57
57
  // All punctuation characters (normal and full-width)
58
58
  var allPunctuation = ".,;:!?。,;:!?";
59
59
  module.exports.allPunctuation = allPunctuation;
@@ -76,12 +76,18 @@ module.exports.isObject = function isObject(obj) {
76
76
  return (obj !== null) && (typeof obj === "object") && !Array.isArray(obj);
77
77
  };
78
78
  // Returns true iff the input line is blank (no content)
79
- // Example: Contains nothing, whitespace, or comments
80
- var blankLineRe = />|(?:<!--.*?-->)/g;
79
+ // Example: Contains nothing, whitespace, or comment (unclosed start/end okay)
81
80
  module.exports.isBlankLine = function isBlankLine(line) {
82
81
  // Call to String.replace follows best practices and is not a security check
83
82
  // False-positive for js/incomplete-multi-character-sanitization
84
- return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
83
+ return (!line ||
84
+ !line.trim() ||
85
+ !line
86
+ .replace(/<!--.*?-->/g, "")
87
+ .replace(/<!--.*$/g, "")
88
+ .replace(/^.*-->/g, "")
89
+ .replace(/>/g, "")
90
+ .trim());
85
91
  };
86
92
  /**
87
93
  * Compare function for Array.prototype.sort for ascending order of numbers.
@@ -189,6 +195,21 @@ module.exports.fencedCodeBlockStyleFor =
189
195
  return "backtick";
190
196
  }
191
197
  };
198
+ /**
199
+ * Return the string representation of a emphasis or strong markup character.
200
+ *
201
+ * @param {string} markup Emphasis or strong string.
202
+ * @returns {string} String representation.
203
+ */
204
+ module.exports.emphasisOrStrongStyleFor =
205
+ function emphasisOrStrongStyleFor(markup) {
206
+ switch (markup[0]) {
207
+ case "*":
208
+ return "asterisk";
209
+ default:
210
+ return "underscore";
211
+ }
212
+ };
192
213
  /**
193
214
  * Return the number of characters of indent for a token.
194
215
  *
@@ -250,10 +271,11 @@ module.exports.filterTokens = filterTokens;
250
271
  * @returns {boolean} True iff token is a math block.
251
272
  */
252
273
  function isMathBlock(token) {
253
- return ((token.tag === "math") &&
274
+ return (((token.tag === "$$") || (token.tag === "math")) &&
254
275
  token.type.startsWith("math_block") &&
255
276
  !token.type.endsWith("_end"));
256
277
  }
278
+ module.exports.isMathBlock = isMathBlock;
257
279
  // Get line metadata array
258
280
  module.exports.getLineMetadata = function getLineMetadata(params) {
259
281
  var lineMetadata = params.lines.map(function (line, index) { return [line, index, false, 0, false, false, false, false]; });
@@ -291,27 +313,29 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
291
313
  });
292
314
  return lineMetadata;
293
315
  };
294
- // Calls the provided function for each line (with context)
295
- module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
316
+ /**
317
+ * Calls the provided function for each line.
318
+ *
319
+ * @param {Object} lineMetadata Line metadata object.
320
+ * @param {Function} handler Function taking (line, lineIndex, inCode, onFence,
321
+ * inTable, inItem, inBreak, inMath).
322
+ * @returns {void}
323
+ */
324
+ function forEachLine(lineMetadata, handler) {
296
325
  lineMetadata.forEach(function forMetadata(metadata) {
297
- // Parameters:
298
- // line, lineIndex, inCode, onFence, inTable, inItem, inBreak, inMath
299
326
  handler.apply(void 0, metadata);
300
327
  });
301
- };
328
+ }
329
+ module.exports.forEachLine = forEachLine;
302
330
  // Returns (nested) lists as a flat array (in order)
303
- module.exports.flattenLists = function flattenLists(params) {
331
+ module.exports.flattenLists = function flattenLists(tokens) {
304
332
  var flattenedLists = [];
305
333
  var stack = [];
306
334
  var current = null;
307
335
  var nesting = 0;
308
336
  var nestingStack = [];
309
337
  var lastWithMap = { "map": [0, 1] };
310
- params.tokens.forEach(function (token) {
311
- if (isMathBlock(token) && token.map[1]) {
312
- // markdown-it-texmath plugin does not account for math_block_end
313
- token.map[1]++;
314
- }
338
+ tokens.forEach(function (token) {
315
339
  if ((token.type === "bullet_list_open") ||
316
340
  (token.type === "ordered_list_open")) {
317
341
  // Save current context and start a new one
@@ -387,7 +411,8 @@ module.exports.forEachHeading = function forEachHeading(params, handler) {
387
411
  * Calls the provided function for each inline code span's content.
388
412
  *
389
413
  * @param {string} input Markdown content.
390
- * @param {Function} handler Callback function.
414
+ * @param {Function} handler Callback function taking (code, lineIndex,
415
+ * columnIndex, ticks).
391
416
  * @returns {void}
392
417
  */
393
418
  function forEachInlineCodeSpan(input, handler) {
@@ -516,14 +541,60 @@ module.exports.addErrorContext = function addErrorContext(onError, lineNumber, c
516
541
  }
517
542
  addError(onError, lineNumber, null, context, range, fixInfo);
518
543
  };
544
+ /**
545
+ * Returns an array of code block and span content ranges.
546
+ *
547
+ * @param {Object} params RuleParams instance.
548
+ * @param {Object} lineMetadata Line metadata object.
549
+ * @returns {number[][]} Array of ranges (lineIndex, columnIndex, length).
550
+ */
551
+ module.exports.codeBlockAndSpanRanges = function (params, lineMetadata) {
552
+ var exclusions = [];
553
+ // Add code block ranges (excludes fences)
554
+ forEachLine(lineMetadata, function (line, lineIndex, inCode, onFence) {
555
+ if (inCode && !onFence) {
556
+ exclusions.push([lineIndex, 0, line.length]);
557
+ }
558
+ });
559
+ // Add code span ranges (excludes ticks)
560
+ filterTokens(params, "inline", function (token) {
561
+ if (token.children.some(function (child) { return child.type === "code_inline"; })) {
562
+ var tokenLines = params.lines.slice(token.map[0], token.map[1]);
563
+ forEachInlineCodeSpan(tokenLines.join("\n"), function (code, lineIndex, columnIndex) {
564
+ var codeLines = code.split(newLineRe);
565
+ for (var _i = 0, _a = codeLines.entries(); _i < _a.length; _i++) {
566
+ var _b = _a[_i], i = _b[0], line = _b[1];
567
+ exclusions.push([
568
+ token.lineNumber - 1 + lineIndex + i,
569
+ i ? 0 : columnIndex,
570
+ line.length
571
+ ]);
572
+ }
573
+ });
574
+ }
575
+ });
576
+ return exclusions;
577
+ };
578
+ /**
579
+ * Determines whether the specified range overlaps another range.
580
+ *
581
+ * @param {number[][]} ranges Array of ranges (line, index, length).
582
+ * @param {number} lineIndex Line index to check.
583
+ * @param {number} index Index to check.
584
+ * @param {number} length Length to check.
585
+ * @returns {boolean} True iff the specified range overlaps.
586
+ */
587
+ module.exports.overlapsAnyRange = function (ranges, lineIndex, index, length) { return (!ranges.every(function (span) { return ((lineIndex !== span[0]) ||
588
+ (index + length < span[1]) ||
589
+ (index > span[1] + span[2])); })); };
519
590
  // Returns a range object for a line by applying a RegExp
520
591
  module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {
521
592
  var range = null;
522
593
  var match = line.match(regexp);
523
594
  if (match) {
524
595
  var column = match.index + 1;
525
- var length_1 = match[0].length;
526
- range = [column, length_1];
596
+ var length = match[0].length;
597
+ range = [column, length];
527
598
  }
528
599
  return range;
529
600
  };
@@ -544,6 +615,18 @@ module.exports.frontMatterHasTitle =
544
615
  function emphasisMarkersInContent(params) {
545
616
  var lines = params.lines;
546
617
  var byLine = new Array(lines.length);
618
+ // Search links
619
+ lines.forEach(function (tokenLine, tokenLineIndex) {
620
+ var inLine = [];
621
+ var linkMatch = null;
622
+ while ((linkMatch = linkRe.exec(tokenLine))) {
623
+ var markerMatch = null;
624
+ while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
625
+ inLine.push(linkMatch.index + markerMatch.index);
626
+ }
627
+ }
628
+ byLine[tokenLineIndex] = inLine;
629
+ });
547
630
  // Search code spans
548
631
  filterTokens(params, "inline", function (token) {
549
632
  var children = token.children, lineNumber = token.lineNumber, map = token.map;
@@ -552,30 +635,18 @@ function emphasisMarkersInContent(params) {
552
635
  forEachInlineCodeSpan(tokenLines.join("\n"), function (code, lineIndex, column, tickCount) {
553
636
  var codeLines = code.split(newLineRe);
554
637
  codeLines.forEach(function (codeLine, codeLineIndex) {
638
+ var byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
639
+ var inLine = byLine[byLineIndex];
640
+ var codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
555
641
  var match = null;
556
642
  while ((match = emphasisMarkersRe.exec(codeLine))) {
557
- var byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
558
- var inLine = byLine[byLineIndex] || [];
559
- var codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
560
643
  inLine.push(codeLineOffset + match.index);
561
- byLine[byLineIndex] = inLine;
562
644
  }
645
+ byLine[byLineIndex] = inLine;
563
646
  });
564
647
  });
565
648
  }
566
649
  });
567
- // Search links
568
- lines.forEach(function (tokenLine, tokenLineIndex) {
569
- var linkMatch = null;
570
- while ((linkMatch = linkRe.exec(tokenLine))) {
571
- var markerMatch = null;
572
- while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
573
- var inLine = byLine[tokenLineIndex] || [];
574
- inLine.push(linkMatch.index + markerMatch.index);
575
- byLine[tokenLineIndex] = inLine;
576
- }
577
- }
578
- });
579
650
  return byLine;
580
651
  }
581
652
  module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
@@ -583,9 +654,10 @@ module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
583
654
  * Gets the most common line ending, falling back to the platform default.
584
655
  *
585
656
  * @param {string} input Markdown content to analyze.
657
+ * @param {string} [platform] Platform identifier (process.platform).
586
658
  * @returns {string} Preferred line ending.
587
659
  */
588
- function getPreferredLineEnding(input) {
660
+ function getPreferredLineEnding(input, platform) {
589
661
  var cr = 0;
590
662
  var lf = 0;
591
663
  var crlf = 0;
@@ -606,7 +678,8 @@ function getPreferredLineEnding(input) {
606
678
  });
607
679
  var preferredLineEnding = null;
608
680
  if (!cr && !lf && !crlf) {
609
- preferredLineEnding = os.EOL;
681
+ preferredLineEnding =
682
+ ((platform || process.platform) === "win32") ? "\r\n" : "\n";
610
683
  }
611
684
  else if ((lf >= crlf) && (lf >= cr)) {
612
685
  preferredLineEnding = "\n";
@@ -714,6 +787,79 @@ module.exports.applyFixes = function applyFixes(input, errors) {
714
787
  // Return corrected input
715
788
  return lines.filter(function (line) { return line !== null; }).join(lineEnding);
716
789
  };
790
+ /**
791
+ * Gets the range and fixInfo values for reporting an error if the expected
792
+ * text is found on the specified line.
793
+ *
794
+ * @param {string[]} lines Lines of Markdown content.
795
+ * @param {number} lineIndex Line index to check.
796
+ * @param {string} search Text to search for.
797
+ * @param {string} replace Text to replace with.
798
+ * @returns {Object} Range and fixInfo wrapper.
799
+ */
800
+ function getRangeAndFixInfoIfFound(lines, lineIndex, search, replace) {
801
+ var range = null;
802
+ var fixInfo = null;
803
+ var searchIndex = lines[lineIndex].indexOf(search);
804
+ if (searchIndex !== -1) {
805
+ var column = searchIndex + 1;
806
+ var length = search.length;
807
+ range = [column, length];
808
+ fixInfo = {
809
+ "editColumn": column,
810
+ "deleteCount": length,
811
+ "insertText": replace
812
+ };
813
+ }
814
+ return {
815
+ range: range,
816
+ fixInfo: fixInfo
817
+ };
818
+ }
819
+ module.exports.getRangeAndFixInfoIfFound = getRangeAndFixInfoIfFound;
820
+ /**
821
+ * Gets the next (subsequent) child token if it is of the expected type.
822
+ *
823
+ * @param {Object} parentToken Parent token.
824
+ * @param {Object} childToken Child token basis.
825
+ * @param {string} nextType Token type of next token.
826
+ * @param {string} nextNextType Token type of next-next token.
827
+ * @returns {Object} Next token.
828
+ */
829
+ function getNextChildToken(parentToken, childToken, nextType, nextNextType) {
830
+ var children = parentToken.children;
831
+ var index = children.indexOf(childToken);
832
+ if ((index !== -1) &&
833
+ (children.length > index + 2) &&
834
+ (children[index + 1].type === nextType) &&
835
+ (children[index + 2].type === nextNextType)) {
836
+ return children[index + 1];
837
+ }
838
+ return null;
839
+ }
840
+ module.exports.getNextChildToken = getNextChildToken;
841
+ /**
842
+ * Calls Object.freeze() on an object and its children.
843
+ *
844
+ * @param {Object} obj Object to deep freeze.
845
+ * @returns {Object} Object passed to the function.
846
+ */
847
+ function deepFreeze(obj) {
848
+ var pending = [obj];
849
+ var current = null;
850
+ while ((current = pending.shift())) {
851
+ Object.freeze(current);
852
+ for (var _i = 0, _a = Object.getOwnPropertyNames(current); _i < _a.length; _i++) {
853
+ var name = _a[_i];
854
+ var value = current[name];
855
+ if (value && (typeof value === "object")) {
856
+ pending.push(value);
857
+ }
858
+ }
859
+ }
860
+ return obj;
861
+ }
862
+ module.exports.deepFreeze = deepFreeze;
717
863
 
718
864
 
719
865
  /***/ }),
@@ -727,12 +873,12 @@ module.exports.applyFixes = function applyFixes(input, errors) {
727
873
  "use strict";
728
874
  // @ts-check
729
875
 
730
- var lineMetadata = null;
731
- module.exports.lineMetadata = function (value) {
876
+ var codeBlockAndSpanRanges = null;
877
+ module.exports.codeBlockAndSpanRanges = function (value) {
732
878
  if (value) {
733
- lineMetadata = value;
879
+ codeBlockAndSpanRanges = value;
734
880
  }
735
- return lineMetadata;
881
+ return codeBlockAndSpanRanges;
736
882
  };
737
883
  var flattenedLists = null;
738
884
  module.exports.flattenedLists = function (value) {
@@ -741,12 +887,36 @@ module.exports.flattenedLists = function (value) {
741
887
  }
742
888
  return flattenedLists;
743
889
  };
890
+ var lineMetadata = null;
891
+ module.exports.lineMetadata = function (value) {
892
+ if (value) {
893
+ lineMetadata = value;
894
+ }
895
+ return lineMetadata;
896
+ };
744
897
  module.exports.clear = function () {
745
- lineMetadata = null;
898
+ codeBlockAndSpanRanges = null;
746
899
  flattenedLists = null;
900
+ lineMetadata = null;
747
901
  };
748
902
 
749
903
 
904
+ /***/ }),
905
+
906
+ /***/ "../lib/constants.js":
907
+ /*!***************************!*\
908
+ !*** ../lib/constants.js ***!
909
+ \***************************/
910
+ /***/ ((module) => {
911
+
912
+ "use strict";
913
+ // @ts-check
914
+
915
+ module.exports.deprecatedRuleNames = ["MD002", "MD006"];
916
+ module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
917
+ module.exports.version = "0.25.1";
918
+
919
+
750
920
  /***/ }),
751
921
 
752
922
  /***/ "../lib/markdownlint.js":
@@ -769,28 +939,34 @@ var __assign = (this && this.__assign) || function () {
769
939
  };
770
940
  return __assign.apply(this, arguments);
771
941
  };
772
- var __spreadArrays = (this && this.__spreadArrays) || function () {
773
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
774
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
775
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
776
- r[k] = a[j];
777
- return r;
942
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
943
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
944
+ if (ar || !(i in from)) {
945
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
946
+ ar[i] = from[i];
947
+ }
948
+ }
949
+ return to.concat(ar || Array.prototype.slice.call(from));
778
950
  };
779
- var fs = __webpack_require__(/*! fs */ "?65c5");
780
- var path = __webpack_require__(/*! path */ "?0f27");
781
- var promisify = __webpack_require__(/*! util */ "?0bed").promisify;
951
+ var path = __webpack_require__(/*! path */ "?b85c");
952
+ var promisify = (__webpack_require__(/*! util */ "?96a2").promisify);
782
953
  var markdownIt = __webpack_require__(/*! markdown-it */ "markdown-it");
954
+ var deprecatedRuleNames = (__webpack_require__(/*! ./constants */ "../lib/constants.js").deprecatedRuleNames);
783
955
  var rules = __webpack_require__(/*! ./rules */ "../lib/rules.js");
784
956
  var helpers = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js");
785
957
  var cache = __webpack_require__(/*! ./cache */ "../lib/cache.js");
786
- var deprecatedRuleNames = ["MD002", "MD006"];
958
+ // @ts-ignore
959
+ // eslint-disable-next-line camelcase, max-len, no-inline-comments, no-undef
960
+ var dynamicRequire = (typeof require === "undefined") ? __webpack_require__("../lib sync recursive") : /* c8 ignore next */ require;
961
+ // Capture native require implementation for dynamic loading of modules
787
962
  /**
788
963
  * Validate the list of rules for structure and reuse.
789
964
  *
790
965
  * @param {Rule[]} ruleList List of rules.
966
+ * @param {boolean} synchronous Whether to execute synchronously.
791
967
  * @returns {string} Error message if validation fails.
792
968
  */
793
- function validateRuleList(ruleList) {
969
+ function validateRuleList(ruleList, synchronous) {
794
970
  var result = null;
795
971
  if (ruleList.length === rules.length) {
796
972
  // No need to validate if only using built-in rules
@@ -827,6 +1003,15 @@ function validateRuleList(ruleList) {
827
1003
  (Object.getPrototypeOf(rule.information) !== URL.prototype)) {
828
1004
  result = newError("information");
829
1005
  }
1006
+ if (!result &&
1007
+ (rule.asynchronous !== undefined) &&
1008
+ (typeof rule.asynchronous !== "boolean")) {
1009
+ result = newError("asynchronous");
1010
+ }
1011
+ if (!result && rule.asynchronous && synchronous) {
1012
+ result = new Error("Custom rule " + rule.names.join("/") + " at index " + customIndex +
1013
+ " is asynchronous and can not be used in a synchronous context.");
1014
+ }
830
1015
  if (!result) {
831
1016
  rule.names.forEach(function forName(name) {
832
1017
  var nameUpper = name.toUpperCase();
@@ -943,23 +1128,22 @@ function removeFrontMatter(content, frontMatter) {
943
1128
  * @returns {void}
944
1129
  */
945
1130
  function annotateTokens(tokens, lines) {
946
- var tableMap = null;
1131
+ var trMap = null;
947
1132
  tokens.forEach(function forToken(token) {
948
- // Handle missing maps for table head/body
949
- if ((token.type === "thead_open") ||
950
- (token.type === "tbody_open")) {
951
- tableMap = token.map.slice();
1133
+ // Provide missing maps for table content
1134
+ if (token.type === "tr_open") {
1135
+ trMap = token.map;
952
1136
  }
953
- else if ((token.type === "tr_close") &&
954
- tableMap) {
955
- tableMap[0]++;
1137
+ else if (token.type === "tr_close") {
1138
+ trMap = null;
956
1139
  }
957
- else if ((token.type === "thead_close") ||
958
- (token.type === "tbody_close")) {
959
- tableMap = null;
1140
+ if (!token.map && trMap) {
1141
+ token.map = __spreadArray([], trMap, true);
960
1142
  }
961
- if (tableMap && !token.map) {
962
- token.map = tableMap.slice();
1143
+ // Adjust maps for math blocks
1144
+ if (helpers.isMathBlock(token) && token.map[1]) {
1145
+ // markdown-it-texmath plugin does not account for math_block_end
1146
+ token.map[1]++;
963
1147
  }
964
1148
  // Update token metadata
965
1149
  if (token.map) {
@@ -1080,8 +1264,7 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
1080
1264
  var enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
1081
1265
  // Helper functions
1082
1266
  // eslint-disable-next-line jsdoc/require-jsdoc
1083
- function handleInlineConfig(perLine, forEachMatch, forEachLine) {
1084
- var input = perLine ? lines : [lines.join("\n")];
1267
+ function handleInlineConfig(input, forEachMatch, forEachLine) {
1085
1268
  input.forEach(function (line, lineIndex) {
1086
1269
  if (!noInlineConfig) {
1087
1270
  var match = null;
@@ -1110,6 +1293,7 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
1110
1293
  }
1111
1294
  // eslint-disable-next-line jsdoc/require-jsdoc
1112
1295
  function applyEnableDisable(action, parameter, state) {
1296
+ state = __assign({}, state);
1113
1297
  var enabled = (action.startsWith("ENABLE"));
1114
1298
  var items = parameter ?
1115
1299
  parameter.trim().toUpperCase().split(/\s+/) :
@@ -1119,38 +1303,40 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
1119
1303
  state[ruleName] = enabled;
1120
1304
  });
1121
1305
  });
1306
+ return state;
1122
1307
  }
1123
1308
  // eslint-disable-next-line jsdoc/require-jsdoc
1124
1309
  function enableDisableFile(action, parameter) {
1125
1310
  if ((action === "ENABLE-FILE") || (action === "DISABLE-FILE")) {
1126
- applyEnableDisable(action, parameter, enabledRules);
1311
+ enabledRules = applyEnableDisable(action, parameter, enabledRules);
1127
1312
  }
1128
1313
  }
1129
1314
  // eslint-disable-next-line jsdoc/require-jsdoc
1130
1315
  function captureRestoreEnableDisable(action, parameter) {
1131
1316
  if (action === "CAPTURE") {
1132
- capturedRules = __assign({}, enabledRules);
1317
+ capturedRules = enabledRules;
1133
1318
  }
1134
1319
  else if (action === "RESTORE") {
1135
- enabledRules = __assign({}, capturedRules);
1320
+ enabledRules = capturedRules;
1136
1321
  }
1137
1322
  else if ((action === "ENABLE") || (action === "DISABLE")) {
1138
- enabledRules = __assign({}, enabledRules);
1139
- applyEnableDisable(action, parameter, enabledRules);
1323
+ enabledRules = applyEnableDisable(action, parameter, enabledRules);
1140
1324
  }
1141
1325
  }
1142
1326
  // eslint-disable-next-line jsdoc/require-jsdoc
1143
1327
  function updateLineState() {
1144
- enabledRulesPerLineNumber.push(__assign({}, enabledRules));
1328
+ enabledRulesPerLineNumber.push(enabledRules);
1145
1329
  }
1146
1330
  // eslint-disable-next-line jsdoc/require-jsdoc
1147
1331
  function disableNextLine(action, parameter, lineNumber) {
1148
1332
  if (action === "DISABLE-NEXT-LINE") {
1149
- applyEnableDisable(action, parameter, enabledRulesPerLineNumber[lineNumber + 1] || {});
1333
+ var nextLineNumber = frontMatterLines.length + lineNumber + 1;
1334
+ enabledRulesPerLineNumber[nextLineNumber] =
1335
+ applyEnableDisable(action, parameter, enabledRulesPerLineNumber[nextLineNumber] || {});
1150
1336
  }
1151
1337
  }
1152
1338
  // Handle inline comments
1153
- handleInlineConfig(false, configureFile);
1339
+ handleInlineConfig([lines.join("\n")], configureFile);
1154
1340
  var effectiveConfig = getEffectiveConfig(ruleList, config, aliasToRuleNames);
1155
1341
  ruleList.forEach(function (rule) {
1156
1342
  var ruleName = rule.names[0].toUpperCase();
@@ -1158,44 +1344,15 @@ function getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlin
1158
1344
  enabledRules[ruleName] = !!effectiveConfig[ruleName];
1159
1345
  });
1160
1346
  capturedRules = enabledRules;
1161
- handleInlineConfig(true, enableDisableFile);
1162
- handleInlineConfig(true, captureRestoreEnableDisable, updateLineState);
1163
- handleInlineConfig(true, disableNextLine);
1347
+ handleInlineConfig(lines, enableDisableFile);
1348
+ handleInlineConfig(lines, captureRestoreEnableDisable, updateLineState);
1349
+ handleInlineConfig(lines, disableNextLine);
1164
1350
  // Return results
1165
1351
  return {
1166
1352
  effectiveConfig: effectiveConfig,
1167
1353
  enabledRulesPerLineNumber: enabledRulesPerLineNumber
1168
1354
  };
1169
1355
  }
1170
- /**
1171
- * Compare function for Array.prototype.sort for ascending order of errors.
1172
- *
1173
- * @param {LintError} a First error.
1174
- * @param {LintError} b Second error.
1175
- * @returns {number} Positive value if a>b, negative value if b<a, 0 otherwise.
1176
- */
1177
- function lineNumberComparison(a, b) {
1178
- return a.lineNumber - b.lineNumber;
1179
- }
1180
- /**
1181
- * Filter function to include everything.
1182
- *
1183
- * @returns {boolean} True.
1184
- */
1185
- function filterAllValues() {
1186
- return true;
1187
- }
1188
- /**
1189
- * Function to return unique values from a sorted errors array.
1190
- *
1191
- * @param {LintError} value Error instance.
1192
- * @param {number} index Index in array.
1193
- * @param {LintError[]} array Array of errors.
1194
- * @returns {boolean} Filter value.
1195
- */
1196
- function uniqueFilterForSortedErrors(value, index, array) {
1197
- return (index === 0) || (value.lineNumber > array[index - 1].lineNumber);
1198
- }
1199
1356
  /**
1200
1357
  * Lints a string containing Markdown content.
1201
1358
  *
@@ -1227,26 +1384,25 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1227
1384
  var _a = getEnabledRulesPerLineNumber(ruleList, lines, frontMatterLines, noInlineConfig, config, aliasToRuleNames), effectiveConfig = _a.effectiveConfig, enabledRulesPerLineNumber = _a.enabledRulesPerLineNumber;
1228
1385
  // Create parameters for rules
1229
1386
  var params = {
1230
- name: name,
1231
- tokens: tokens,
1232
- lines: lines,
1233
- frontMatterLines: frontMatterLines
1387
+ "name": helpers.deepFreeze(name),
1388
+ "tokens": helpers.deepFreeze(tokens),
1389
+ "lines": helpers.deepFreeze(lines),
1390
+ "frontMatterLines": helpers.deepFreeze(frontMatterLines)
1234
1391
  };
1235
1392
  cache.lineMetadata(helpers.getLineMetadata(params));
1236
- cache.flattenedLists(helpers.flattenLists(params));
1393
+ cache.flattenedLists(helpers.flattenLists(params.tokens));
1394
+ cache.codeBlockAndSpanRanges(helpers.codeBlockAndSpanRanges(params, cache.lineMetadata()));
1237
1395
  // Function to run for each rule
1238
- var result = (resultVersion === 0) ? {} : [];
1396
+ var results = [];
1239
1397
  // eslint-disable-next-line jsdoc/require-jsdoc
1240
1398
  function forRule(rule) {
1241
1399
  // Configure rule
1242
- var ruleNameFriendly = rule.names[0];
1243
- var ruleName = ruleNameFriendly.toUpperCase();
1400
+ var ruleName = rule.names[0].toUpperCase();
1244
1401
  params.config = effectiveConfig[ruleName];
1245
1402
  // eslint-disable-next-line jsdoc/require-jsdoc
1246
1403
  function throwError(property) {
1247
1404
  throw new Error("Property '" + property + "' of onError parameter is incorrect.");
1248
1405
  }
1249
- var errors = [];
1250
1406
  // eslint-disable-next-line jsdoc/require-jsdoc
1251
1407
  function onError(errorInfo) {
1252
1408
  if (!errorInfo ||
@@ -1255,6 +1411,10 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1255
1411
  (errorInfo.lineNumber > lines.length)) {
1256
1412
  throwError("lineNumber");
1257
1413
  }
1414
+ var lineNumber = errorInfo.lineNumber + frontMatterLines.length;
1415
+ if (!enabledRulesPerLineNumber[lineNumber][ruleName]) {
1416
+ return;
1417
+ }
1258
1418
  if (errorInfo.detail &&
1259
1419
  !helpers.isString(errorInfo.detail)) {
1260
1420
  throwError("detail");
@@ -1315,83 +1475,115 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1315
1475
  cleanFixInfo.insertText = fixInfo.insertText;
1316
1476
  }
1317
1477
  }
1318
- errors.push({
1319
- "lineNumber": errorInfo.lineNumber + frontMatterLines.length,
1320
- "detail": errorInfo.detail || null,
1321
- "context": errorInfo.context || null,
1322
- "range": errorInfo.range ? __spreadArrays(errorInfo.range) : null,
1478
+ results.push({
1479
+ lineNumber: lineNumber,
1480
+ "ruleName": rule.names[0],
1481
+ "ruleNames": rule.names,
1482
+ "ruleDescription": rule.description,
1483
+ "ruleInformation": rule.information ? rule.information.href : null,
1484
+ "errorDetail": errorInfo.detail || null,
1485
+ "errorContext": errorInfo.context || null,
1486
+ "errorRange": errorInfo.range ? __spreadArray([], errorInfo.range, true) : null,
1323
1487
  "fixInfo": fixInfo ? cleanFixInfo : null
1324
1488
  });
1325
1489
  }
1326
- // Call (possibly external) rule function
1327
- if (handleRuleFailures) {
1328
- try {
1329
- rule["function"](params, onError);
1490
+ // Call (possibly external) rule function to report errors
1491
+ var catchCallsOnError = function (error) { return onError({
1492
+ "lineNumber": 1,
1493
+ "detail": "This rule threw an exception: ".concat(error.message || error)
1494
+ }); };
1495
+ var invokeRuleFunction = function () { return rule.function(params, onError); };
1496
+ if (rule.asynchronous) {
1497
+ // Asynchronous rule, ensure it returns a Promise
1498
+ var ruleFunctionPromise = Promise.resolve().then(invokeRuleFunction);
1499
+ return handleRuleFailures ?
1500
+ ruleFunctionPromise.catch(catchCallsOnError) :
1501
+ ruleFunctionPromise;
1502
+ }
1503
+ // Synchronous rule
1504
+ try {
1505
+ invokeRuleFunction();
1506
+ }
1507
+ catch (error) {
1508
+ if (handleRuleFailures) {
1509
+ catchCallsOnError(error);
1330
1510
  }
1331
- catch (error) {
1332
- onError({
1333
- "lineNumber": 1,
1334
- "detail": "This rule threw an exception: " + error.message
1335
- });
1511
+ else {
1512
+ throw error;
1336
1513
  }
1337
1514
  }
1338
- else {
1339
- rule["function"](params, onError);
1340
- }
1341
- // Record any errors (significant performance benefit from length check)
1342
- if (errors.length > 0) {
1343
- errors.sort(lineNumberComparison);
1344
- var filteredErrors = errors
1345
- .filter((resultVersion === 3) ?
1346
- filterAllValues :
1347
- uniqueFilterForSortedErrors)
1348
- .filter(function removeDisabledRules(error) {
1349
- return enabledRulesPerLineNumber[error.lineNumber][ruleName];
1350
- })
1351
- .map(function formatResults(error) {
1352
- if (resultVersion === 0) {
1353
- return error.lineNumber;
1354
- }
1355
- var errorObject = {};
1356
- errorObject.lineNumber = error.lineNumber;
1357
- if (resultVersion === 1) {
1358
- errorObject.ruleName = ruleNameFriendly;
1359
- errorObject.ruleAlias = rule.names[1] || rule.names[0];
1360
- }
1361
- else {
1362
- errorObject.ruleNames = rule.names;
1363
- }
1364
- errorObject.ruleDescription = rule.description;
1365
- errorObject.ruleInformation =
1366
- rule.information ? rule.information.href : null;
1367
- errorObject.errorDetail = error.detail;
1368
- errorObject.errorContext = error.context;
1369
- errorObject.errorRange = error.range;
1370
- if (resultVersion === 3) {
1371
- errorObject.fixInfo = error.fixInfo;
1372
- }
1373
- return errorObject;
1515
+ return null;
1516
+ }
1517
+ // eslint-disable-next-line jsdoc/require-jsdoc
1518
+ function formatResults() {
1519
+ // Sort results by rule name by line number
1520
+ results.sort(function (a, b) { return (a.ruleName.localeCompare(b.ruleName) ||
1521
+ a.lineNumber - b.lineNumber); });
1522
+ if (resultVersion < 3) {
1523
+ // Remove fixInfo and multiple errors for the same rule and line number
1524
+ var noPrevious_1 = {
1525
+ "ruleName": null,
1526
+ "lineNumber": -1
1527
+ };
1528
+ results = results.filter(function (error, index, array) {
1529
+ delete error.fixInfo;
1530
+ var previous = array[index - 1] || noPrevious_1;
1531
+ return ((error.ruleName !== previous.ruleName) ||
1532
+ (error.lineNumber !== previous.lineNumber));
1374
1533
  });
1375
- if (filteredErrors.length > 0) {
1376
- if (resultVersion === 0) {
1377
- result[ruleNameFriendly] = filteredErrors;
1378
- }
1379
- else {
1380
- Array.prototype.push.apply(result, filteredErrors);
1381
- }
1534
+ }
1535
+ if (resultVersion === 0) {
1536
+ // Return a dictionary of rule->[line numbers]
1537
+ var dictionary = {};
1538
+ for (var _i = 0, results_1 = results; _i < results_1.length; _i++) {
1539
+ var error = results_1[_i];
1540
+ var ruleLines = dictionary[error.ruleName] || [];
1541
+ ruleLines.push(error.lineNumber);
1542
+ dictionary[error.ruleName] = ruleLines;
1543
+ }
1544
+ // @ts-ignore
1545
+ results = dictionary;
1546
+ }
1547
+ else if (resultVersion === 1) {
1548
+ // Use ruleAlias instead of ruleNames
1549
+ for (var _a = 0, results_2 = results; _a < results_2.length; _a++) {
1550
+ var error = results_2[_a];
1551
+ error.ruleAlias = error.ruleNames[1] || error.ruleName;
1552
+ delete error.ruleNames;
1553
+ }
1554
+ }
1555
+ else {
1556
+ // resultVersion 2 or 3: Remove unwanted ruleName
1557
+ for (var _b = 0, results_3 = results; _b < results_3.length; _b++) {
1558
+ var error = results_3[_b];
1559
+ delete error.ruleName;
1382
1560
  }
1383
1561
  }
1562
+ return results;
1384
1563
  }
1385
1564
  // Run all rules
1565
+ var ruleListAsync = ruleList.filter(function (rule) { return rule.asynchronous; });
1566
+ var ruleListSync = ruleList.filter(function (rule) { return !rule.asynchronous; });
1567
+ var ruleListAsyncFirst = __spreadArray(__spreadArray([], ruleListAsync, true), ruleListSync, true);
1568
+ var callbackSuccess = function () { return callback(null, formatResults()); };
1569
+ var callbackError = function (error) { return callback(error instanceof Error ? error : new Error(error)); };
1386
1570
  try {
1387
- ruleList.forEach(forRule);
1571
+ var ruleResults = ruleListAsyncFirst.map(forRule);
1572
+ if (ruleListAsync.length > 0) {
1573
+ Promise.all(ruleResults.slice(0, ruleListAsync.length))
1574
+ .then(callbackSuccess)
1575
+ .catch(callbackError);
1576
+ }
1577
+ else {
1578
+ callbackSuccess();
1579
+ }
1388
1580
  }
1389
1581
  catch (error) {
1582
+ callbackError(error);
1583
+ }
1584
+ finally {
1390
1585
  cache.clear();
1391
- return callback(error);
1392
1586
  }
1393
- cache.clear();
1394
- return callback(null, result);
1395
1587
  }
1396
1588
  /**
1397
1589
  * Lints a file containing Markdown content.
@@ -1404,11 +1596,12 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1404
1596
  * @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
1405
1597
  * @param {boolean} noInlineConfig Whether to allow inline configuration.
1406
1598
  * @param {number} resultVersion Version of the LintResults object to return.
1599
+ * @param {Object} fs File system implementation.
1407
1600
  * @param {boolean} synchronous Whether to execute synchronously.
1408
1601
  * @param {Function} callback Callback (err, result) function.
1409
1602
  * @returns {void}
1410
1603
  */
1411
- function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, callback) {
1604
+ function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, callback) {
1412
1605
  // eslint-disable-next-line jsdoc/require-jsdoc
1413
1606
  function lintContentWrapper(err, content) {
1414
1607
  if (err) {
@@ -1418,11 +1611,10 @@ function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, n
1418
1611
  }
1419
1612
  // Make a/synchronous call to read file
1420
1613
  if (synchronous) {
1421
- // @ts-ignore
1422
- lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding));
1614
+ lintContentWrapper(null, fs.readFileSync(file, "utf8"));
1423
1615
  }
1424
1616
  else {
1425
- fs.readFile(file, helpers.utf8Encoding, lintContentWrapper);
1617
+ fs.readFile(file, "utf8", lintContentWrapper);
1426
1618
  }
1427
1619
  }
1428
1620
  /**
@@ -1439,13 +1631,13 @@ function lintInput(options, synchronous, callback) {
1439
1631
  callback = callback || function noop() { };
1440
1632
  // eslint-disable-next-line unicorn/prefer-spread
1441
1633
  var ruleList = rules.concat(options.customRules || []);
1442
- var ruleErr = validateRuleList(ruleList);
1634
+ var ruleErr = validateRuleList(ruleList, synchronous);
1443
1635
  if (ruleErr) {
1444
1636
  return callback(ruleErr);
1445
1637
  }
1446
1638
  var files = [];
1447
1639
  if (Array.isArray(options.files)) {
1448
- files = options.files.slice();
1640
+ files = __spreadArray([], options.files, true);
1449
1641
  }
1450
1642
  else if (options.files) {
1451
1643
  files = [String(options.files)];
@@ -1465,67 +1657,66 @@ function lintInput(options, synchronous, callback) {
1465
1657
  // @ts-ignore
1466
1658
  md.use.apply(md, plugin);
1467
1659
  });
1660
+ var fs = options.fs || __webpack_require__(/*! fs */ "?ec0a");
1468
1661
  var results = newResults(ruleList);
1469
1662
  var done = false;
1470
- // Linting of strings is always synchronous
1471
- var syncItem = null;
1472
- // eslint-disable-next-line jsdoc/require-jsdoc
1473
- function syncCallback(err, result) {
1474
- if (err) {
1475
- done = true;
1476
- return callback(err);
1477
- }
1478
- results[syncItem] = result;
1479
- return null;
1480
- }
1481
- while (!done && (syncItem = stringsKeys.shift())) {
1482
- lintContent(ruleList, syncItem, strings[syncItem] || "", md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, syncCallback);
1483
- }
1484
- if (synchronous) {
1485
- // Lint files synchronously
1486
- while (!done && (syncItem = files.shift())) {
1487
- lintFile(ruleList, syncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, syncCallback);
1488
- }
1489
- return done || callback(null, results);
1490
- }
1491
- // Lint files asynchronously
1492
1663
  var concurrency = 0;
1493
1664
  // eslint-disable-next-line jsdoc/require-jsdoc
1494
- function lintConcurrently() {
1495
- var asyncItem = files.shift();
1665
+ function lintWorker() {
1666
+ var currentItem = null;
1667
+ // eslint-disable-next-line jsdoc/require-jsdoc
1668
+ function lintWorkerCallback(err, result) {
1669
+ concurrency--;
1670
+ if (err) {
1671
+ done = true;
1672
+ return callback(err);
1673
+ }
1674
+ results[currentItem] = result;
1675
+ if (!synchronous) {
1676
+ lintWorker();
1677
+ }
1678
+ return null;
1679
+ }
1496
1680
  if (done) {
1497
- // Nothing to do
1681
+ // Abort for error or nothing left to do
1498
1682
  }
1499
- else if (asyncItem) {
1683
+ else if (files.length > 0) {
1684
+ // Lint next file
1500
1685
  concurrency++;
1501
- lintFile(ruleList, asyncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, function (err, result) {
1502
- concurrency--;
1503
- if (err) {
1504
- done = true;
1505
- return callback(err);
1506
- }
1507
- results[asyncItem] = result;
1508
- lintConcurrently();
1509
- return null;
1510
- });
1686
+ currentItem = files.shift();
1687
+ lintFile(ruleList, currentItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, lintWorkerCallback);
1688
+ }
1689
+ else if (stringsKeys.length > 0) {
1690
+ // Lint next string
1691
+ concurrency++;
1692
+ currentItem = stringsKeys.shift();
1693
+ lintContent(ruleList, currentItem, strings[currentItem] || "", md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, lintWorkerCallback);
1511
1694
  }
1512
1695
  else if (concurrency === 0) {
1696
+ // Finish
1513
1697
  done = true;
1514
1698
  return callback(null, results);
1515
1699
  }
1516
1700
  return null;
1517
1701
  }
1518
- // Testing on a Raspberry Pi 4 Model B with an artificial 5ms file access
1519
- // delay suggests that a concurrency factor of 8 can eliminate the impact
1520
- // of that delay (i.e., total time is the same as with no delay).
1521
- lintConcurrently();
1522
- lintConcurrently();
1523
- lintConcurrently();
1524
- lintConcurrently();
1525
- lintConcurrently();
1526
- lintConcurrently();
1527
- lintConcurrently();
1528
- lintConcurrently();
1702
+ if (synchronous) {
1703
+ while (!done) {
1704
+ lintWorker();
1705
+ }
1706
+ }
1707
+ else {
1708
+ // Testing on a Raspberry Pi 4 Model B with an artificial 5ms file access
1709
+ // delay suggests that a concurrency factor of 8 can eliminate the impact
1710
+ // of that delay (i.e., total time is the same as with no delay).
1711
+ lintWorker();
1712
+ lintWorker();
1713
+ lintWorker();
1714
+ lintWorker();
1715
+ lintWorker();
1716
+ lintWorker();
1717
+ lintWorker();
1718
+ lintWorker();
1719
+ }
1529
1720
  return null;
1530
1721
  }
1531
1722
  /**
@@ -1576,19 +1767,20 @@ function parseConfiguration(name, content, parsers) {
1576
1767
  var config = null;
1577
1768
  var message = "";
1578
1769
  var errors = [];
1770
+ var index = 0;
1579
1771
  // Try each parser
1580
1772
  (parsers || [JSON.parse]).every(function (parser) {
1581
1773
  try {
1582
1774
  config = parser(content);
1583
1775
  }
1584
1776
  catch (error) {
1585
- errors.push(error.message);
1777
+ errors.push("Parser ".concat(index++, ": ").concat(error.message));
1586
1778
  }
1587
1779
  return !config;
1588
1780
  });
1589
1781
  // Message if unable to parse
1590
1782
  if (!config) {
1591
- errors.unshift("Unable to parse '" + name + "'");
1783
+ errors.unshift("Unable to parse '".concat(name, "'"));
1592
1784
  message = errors.join("; ");
1593
1785
  }
1594
1786
  return {
@@ -1602,24 +1794,51 @@ function parseConfiguration(name, content, parsers) {
1602
1794
  *
1603
1795
  * @param {string} configFile Configuration file name.
1604
1796
  * @param {string} referenceId Referenced identifier to resolve.
1797
+ * @param {Object} fs File system implementation.
1798
+ * @param {ResolveConfigExtendsCallback} [callback] Callback (err, result)
1799
+ * function.
1800
+ * @returns {void}
1801
+ */
1802
+ function resolveConfigExtends(configFile, referenceId, fs, callback) {
1803
+ var configFileDirname = path.dirname(configFile);
1804
+ var resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
1805
+ fs.access(resolvedExtendsFile, function (err) {
1806
+ if (err) {
1807
+ // Not a file, try require.resolve
1808
+ try {
1809
+ return callback(null, dynamicRequire.resolve(referenceId, { "paths": [configFileDirname] }));
1810
+ }
1811
+ catch (_a) {
1812
+ // Unable to resolve, use resolvedExtendsFile
1813
+ }
1814
+ }
1815
+ return callback(null, resolvedExtendsFile);
1816
+ });
1817
+ }
1818
+ /**
1819
+ * Resolve referenced "extends" path in a configuration file
1820
+ * using path.resolve() with require.resolve() as a fallback.
1821
+ *
1822
+ * @param {string} configFile Configuration file name.
1823
+ * @param {string} referenceId Referenced identifier to resolve.
1824
+ * @param {Object} fs File system implementation.
1605
1825
  * @returns {string} Resolved path to file.
1606
1826
  */
1607
- function resolveConfigExtends(configFile, referenceId) {
1827
+ function resolveConfigExtendsSync(configFile, referenceId, fs) {
1608
1828
  var configFileDirname = path.dirname(configFile);
1609
1829
  var resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
1610
1830
  try {
1611
- if (fs.statSync(resolvedExtendsFile).isFile()) {
1612
- return resolvedExtendsFile;
1613
- }
1831
+ fs.accessSync(resolvedExtendsFile);
1832
+ return resolvedExtendsFile;
1614
1833
  }
1615
1834
  catch (_a) {
1616
- // If not a file or fs.statSync throws, try require.resolve
1835
+ // Not a file, try require.resolve
1617
1836
  }
1618
1837
  try {
1619
- return __webpack_require__("../lib sync recursive").resolve(referenceId, { "paths": [configFileDirname] });
1838
+ return dynamicRequire.resolve(referenceId, { "paths": [configFileDirname] });
1620
1839
  }
1621
1840
  catch (_b) {
1622
- // If require.resolve throws, return resolvedExtendsFile
1841
+ // Unable to resolve, return resolvedExtendsFile
1623
1842
  }
1624
1843
  return resolvedExtendsFile;
1625
1844
  }
@@ -1629,17 +1848,27 @@ function resolveConfigExtends(configFile, referenceId) {
1629
1848
  * @param {string} file Configuration file name.
1630
1849
  * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
1631
1850
  * function(s).
1851
+ * @param {Object} [fs] File system implementation.
1632
1852
  * @param {ReadConfigCallback} [callback] Callback (err, result) function.
1633
1853
  * @returns {void}
1634
1854
  */
1635
- function readConfig(file, parsers, callback) {
1855
+ function readConfig(file, parsers, fs, callback) {
1636
1856
  if (!callback) {
1637
- // @ts-ignore
1638
- callback = parsers;
1639
- parsers = null;
1857
+ if (fs) {
1858
+ callback = fs;
1859
+ fs = null;
1860
+ }
1861
+ else {
1862
+ // @ts-ignore
1863
+ callback = parsers;
1864
+ parsers = null;
1865
+ }
1866
+ }
1867
+ if (!fs) {
1868
+ fs = __webpack_require__(/*! fs */ "?ec0a");
1640
1869
  }
1641
1870
  // Read file
1642
- fs.readFile(file, helpers.utf8Encoding, function (err, content) {
1871
+ fs.readFile(file, "utf8", function (err, content) {
1643
1872
  if (err) {
1644
1873
  return callback(err);
1645
1874
  }
@@ -1650,16 +1879,15 @@ function readConfig(file, parsers, callback) {
1650
1879
  return callback(new Error(message));
1651
1880
  }
1652
1881
  // Extend configuration
1653
- var configExtends = config["extends"];
1882
+ var configExtends = config.extends;
1654
1883
  if (configExtends) {
1655
- delete config["extends"];
1656
- var resolvedExtends = resolveConfigExtends(file, configExtends);
1657
- return readConfig(resolvedExtends, parsers, function (errr, extendsConfig) {
1884
+ delete config.extends;
1885
+ return resolveConfigExtends(file, configExtends, fs, function (_, resolvedExtends) { return readConfig(resolvedExtends, parsers, fs, function (errr, extendsConfig) {
1658
1886
  if (errr) {
1659
1887
  return callback(errr);
1660
1888
  }
1661
1889
  return callback(null, __assign(__assign({}, extendsConfig), config));
1662
- });
1890
+ }); });
1663
1891
  }
1664
1892
  return callback(null, config);
1665
1893
  });
@@ -1670,34 +1898,39 @@ var readConfigPromisify = promisify && promisify(readConfig);
1670
1898
  *
1671
1899
  * @param {string} file Configuration file name.
1672
1900
  * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1901
+ * @param {Object} [fs] File system implementation.
1673
1902
  * @returns {Promise<Configuration>} Configuration object.
1674
1903
  */
1675
- function readConfigPromise(file, parsers) {
1904
+ function readConfigPromise(file, parsers, fs) {
1676
1905
  // @ts-ignore
1677
- return readConfigPromisify(file, parsers);
1906
+ return readConfigPromisify(file, parsers, fs);
1678
1907
  }
1679
1908
  /**
1680
1909
  * Read specified configuration file synchronously.
1681
1910
  *
1682
1911
  * @param {string} file Configuration file name.
1683
1912
  * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1913
+ * @param {Object} [fs] File system implementation.
1684
1914
  * @returns {Configuration} Configuration object.
1915
+ * @throws An Error if processing fails.
1685
1916
  */
1686
- function readConfigSync(file, parsers) {
1917
+ function readConfigSync(file, parsers, fs) {
1918
+ if (!fs) {
1919
+ fs = __webpack_require__(/*! fs */ "?ec0a");
1920
+ }
1687
1921
  // Read file
1688
- // @ts-ignore
1689
- var content = fs.readFileSync(file, helpers.utf8Encoding);
1922
+ var content = fs.readFileSync(file, "utf8");
1690
1923
  // Try to parse file
1691
1924
  var _a = parseConfiguration(file, content, parsers), config = _a.config, message = _a.message;
1692
1925
  if (!config) {
1693
1926
  throw new Error(message);
1694
1927
  }
1695
1928
  // Extend configuration
1696
- var configExtends = config["extends"];
1929
+ var configExtends = config.extends;
1697
1930
  if (configExtends) {
1698
- delete config["extends"];
1699
- var resolvedExtends = resolveConfigExtends(file, configExtends);
1700
- return __assign(__assign({}, readConfigSync(resolvedExtends, parsers)), config);
1931
+ delete config.extends;
1932
+ var resolvedExtends = resolveConfigExtendsSync(file, configExtends, fs);
1933
+ return __assign(__assign({}, readConfigSync(resolvedExtends, parsers, fs)), config);
1701
1934
  }
1702
1935
  return config;
1703
1936
  }
@@ -1707,7 +1940,7 @@ function readConfigSync(file, parsers) {
1707
1940
  * @returns {string} SemVer string.
1708
1941
  */
1709
1942
  function getVersion() {
1710
- return __webpack_require__(/*! ../package.json */ "../package.json").version;
1943
+ return (__webpack_require__(/*! ./constants */ "../lib/constants.js").version);
1711
1944
  }
1712
1945
  // Export a/synchronous/Promise APIs
1713
1946
  markdownlint.sync = markdownlintSync;
@@ -1761,7 +1994,7 @@ module.exports = {
1761
1994
  "use strict";
1762
1995
  // @ts-check
1763
1996
 
1764
- var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
1997
+ var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
1765
1998
  module.exports = {
1766
1999
  "names": ["MD002", "first-heading-h1", "first-header-h1"],
1767
2000
  "description": "First heading should be a top-level heading",
@@ -1839,7 +2072,7 @@ module.exports = {
1839
2072
  // @ts-check
1840
2073
 
1841
2074
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, unorderedListStyleFor = _a.unorderedListStyleFor;
1842
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
2075
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
1843
2076
  var expectedStyleToMarker = {
1844
2077
  "dash": "-",
1845
2078
  "plus": "+",
@@ -1884,8 +2117,8 @@ module.exports = {
1884
2117
  var match = item.line.match(listItemMarkerRe);
1885
2118
  if (match) {
1886
2119
  var column = match.index + 1;
1887
- var length_1 = match[0].length;
1888
- range = [column, length_1];
2120
+ var length = match[0].length;
2121
+ range = [column, length];
1889
2122
  fixInfo = {
1890
2123
  "editColumn": match[1].length + 1,
1891
2124
  "deleteCount": 1,
@@ -1912,7 +2145,7 @@ module.exports = {
1912
2145
  // @ts-check
1913
2146
 
1914
2147
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, addErrorDetailIf = _a.addErrorDetailIf, indentFor = _a.indentFor, listItemMarkerRe = _a.listItemMarkerRe, orderedListItemMarkerRe = _a.orderedListItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
1915
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
2148
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
1916
2149
  module.exports = {
1917
2150
  "names": ["MD005", "list-indent"],
1918
2151
  "description": "Inconsistent indentation for list items at the same level",
@@ -1942,8 +2175,8 @@ module.exports = {
1942
2175
  }
1943
2176
  else {
1944
2177
  var detail = endMatching ?
1945
- "Expected: (" + expectedEnd + "); Actual: (" + actualEnd + ")" :
1946
- "Expected: " + expectedIndent + "; Actual: " + actualIndent;
2178
+ "Expected: (".concat(expectedEnd, "); Actual: (").concat(actualEnd, ")") :
2179
+ "Expected: ".concat(expectedIndent, "; Actual: ").concat(actualIndent);
1947
2180
  var expected = endMatching ?
1948
2181
  expectedEnd - markerLength :
1949
2182
  expectedIndent;
@@ -1976,7 +2209,7 @@ module.exports = {
1976
2209
  // @ts-check
1977
2210
 
1978
2211
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
1979
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
2212
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
1980
2213
  module.exports = {
1981
2214
  "names": ["MD006", "ul-start-left"],
1982
2215
  "description": "Consider starting bulleted lists at the beginning of the line",
@@ -2008,7 +2241,7 @@ module.exports = {
2008
2241
  // @ts-check
2009
2242
 
2010
2243
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, indentFor = _a.indentFor, listItemMarkerRe = _a.listItemMarkerRe;
2011
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
2244
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
2012
2245
  module.exports = {
2013
2246
  "names": ["MD007", "ul-indent"],
2014
2247
  "description": "Unordered list indentation",
@@ -2016,12 +2249,13 @@ module.exports = {
2016
2249
  "function": function MD007(params, onError) {
2017
2250
  var indent = Number(params.config.indent || 2);
2018
2251
  var startIndented = !!params.config.start_indented;
2252
+ var startIndent = Number(params.config.start_indent || indent);
2019
2253
  flattenedLists().forEach(function (list) {
2020
2254
  if (list.unordered && list.parentsUnordered) {
2021
2255
  list.items.forEach(function (item) {
2022
2256
  var lineNumber = item.lineNumber, line = item.line;
2023
- var expectedNesting = list.nesting + (startIndented ? 1 : 0);
2024
- var expectedIndent = expectedNesting * indent;
2257
+ var expectedIndent = (startIndented ? startIndent : 0) +
2258
+ (list.nesting * indent);
2025
2259
  var actualIndent = indentFor(item);
2026
2260
  var range = null;
2027
2261
  var editColumn = 1;
@@ -2054,7 +2288,7 @@ module.exports = {
2054
2288
  // @ts-check
2055
2289
 
2056
2290
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, filterTokens = _a.filterTokens, forEachInlineCodeSpan = _a.forEachInlineCodeSpan, forEachLine = _a.forEachLine, includesSorted = _a.includesSorted, newLineRe = _a.newLineRe, numericSortAscending = _a.numericSortAscending;
2057
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2291
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2058
2292
  module.exports = {
2059
2293
  "names": ["MD009", "no-trailing-spaces"],
2060
2294
  "description": "Trailing spaces",
@@ -2129,8 +2363,8 @@ module.exports = {
2129
2363
  "use strict";
2130
2364
  // @ts-check
2131
2365
 
2132
- var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine;
2133
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2366
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
2367
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
2134
2368
  var tabRe = /\t+/g;
2135
2369
  module.exports = {
2136
2370
  "names": ["MD010", "no-hard-tabs"],
@@ -2138,18 +2372,26 @@ module.exports = {
2138
2372
  "tags": ["whitespace", "hard_tab"],
2139
2373
  "function": function MD010(params, onError) {
2140
2374
  var codeBlocks = params.config.code_blocks;
2141
- var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
2375
+ var includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
2376
+ var spacesPerTab = params.config.spaces_per_tab;
2377
+ var spaceMultiplier = (spacesPerTab === undefined) ?
2378
+ 1 :
2379
+ Math.max(0, Number(spacesPerTab));
2380
+ var exclusions = includeCode ? [] : codeBlockAndSpanRanges();
2142
2381
  forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
2143
- if (!inCode || includeCodeBlocks) {
2382
+ if (includeCode || !inCode) {
2144
2383
  var match = null;
2145
2384
  while ((match = tabRe.exec(line)) !== null) {
2146
- var column = match.index + 1;
2147
- var length_1 = match[0].length;
2148
- addError(onError, lineIndex + 1, "Column: " + column, null, [column, length_1], {
2149
- "editColumn": column,
2150
- "deleteCount": length_1,
2151
- "insertText": "".padEnd(length_1)
2152
- });
2385
+ var index = match.index;
2386
+ var column = index + 1;
2387
+ var length = match[0].length;
2388
+ if (!overlapsAnyRange(exclusions, lineIndex, index, length)) {
2389
+ addError(onError, lineIndex + 1, "Column: " + column, null, [column, length], {
2390
+ "editColumn": column,
2391
+ "deleteCount": length,
2392
+ "insertText": "".padEnd(length * spaceMultiplier)
2393
+ });
2394
+ }
2153
2395
  }
2154
2396
  }
2155
2397
  });
@@ -2168,30 +2410,32 @@ module.exports = {
2168
2410
  "use strict";
2169
2411
  // @ts-check
2170
2412
 
2171
- var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachInlineChild = _a.forEachInlineChild, unescapeMarkdown = _a.unescapeMarkdown;
2172
- var reversedLinkRe = /\(([^)]+)\)\[([^\]^][^\]]*)]/g;
2413
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
2414
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
2415
+ var reversedLinkRe = /(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
2173
2416
  module.exports = {
2174
2417
  "names": ["MD011", "no-reversed-links"],
2175
2418
  "description": "Reversed link syntax",
2176
2419
  "tags": ["links"],
2177
2420
  "function": function MD011(params, onError) {
2178
- forEachInlineChild(params, "text", function (token) {
2179
- var lineNumber = token.lineNumber, content = token.content;
2180
- var match = null;
2181
- while ((match = reversedLinkRe.exec(content)) !== null) {
2182
- var reversedLink = match[0], linkText = match[1], linkDestination = match[2];
2183
- var line = params.lines[lineNumber - 1];
2184
- var column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
2185
- var length_1 = reversedLink.length;
2186
- var range = column ? [column, length_1] : null;
2187
- var fixInfo = column ?
2188
- {
2189
- "editColumn": column,
2190
- "deleteCount": length_1,
2191
- "insertText": "[" + linkText + "](" + linkDestination + ")"
2192
- } :
2193
- null;
2194
- addError(onError, lineNumber, reversedLink, null, range, fixInfo);
2421
+ var exclusions = codeBlockAndSpanRanges();
2422
+ forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
2423
+ if (!inCode && !onFence) {
2424
+ var match = null;
2425
+ while ((match = reversedLinkRe.exec(line)) !== null) {
2426
+ var reversedLink = match[0], preChar = match[1], linkText = match[2], linkDestination = match[3];
2427
+ var index = match.index + preChar.length;
2428
+ var length = match[0].length - preChar.length;
2429
+ if (!linkText.endsWith("\\") &&
2430
+ !linkDestination.endsWith("\\") &&
2431
+ !overlapsAnyRange(exclusions, lineIndex, index, length)) {
2432
+ addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), null, [index + 1, length], {
2433
+ "editColumn": index + 1,
2434
+ "deleteCount": length,
2435
+ "insertText": "[".concat(linkText, "](").concat(linkDestination, ")")
2436
+ });
2437
+ }
2438
+ }
2195
2439
  }
2196
2440
  });
2197
2441
  }
@@ -2210,7 +2454,7 @@ module.exports = {
2210
2454
  // @ts-check
2211
2455
 
2212
2456
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, forEachLine = _a.forEachLine;
2213
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2457
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2214
2458
  module.exports = {
2215
2459
  "names": ["MD012", "no-multiple-blanks"],
2216
2460
  "description": "Multiple consecutive blank lines",
@@ -2242,7 +2486,7 @@ module.exports = {
2242
2486
  // @ts-check
2243
2487
 
2244
2488
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, filterTokens = _a.filterTokens, forEachHeading = _a.forEachHeading, forEachLine = _a.forEachLine, includesSorted = _a.includesSorted;
2245
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2489
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2246
2490
  var longLineRePrefix = "^.{";
2247
2491
  var longLineRePostfixRelaxed = "}.*\\s.*$";
2248
2492
  var longLineRePostfixStrict = "}.+$";
@@ -2352,8 +2596,8 @@ module.exports = {
2352
2596
  var match = dollarCommandRe.exec(line);
2353
2597
  if (match) {
2354
2598
  var column = match[1].length + 1;
2355
- var length_1 = match[2].length;
2356
- dollarInstances.push([i, lineTrim, column, length_1]);
2599
+ var length = match[2].length;
2600
+ dollarInstances.push([i, lineTrim, column, length]);
2357
2601
  }
2358
2602
  else {
2359
2603
  allDollars = false;
@@ -2387,7 +2631,7 @@ module.exports = {
2387
2631
  // @ts-check
2388
2632
 
2389
2633
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine;
2390
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2634
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2391
2635
  module.exports = {
2392
2636
  "names": ["MD018", "no-missing-space-atx"],
2393
2637
  "description": "No space after hash on atx style heading",
@@ -2455,7 +2699,7 @@ module.exports = {
2455
2699
  // @ts-check
2456
2700
 
2457
2701
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine;
2458
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
2702
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2459
2703
  module.exports = {
2460
2704
  "names": ["MD020", "no-missing-space-closed-atx"],
2461
2705
  "description": "No space inside hashes on closed atx style heading",
@@ -2470,7 +2714,7 @@ module.exports = {
2470
2714
  var rightHashLength = rightHash.length;
2471
2715
  var left = !leftSpaceLength;
2472
2716
  var right = !rightSpaceLength || rightEscape;
2473
- var rightEscapeReplacement = rightEscape ? rightEscape + " " : "";
2717
+ var rightEscapeReplacement = rightEscape ? "".concat(rightEscape, " ") : "";
2474
2718
  if (left || right) {
2475
2719
  var range = left ?
2476
2720
  [
@@ -2484,7 +2728,7 @@ module.exports = {
2484
2728
  addErrorContext(onError, lineIndex + 1, line.trim(), left, right, range, {
2485
2729
  "editColumn": 1,
2486
2730
  "deleteCount": line.length,
2487
- "insertText": leftHash + " " + content + " " + rightEscapeReplacement + rightHash
2731
+ "insertText": "".concat(leftHash, " ").concat(content, " ").concat(rightEscapeReplacement).concat(rightHash)
2488
2732
  });
2489
2733
  }
2490
2734
  }
@@ -2520,7 +2764,7 @@ module.exports = {
2520
2764
  var left = leftSpaceLength > 1;
2521
2765
  var right = rightSpaceLength > 1;
2522
2766
  if (left || right) {
2523
- var length_1 = line.length;
2767
+ var length = line.length;
2524
2768
  var leftHashLength = leftHash.length;
2525
2769
  var rightHashLength = rightHash.length;
2526
2770
  var range = left ?
@@ -2529,13 +2773,13 @@ module.exports = {
2529
2773
  leftHashLength + leftSpaceLength + 1
2530
2774
  ] :
2531
2775
  [
2532
- length_1 - trailSpaceLength - rightHashLength - rightSpaceLength,
2776
+ length - trailSpaceLength - rightHashLength - rightSpaceLength,
2533
2777
  rightSpaceLength + rightHashLength + 1
2534
2778
  ];
2535
2779
  addErrorContext(onError, lineNumber, line.trim(), left, right, range, {
2536
2780
  "editColumn": 1,
2537
- "deleteCount": length_1,
2538
- "insertText": leftHash + " " + content + " " + rightHash
2781
+ "deleteCount": length,
2782
+ "insertText": "".concat(leftHash, " ").concat(content, " ").concat(rightHash)
2539
2783
  });
2540
2784
  }
2541
2785
  }
@@ -2740,10 +2984,10 @@ module.exports = {
2740
2984
  if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) {
2741
2985
  var fullMatch = match[0];
2742
2986
  var column = match.index + 1;
2743
- var length_1 = fullMatch.length;
2744
- addError(onError, lineNumber, "Punctuation: '" + fullMatch + "'", null, [column, length_1], {
2987
+ var length = fullMatch.length;
2988
+ addError(onError, lineNumber, "Punctuation: '".concat(fullMatch, "'"), null, [column, length], {
2745
2989
  "editColumn": column,
2746
- "deleteCount": length_1
2990
+ "deleteCount": length
2747
2991
  });
2748
2992
  }
2749
2993
  });
@@ -2817,7 +3061,7 @@ module.exports = {
2817
3061
  "use strict";
2818
3062
  // @ts-check
2819
3063
 
2820
- var addError = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addError;
3064
+ var addError = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addError);
2821
3065
  module.exports = {
2822
3066
  "names": ["MD028", "no-blanks-blockquote"],
2823
3067
  "description": "Blank line inside blockquote",
@@ -2853,7 +3097,7 @@ module.exports = {
2853
3097
  // @ts-check
2854
3098
 
2855
3099
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, listItemMarkerRe = _a.listItemMarkerRe, orderedListItemMarkerRe = _a.orderedListItemMarkerRe, rangeFromRegExp = _a.rangeFromRegExp;
2856
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
3100
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
2857
3101
  var listStyleExamples = {
2858
3102
  "one": "1/1/1",
2859
3103
  "ordered": "1/2/3",
@@ -2922,8 +3166,8 @@ module.exports = {
2922
3166
  "use strict";
2923
3167
  // @ts-check
2924
3168
 
2925
- var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
2926
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
3169
+ var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
3170
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
2927
3171
  module.exports = {
2928
3172
  "names": ["MD030", "list-marker-space"],
2929
3173
  "description": "Spaces after list markers",
@@ -2972,7 +3216,7 @@ module.exports = {
2972
3216
  // @ts-check
2973
3217
 
2974
3218
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, forEachLine = _a.forEachLine, isBlankLine = _a.isBlankLine;
2975
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
3219
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
2976
3220
  var codeFencePrefixRe = /^(.*?)\s*[`~]/;
2977
3221
  module.exports = {
2978
3222
  "names": ["MD031", "blanks-around-fences"],
@@ -2991,7 +3235,7 @@ module.exports = {
2991
3235
  var _a = line.match(codeFencePrefixRe) || [], prefix = _a[1];
2992
3236
  var fixInfo = (prefix === undefined) ? null : {
2993
3237
  "lineNumber": i + (onTopFence ? 1 : 2),
2994
- "insertText": prefix + "\n"
3238
+ "insertText": "".concat(prefix, "\n")
2995
3239
  };
2996
3240
  addErrorContext(onError, i + 1, lines[i].trim(), null, null, null, fixInfo);
2997
3241
  }
@@ -3012,7 +3256,7 @@ module.exports = {
3012
3256
  // @ts-check
3013
3257
 
3014
3258
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, isBlankLine = _a.isBlankLine;
3015
- var flattenedLists = __webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists;
3259
+ var flattenedLists = (__webpack_require__(/*! ./cache */ "../lib/cache.js").flattenedLists);
3016
3260
  var quotePrefixRe = /^[>\s]*/;
3017
3261
  module.exports = {
3018
3262
  "names": ["MD032", "blanks-around-lists"],
@@ -3026,7 +3270,7 @@ module.exports = {
3026
3270
  var line = lines[firstIndex];
3027
3271
  var quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
3028
3272
  addErrorContext(onError, firstIndex + 1, line.trim(), null, null, null, {
3029
- "insertText": quotePrefix + "\n"
3273
+ "insertText": "".concat(quotePrefix, "\n")
3030
3274
  });
3031
3275
  }
3032
3276
  var lastIndex = list.lastLineIndex - 1;
@@ -3035,7 +3279,7 @@ module.exports = {
3035
3279
  var quotePrefix = line.match(quotePrefixRe)[0].trimEnd();
3036
3280
  addErrorContext(onError, lastIndex + 1, line.trim(), null, null, null, {
3037
3281
  "lineNumber": lastIndex + 2,
3038
- "insertText": quotePrefix + "\n"
3282
+ "insertText": "".concat(quotePrefix, "\n")
3039
3283
  });
3040
3284
  }
3041
3285
  });
@@ -3054,11 +3298,10 @@ module.exports = {
3054
3298
  "use strict";
3055
3299
  // @ts-check
3056
3300
 
3057
- var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, unescapeMarkdown = _a.unescapeMarkdown;
3058
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
3301
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange, unescapeMarkdown = _a.unescapeMarkdown;
3302
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
3059
3303
  var htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g;
3060
3304
  var linkDestinationRe = /]\(\s*$/;
3061
- var inlineCodeRe = /^[^`]*(`+[^`]+`+[^`]+)*`+[^`]*$/;
3062
3305
  // See https://spec.commonmark.org/0.29/#autolinks
3063
3306
  var emailAddressRe =
3064
3307
  // eslint-disable-next-line max-len
@@ -3071,6 +3314,7 @@ module.exports = {
3071
3314
  var allowedElements = params.config.allowed_elements;
3072
3315
  allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
3073
3316
  allowedElements = allowedElements.map(function (element) { return element.toLowerCase(); });
3317
+ var exclusions = codeBlockAndSpanRanges();
3074
3318
  forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
3075
3319
  var match = null;
3076
3320
  // eslint-disable-next-line no-unmodified-loop-condition
@@ -3078,12 +3322,12 @@ module.exports = {
3078
3322
  var tag = match[0], content = match[1], element = match[2];
3079
3323
  if (!allowedElements.includes(element.toLowerCase()) &&
3080
3324
  !tag.endsWith("\\>") &&
3081
- !emailAddressRe.test(content)) {
3325
+ !emailAddressRe.test(content) &&
3326
+ !overlapsAnyRange(exclusions, lineIndex, match.index, match[0].length)) {
3082
3327
  var prefix = line.substring(0, match.index);
3083
- if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix)) {
3328
+ if (!linkDestinationRe.test(prefix)) {
3084
3329
  var unescaped = unescapeMarkdown(prefix + "<", "_");
3085
- if (!unescaped.endsWith("_") &&
3086
- ((unescaped + "`").match(/`/g).length % 2)) {
3330
+ if (!unescaped.endsWith("_")) {
3087
3331
  addError(onError, lineIndex + 1, "Element: " + element, null, [match.index + 1, tag.length]);
3088
3332
  }
3089
3333
  }
@@ -3143,7 +3387,7 @@ module.exports = {
3143
3387
  var fixInfo = range ? {
3144
3388
  "editColumn": range[0],
3145
3389
  "deleteCount": range[1],
3146
- "insertText": "<" + bareUrl + ">"
3390
+ "insertText": "<".concat(bareUrl, ">")
3147
3391
  } : null;
3148
3392
  addErrorContext(onError, lineNumber, bareUrl, null, null, range, fixInfo);
3149
3393
  }
@@ -3173,12 +3417,12 @@ module.exports = {
3173
3417
  "tags": ["hr"],
3174
3418
  "function": function MD035(params, onError) {
3175
3419
  var style = String(params.config.style || "consistent");
3176
- filterTokens(params, "hr", function forToken(token) {
3177
- var lineTrim = token.line.trim();
3420
+ filterTokens(params, "hr", function (token) {
3421
+ var lineNumber = token.lineNumber, markup = token.markup;
3178
3422
  if (style === "consistent") {
3179
- style = lineTrim;
3423
+ style = markup;
3180
3424
  }
3181
- addErrorDetailIf(onError, token.lineNumber, style, lineTrim);
3425
+ addErrorDetailIf(onError, lineNumber, style, markup);
3182
3426
  });
3183
3427
  }
3184
3428
  };
@@ -3261,8 +3505,9 @@ module.exports = {
3261
3505
  // @ts-check
3262
3506
 
3263
3507
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, emphasisMarkersInContent = _a.emphasisMarkersInContent, forEachLine = _a.forEachLine, isBlankLine = _a.isBlankLine;
3264
- var lineMetadata = __webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata;
3508
+ var lineMetadata = (__webpack_require__(/*! ./cache */ "../lib/cache.js").lineMetadata);
3265
3509
  var emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;
3510
+ var embeddedUnderscoreRe = /([A-Za-z0-9])_([A-Za-z0-9])/g;
3266
3511
  var asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
3267
3512
  var leftSpaceRe = /^\s+/;
3268
3513
  var rightSpaceRe = /\s+$/;
@@ -3301,20 +3546,20 @@ module.exports = {
3301
3546
  var contextEnd = matchIndex + contextLength;
3302
3547
  var context = line.substring(contextStart, contextEnd);
3303
3548
  var column = contextStart + 1;
3304
- var length_1 = contextEnd - contextStart;
3549
+ var length = contextEnd - contextStart;
3305
3550
  var leftMarker = line.substring(contextStart, emphasisIndex);
3306
3551
  var rightMarker = match ? (match[2] || match[3]) : "";
3307
- var fixedText = "" + leftMarker + content.trim() + rightMarker;
3552
+ var fixedText = "".concat(leftMarker).concat(content.trim()).concat(rightMarker);
3308
3553
  return [
3309
3554
  onError,
3310
3555
  lineIndex + 1,
3311
3556
  context,
3312
3557
  leftSpace,
3313
3558
  rightSpace,
3314
- [column, length_1],
3559
+ [column, length],
3315
3560
  {
3316
3561
  "editColumn": column,
3317
- "deleteCount": length_1,
3562
+ "deleteCount": length,
3318
3563
  "insertText": fixedText
3319
3564
  }
3320
3565
  ];
@@ -3326,22 +3571,31 @@ module.exports = {
3326
3571
  resetRunTracking();
3327
3572
  forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence, inTable, inItem, onBreak, inMath) {
3328
3573
  var onItemStart = (inItem === 1);
3329
- if (inCode || inTable || onBreak || onItemStart || isBlankLine(line)) {
3574
+ if (inCode ||
3575
+ onFence ||
3576
+ inTable ||
3577
+ onBreak ||
3578
+ onItemStart ||
3579
+ isBlankLine(line)) {
3330
3580
  // Emphasis resets when leaving a block
3331
3581
  resetRunTracking();
3332
3582
  }
3333
- if (inCode || onBreak || inMath) {
3583
+ if (inCode ||
3584
+ onFence ||
3585
+ onBreak ||
3586
+ inMath) {
3334
3587
  // Emphasis has no meaning here
3335
3588
  return;
3336
3589
  }
3590
+ var patchedLine = line.replace(embeddedUnderscoreRe, "$1 $2");
3337
3591
  if (onItemStart) {
3338
3592
  // Trim overlapping '*' list item marker
3339
- line = line.replace(asteriskListItemMarkerRe, "$1 $2");
3593
+ patchedLine = patchedLine.replace(asteriskListItemMarkerRe, "$1 $2");
3340
3594
  }
3341
3595
  var match = null;
3342
3596
  // Match all emphasis-looking runs in the line...
3343
- while ((match = emphasisRe.exec(line))) {
3344
- var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex] || [];
3597
+ while ((match = emphasisRe.exec(patchedLine))) {
3598
+ var ignoreMarkersForLine = ignoreMarkersByLine[lineIndex];
3345
3599
  var matchIndex = match.index + match[1].length;
3346
3600
  if (ignoreMarkersForLine.includes(matchIndex)) {
3347
3601
  // Ignore emphasis markers inside code spans and links
@@ -3484,7 +3738,7 @@ module.exports = {
3484
3738
  // @ts-check
3485
3739
 
3486
3740
  var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens;
3487
- var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
3741
+ var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=((?:\([^)]*\))|(?:\[[^\]]*\])))/;
3488
3742
  module.exports = {
3489
3743
  "names": ["MD039", "no-space-in-links"],
3490
3744
  "description": "Spaces inside link text",
@@ -3513,16 +3767,16 @@ module.exports = {
3513
3767
  var match = line.slice(lineIndex).match(spaceInLinkRe);
3514
3768
  if (match) {
3515
3769
  var column = match.index + lineIndex + 1;
3516
- var length_1 = match[0].length;
3517
- range = [column, length_1];
3770
+ var length = match[0].length;
3771
+ range = [column, length];
3518
3772
  fixInfo = {
3519
3773
  "editColumn": column + 1,
3520
- "deleteCount": length_1 - 2,
3774
+ "deleteCount": length - 2,
3521
3775
  "insertText": linkText.trim()
3522
3776
  };
3523
- lineIndex = column + length_1 - 1;
3777
+ lineIndex = column + length - 1;
3524
3778
  }
3525
- addErrorContext(onError, lineNumber, "[" + linkText + "]", left, right, range, fixInfo);
3779
+ addErrorContext(onError, lineNumber, "[".concat(linkText, "]"), left, right, range, fixInfo);
3526
3780
  }
3527
3781
  }
3528
3782
  else if ((type === "softbreak") || (type === "hardbreak")) {
@@ -3585,7 +3839,7 @@ module.exports = {
3585
3839
  var tag = "h" + level;
3586
3840
  var foundFrontMatterTitle = frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title);
3587
3841
  if (!foundFrontMatterTitle) {
3588
- var htmlHeadingRe_1 = new RegExp("^<h" + level + "[ />]", "i");
3842
+ var htmlHeadingRe_1 = new RegExp("^<h".concat(level, "[ />]"), "i");
3589
3843
  params.tokens.every(function (token) {
3590
3844
  var isError = false;
3591
3845
  if (token.type === "html_block") {
@@ -3687,7 +3941,6 @@ module.exports = {
3687
3941
  var matchAny_1 = false;
3688
3942
  var hasError_1 = false;
3689
3943
  var anyHeadings_1 = false;
3690
- // eslint-disable-next-line func-style
3691
3944
  var getExpected_1 = function () { return requiredHeadings[i_1++] || "[None]"; };
3692
3945
  forEachHeading(params, function (heading, content) {
3693
3946
  if (!hasError_1) {
@@ -3695,8 +3948,11 @@ module.exports = {
3695
3948
  var actual = levels_1[heading.tag] + " " + content;
3696
3949
  var expected = getExpected_1();
3697
3950
  if (expected === "*") {
3698
- matchAny_1 = true;
3699
- getExpected_1();
3951
+ var nextExpected = getExpected_1();
3952
+ if (nextExpected.toLowerCase() !== actual.toLowerCase()) {
3953
+ matchAny_1 = true;
3954
+ i_1--;
3955
+ }
3700
3956
  }
3701
3957
  else if (expected === "+") {
3702
3958
  matchAny_1 = true;
@@ -3713,8 +3969,10 @@ module.exports = {
3713
3969
  }
3714
3970
  }
3715
3971
  });
3972
+ var extraHeadings = requiredHeadings.length - i_1;
3716
3973
  if (!hasError_1 &&
3717
- (i_1 < requiredHeadings.length) &&
3974
+ ((extraHeadings > 1) ||
3975
+ ((extraHeadings === 1) && (requiredHeadings[i_1] !== "*"))) &&
3718
3976
  (anyHeadings_1 || !requiredHeadings.every(function (heading) { return heading === "*"; }))) {
3719
3977
  addErrorContext(onError, params.lines.length, requiredHeadings[i_1]);
3720
3978
  }
@@ -3734,9 +3992,8 @@ module.exports = {
3734
3992
  "use strict";
3735
3993
  // @ts-check
3736
3994
 
3737
- var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, bareUrlRe = _a.bareUrlRe, escapeForRegExp = _a.escapeForRegExp, filterTokens = _a.filterTokens, forEachInlineChild = _a.forEachInlineChild, newLineRe = _a.newLineRe;
3738
- var startNonWordRe = /^\W/;
3739
- var endNonWordRe = /\W$/;
3995
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorDetailIf = _a.addErrorDetailIf, bareUrlRe = _a.bareUrlRe, escapeForRegExp = _a.escapeForRegExp, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange, linkRe = _a.linkRe, linkReferenceRe = _a.linkReferenceRe;
3996
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
3740
3997
  module.exports = {
3741
3998
  "names": ["MD044", "proper-names"],
3742
3999
  "description": "Proper names should have the correct capitalization",
@@ -3744,73 +4001,59 @@ module.exports = {
3744
4001
  "function": function MD044(params, onError) {
3745
4002
  var names = params.config.names;
3746
4003
  names = Array.isArray(names) ? names : [];
4004
+ names.sort(function (a, b) { return (b.length - a.length) || a.localeCompare(b); });
3747
4005
  var codeBlocks = params.config.code_blocks;
3748
4006
  var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
3749
- // Text of automatic hyperlinks is implicitly a URL
3750
- var autolinkText = new Set();
3751
- filterTokens(params, "inline", function (token) {
3752
- var inAutoLink = false;
3753
- token.children.forEach(function (child) {
3754
- var info = child.info, type = child.type;
3755
- if ((type === "link_open") && (info === "auto")) {
3756
- inAutoLink = true;
3757
- }
3758
- else if (type === "link_close") {
3759
- inAutoLink = false;
4007
+ var exclusions = [];
4008
+ forEachLine(lineMetadata(), function (line, lineIndex) {
4009
+ if (linkReferenceRe.test(line)) {
4010
+ exclusions.push([lineIndex, 0, line.length]);
4011
+ }
4012
+ else {
4013
+ var match = null;
4014
+ while ((match = bareUrlRe.exec(line)) !== null) {
4015
+ exclusions.push([lineIndex, match.index, match[0].length]);
3760
4016
  }
3761
- else if ((type === "text") && inAutoLink) {
3762
- autolinkText.add(child);
4017
+ while ((match = linkRe.exec(line)) !== null) {
4018
+ var text = match[1], destination = match[2];
4019
+ if (destination) {
4020
+ exclusions.push([lineIndex, match.index + text.length, destination.length]);
4021
+ }
3763
4022
  }
3764
- });
4023
+ }
3765
4024
  });
3766
- // For each proper name...
3767
- names.forEach(function (name) {
4025
+ if (!includeCodeBlocks) {
4026
+ exclusions.push.apply(exclusions, codeBlockAndSpanRanges());
4027
+ }
4028
+ var _loop_1 = function (name) {
3768
4029
  var escapedName = escapeForRegExp(name);
3769
- var startNamePattern = startNonWordRe.test(name) ? "" : "\\S*\\b";
3770
- var endNamePattern = endNonWordRe.test(name) ? "" : "\\b\\S*";
3771
- var namePattern = "(" + startNamePattern + ")(" + escapedName + ")(" + endNamePattern + ")";
3772
- var anyNameRe = new RegExp(namePattern, "gi");
3773
- // eslint-disable-next-line jsdoc/require-jsdoc
3774
- function forToken(token) {
3775
- if (!autolinkText.has(token)) {
3776
- var fenceOffset_1 = (token.type === "fence") ? 1 : 0;
3777
- token.content.split(newLineRe).forEach(function (line, index) {
3778
- var match = null;
3779
- while ((match = anyNameRe.exec(line)) !== null) {
3780
- var fullMatch = match[0], leftMatch = match[1], nameMatch = match[2], rightMatch = match[3];
3781
- if (fullMatch.search(bareUrlRe) === -1) {
3782
- var wordMatch = fullMatch
3783
- .replace(new RegExp("^\\W{0," + leftMatch.length + "}"), "")
3784
- .replace(new RegExp("\\W{0," + rightMatch.length + "}$"), "");
3785
- if (!names.includes(wordMatch)) {
3786
- var lineNumber = token.lineNumber + index + fenceOffset_1;
3787
- var fullLine = params.lines[lineNumber - 1];
3788
- var matchLength = wordMatch.length;
3789
- var matchIndex = fullLine.indexOf(wordMatch);
3790
- var range = (matchIndex === -1) ?
3791
- null :
3792
- [matchIndex + 1, matchLength];
3793
- var fixInfo = (matchIndex === -1) ?
3794
- null :
3795
- {
3796
- "editColumn": matchIndex + 1,
3797
- "deleteCount": matchLength,
3798
- "insertText": name
3799
- };
3800
- addErrorDetailIf(onError, lineNumber, name, nameMatch, null, null, range, fixInfo);
3801
- }
3802
- }
4030
+ var startNamePattern = /^\W/.test(name) ? "" : "\\b_*";
4031
+ var endNamePattern = /\W$/.test(name) ? "" : "_*\\b";
4032
+ var namePattern = "(".concat(startNamePattern, ")(").concat(escapedName, ")").concat(endNamePattern);
4033
+ var nameRe = new RegExp(namePattern, "gi");
4034
+ forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
4035
+ if (includeCodeBlocks || (!inCode && !onFence)) {
4036
+ var match = null;
4037
+ while ((match = nameRe.exec(line)) !== null) {
4038
+ var leftMatch = match[1], nameMatch = match[2];
4039
+ var index = match.index + leftMatch.length;
4040
+ var length = nameMatch.length;
4041
+ if (!overlapsAnyRange(exclusions, lineIndex, index, length)) {
4042
+ addErrorDetailIf(onError, lineIndex + 1, name, nameMatch, null, null, [index + 1, length], {
4043
+ "editColumn": index + 1,
4044
+ "deleteCount": length,
4045
+ "insertText": name
4046
+ });
3803
4047
  }
3804
- });
4048
+ exclusions.push([lineIndex, index, length]);
4049
+ }
3805
4050
  }
3806
- }
3807
- forEachInlineChild(params, "text", forToken);
3808
- if (includeCodeBlocks) {
3809
- forEachInlineChild(params, "code_inline", forToken);
3810
- filterTokens(params, "code_block", forToken);
3811
- filterTokens(params, "fence", forToken);
3812
- }
3813
- });
4051
+ });
4052
+ };
4053
+ for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
4054
+ var name = names_1[_i];
4055
+ _loop_1(name);
4056
+ }
3814
4057
  }
3815
4058
  };
3816
4059
 
@@ -3852,7 +4095,7 @@ module.exports = {
3852
4095
  "use strict";
3853
4096
  // @ts-check
3854
4097
 
3855
- var addErrorDetailIf = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf;
4098
+ var addErrorDetailIf = (__webpack_require__(/*! ../helpers */ "../helpers/helpers.js").addErrorDetailIf);
3856
4099
  var tokenTypeToStyle = {
3857
4100
  "fence": "fenced",
3858
4101
  "code_block": "indented"
@@ -3937,6 +4180,88 @@ module.exports = {
3937
4180
  };
3938
4181
 
3939
4182
 
4183
+ /***/ }),
4184
+
4185
+ /***/ "../lib/md049.js":
4186
+ /*!***********************!*\
4187
+ !*** ../lib/md049.js ***!
4188
+ \***********************/
4189
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4190
+
4191
+ "use strict";
4192
+ // @ts-check
4193
+
4194
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, emphasisOrStrongStyleFor = _a.emphasisOrStrongStyleFor, forEachInlineChild = _a.forEachInlineChild, getNextChildToken = _a.getNextChildToken, getRangeAndFixInfoIfFound = _a.getRangeAndFixInfoIfFound;
4195
+ module.exports = {
4196
+ "names": ["MD049", "emphasis-style"],
4197
+ "description": "Emphasis style should be consistent",
4198
+ "tags": ["emphasis"],
4199
+ "function": function MD049(params, onError) {
4200
+ var expectedStyle = String(params.config.style || "consistent");
4201
+ forEachInlineChild(params, "em_open", function (token, parent) {
4202
+ var lineNumber = token.lineNumber, markup = token.markup;
4203
+ var markupStyle = emphasisOrStrongStyleFor(markup);
4204
+ if (expectedStyle === "consistent") {
4205
+ expectedStyle = markupStyle;
4206
+ }
4207
+ if (expectedStyle !== markupStyle) {
4208
+ var rangeAndFixInfo = {};
4209
+ var contentToken = getNextChildToken(parent, token, "text", "em_close");
4210
+ if (contentToken) {
4211
+ var content = contentToken.content;
4212
+ var actual = "".concat(markup).concat(content).concat(markup);
4213
+ var expectedMarkup = (expectedStyle === "asterisk") ? "*" : "_";
4214
+ var expected = "".concat(expectedMarkup).concat(content).concat(expectedMarkup);
4215
+ rangeAndFixInfo = getRangeAndFixInfoIfFound(params.lines, lineNumber - 1, actual, expected);
4216
+ }
4217
+ addError(onError, lineNumber, "Expected: ".concat(expectedStyle, "; Actual: ").concat(markupStyle), null, rangeAndFixInfo.range, rangeAndFixInfo.fixInfo);
4218
+ }
4219
+ });
4220
+ }
4221
+ };
4222
+
4223
+
4224
+ /***/ }),
4225
+
4226
+ /***/ "../lib/md050.js":
4227
+ /*!***********************!*\
4228
+ !*** ../lib/md050.js ***!
4229
+ \***********************/
4230
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4231
+
4232
+ "use strict";
4233
+ // @ts-check
4234
+
4235
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, emphasisOrStrongStyleFor = _a.emphasisOrStrongStyleFor, forEachInlineChild = _a.forEachInlineChild, getNextChildToken = _a.getNextChildToken, getRangeAndFixInfoIfFound = _a.getRangeAndFixInfoIfFound;
4236
+ module.exports = {
4237
+ "names": ["MD050", "strong-style"],
4238
+ "description": "Strong style should be consistent",
4239
+ "tags": ["emphasis"],
4240
+ "function": function MD050(params, onError) {
4241
+ var expectedStyle = String(params.config.style || "consistent");
4242
+ forEachInlineChild(params, "strong_open", function (token, parent) {
4243
+ var lineNumber = token.lineNumber, markup = token.markup;
4244
+ var markupStyle = emphasisOrStrongStyleFor(markup);
4245
+ if (expectedStyle === "consistent") {
4246
+ expectedStyle = markupStyle;
4247
+ }
4248
+ if (expectedStyle !== markupStyle) {
4249
+ var rangeAndFixInfo = {};
4250
+ var contentToken = getNextChildToken(parent, token, "text", "strong_close");
4251
+ if (contentToken) {
4252
+ var content = contentToken.content;
4253
+ var actual = "".concat(markup).concat(content).concat(markup);
4254
+ var expectedMarkup = (expectedStyle === "asterisk") ? "**" : "__";
4255
+ var expected = "".concat(expectedMarkup).concat(content).concat(expectedMarkup);
4256
+ rangeAndFixInfo = getRangeAndFixInfoIfFound(params.lines, lineNumber - 1, actual, expected);
4257
+ }
4258
+ addError(onError, lineNumber, "Expected: ".concat(expectedStyle, "; Actual: ").concat(markupStyle), null, rangeAndFixInfo.range, rangeAndFixInfo.fixInfo);
4259
+ }
4260
+ });
4261
+ }
4262
+ };
4263
+
4264
+
3940
4265
  /***/ }),
3941
4266
 
3942
4267
  /***/ "../lib/rules.js":
@@ -3948,9 +4273,7 @@ module.exports = {
3948
4273
  "use strict";
3949
4274
  // @ts-check
3950
4275
 
3951
- var packageJson = __webpack_require__(/*! ../package.json */ "../package.json");
3952
- var homepage = packageJson.homepage;
3953
- var version = packageJson.version;
4276
+ var _a = __webpack_require__(/*! ./constants */ "../lib/constants.js"), homepage = _a.homepage, version = _a.version;
3954
4277
  var rules = [
3955
4278
  __webpack_require__(/*! ./md001 */ "../lib/md001.js"),
3956
4279
  __webpack_require__(/*! ./md002 */ "../lib/md002.js"),
@@ -3995,28 +4318,19 @@ var rules = [
3995
4318
  __webpack_require__(/*! ./md045 */ "../lib/md045.js"),
3996
4319
  __webpack_require__(/*! ./md046 */ "../lib/md046.js"),
3997
4320
  __webpack_require__(/*! ./md047 */ "../lib/md047.js"),
3998
- __webpack_require__(/*! ./md048 */ "../lib/md048.js")
4321
+ __webpack_require__(/*! ./md048 */ "../lib/md048.js"),
4322
+ __webpack_require__(/*! ./md049 */ "../lib/md049.js"),
4323
+ __webpack_require__(/*! ./md050 */ "../lib/md050.js")
3999
4324
  ];
4000
4325
  rules.forEach(function (rule) {
4001
4326
  var name = rule.names[0].toLowerCase();
4002
4327
  // eslint-disable-next-line dot-notation
4003
4328
  rule["information"] =
4004
- new URL(homepage + "/blob/v" + version + "/doc/Rules.md#" + name);
4329
+ new URL("".concat(homepage, "/blob/v").concat(version, "/doc/Rules.md#").concat(name));
4005
4330
  });
4006
4331
  module.exports = rules;
4007
4332
 
4008
4333
 
4009
- /***/ }),
4010
-
4011
- /***/ "../package.json":
4012
- /*!***********************!*\
4013
- !*** ../package.json ***!
4014
- \***********************/
4015
- /***/ ((module) => {
4016
-
4017
- "use strict";
4018
- module.exports = JSON.parse("{\"name\":\"markdownlint\",\"version\":\"0.23.0\",\"description\":\"A Node.js style checker and lint tool for Markdown/CommonMark files.\",\"main\":\"lib/markdownlint.js\",\"types\":\"lib/markdownlint.d.ts\",\"author\":\"David Anson (https://dlaa.me/)\",\"license\":\"MIT\",\"homepage\":\"https://github.com/DavidAnson/markdownlint\",\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/DavidAnson/markdownlint.git\"},\"bugs\":\"https://github.com/DavidAnson/markdownlint/issues\",\"scripts\":{\"build-config\":\"npm run build-config-schema && npm run build-config-example\",\"build-config-example\":\"node schema/build-config-example.js\",\"build-config-schema\":\"node schema/build-config-schema.js\",\"build-declaration\":\"tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'\",\"build-demo\":\"cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && webpack --no-stats\",\"build-example\":\"npm install --no-save --ignore-scripts grunt grunt-cli gulp through2\",\"ci\":\"npm-run-all --continue-on-error --parallel test-cover lint declaration build-config build-demo && git diff --exit-code\",\"clean-test-repos\":\"rimraf test-repos\",\"clone-test-repos\":\"mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet\",\"clone-test-repos-large\":\"npm run clone-test-repos && cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet\",\"declaration\":\"npm run build-declaration && npm run test-declaration\",\"example\":\"cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint\",\"lint\":\"eslint --max-warnings 0 .\",\"lint-test-repos\":\"ava --timeout=5m test/markdownlint-test-repos.js\",\"test\":\"ava test/markdownlint-test.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js\",\"test-cover\":\"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test\",\"test-declaration\":\"cd example/typescript && tsc && node type-check.js\",\"test-extra\":\"ava --timeout=5m test/markdownlint-test-extra.js\"},\"engines\":{\"node\":\">=10\"},\"dependencies\":{\"markdown-it\":\"12.0.4\"},\"devDependencies\":{\"ava\":\"~3.15.0\",\"c8\":\"~7.5.0\",\"cpy-cli\":\"~3.1.1\",\"eslint\":\"~7.19.0\",\"eslint-plugin-jsdoc\":\"~31.6.0\",\"eslint-plugin-node\":\"~11.1.0\",\"eslint-plugin-unicorn\":\"~27.0.0\",\"globby\":\"~11.0.2\",\"js-yaml\":\"~4.0.0\",\"markdown-it-for-inline\":\"~0.1.1\",\"markdown-it-sub\":\"~1.0.0\",\"markdown-it-sup\":\"~1.0.0\",\"markdown-it-texmath\":\"~0.8.0\",\"markdownlint-rule-helpers\":\"~0.13.0\",\"npm-run-all\":\"~4.1.5\",\"rimraf\":\"~3.0.2\",\"strip-json-comments\":\"~3.1.1\",\"toml\":\"~3.0.0\",\"ts-loader\":\"~8.0.15\",\"tv4\":\"~1.3.0\",\"typescript\":\"~4.1.3\",\"webpack\":\"~5.21.1\",\"webpack-cli\":\"~4.5.0\"},\"keywords\":[\"markdown\",\"lint\",\"md\",\"CommonMark\",\"markdownlint\"]}");
4019
-
4020
4334
  /***/ }),
4021
4335
 
4022
4336
  /***/ "markdown-it":
@@ -4030,7 +4344,7 @@ module.exports = markdownit;
4030
4344
 
4031
4345
  /***/ }),
4032
4346
 
4033
- /***/ "?65c5":
4347
+ /***/ "?ec0a":
4034
4348
  /*!********************!*\
4035
4349
  !*** fs (ignored) ***!
4036
4350
  \********************/
@@ -4040,17 +4354,7 @@ module.exports = markdownit;
4040
4354
 
4041
4355
  /***/ }),
4042
4356
 
4043
- /***/ "?5533":
4044
- /*!********************!*\
4045
- !*** os (ignored) ***!
4046
- \********************/
4047
- /***/ (() => {
4048
-
4049
- /* (ignored) */
4050
-
4051
- /***/ }),
4052
-
4053
- /***/ "?0f27":
4357
+ /***/ "?b85c":
4054
4358
  /*!**********************!*\
4055
4359
  !*** path (ignored) ***!
4056
4360
  \**********************/
@@ -4060,7 +4364,7 @@ module.exports = markdownit;
4060
4364
 
4061
4365
  /***/ }),
4062
4366
 
4063
- /***/ "?0bed":
4367
+ /***/ "?96a2":
4064
4368
  /*!**********************!*\
4065
4369
  !*** util (ignored) ***!
4066
4370
  \**********************/
@@ -4078,8 +4382,9 @@ module.exports = markdownit;
4078
4382
  /******/ // The require function
4079
4383
  /******/ function __webpack_require__(moduleId) {
4080
4384
  /******/ // Check if module is in cache
4081
- /******/ if(__webpack_module_cache__[moduleId]) {
4082
- /******/ return __webpack_module_cache__[moduleId].exports;
4385
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
4386
+ /******/ if (cachedModule !== undefined) {
4387
+ /******/ return cachedModule.exports;
4083
4388
  /******/ }
4084
4389
  /******/ // Create a new module (and put it into the cache)
4085
4390
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -4102,9 +4407,12 @@ module.exports = markdownit;
4102
4407
  /******/ })();
4103
4408
  /******/
4104
4409
  /************************************************************************/
4105
- /******/ // module exports must be returned from runtime so entry inlining is disabled
4410
+ /******/
4106
4411
  /******/ // startup
4107
4412
  /******/ // Load entry module and return exports
4108
- /******/ return __webpack_require__("../lib/markdownlint.js");
4413
+ /******/ // This entry module is referenced by other modules so it can't be inlined
4414
+ /******/ var __webpack_exports__ = __webpack_require__("../lib/markdownlint.js");
4415
+ /******/ markdownlint = __webpack_exports__;
4416
+ /******/
4109
4417
  /******/ })()
4110
4418
  ;