markdownlint 0.23.1 → 0.24.0

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.1 https://github.com/DavidAnson/markdownlint @license MIT */
2
- var markdownlint;markdownlint =
1
+ /*! markdownlint 0.24.0 https://github.com/DavidAnson/markdownlint @license MIT */
2
+ var markdownlint;
3
3
  /******/ (() => { // webpackBootstrap
4
4
  /******/ var __webpack_modules__ = ({
5
5
 
@@ -30,7 +30,7 @@ module.exports = webpackEmptyContext;
30
30
  "use strict";
31
31
  // @ts-check
32
32
 
33
- var os = __webpack_require__(/*! os */ "?5533");
33
+ var os = __webpack_require__(/*! os */ "?591e");
34
34
  // Regular expression for matching common newline characters
35
35
  // See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
36
36
  var newLineRe = /\r\n?|\n/g;
@@ -51,9 +51,10 @@ module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
51
51
  // Regular expression for all instances of emphasis markers
52
52
  var emphasisMarkersRe = /[_*]/g;
53
53
  // 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";
54
+ var linkRe = /(\[(?:[^[\]]|\[[^\]]*\])*\])(\(\S*\)|\[\S*\])?/g;
55
+ module.exports.linkRe = linkRe;
56
+ // Regular expression for link reference definition lines
57
+ module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/;
57
58
  // All punctuation characters (normal and full-width)
58
59
  var allPunctuation = ".,;:!?。,;:!?";
59
60
  module.exports.allPunctuation = allPunctuation;
@@ -300,14 +301,14 @@ module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
300
301
  });
301
302
  };
302
303
  // Returns (nested) lists as a flat array (in order)
303
- module.exports.flattenLists = function flattenLists(params) {
304
+ module.exports.flattenLists = function flattenLists(tokens) {
304
305
  var flattenedLists = [];
305
306
  var stack = [];
306
307
  var current = null;
307
308
  var nesting = 0;
308
309
  var nestingStack = [];
309
310
  var lastWithMap = { "map": [0, 1] };
310
- params.tokens.forEach(function (token) {
311
+ tokens.forEach(function (token) {
311
312
  if (isMathBlock(token) && token.map[1]) {
312
313
  // markdown-it-texmath plugin does not account for math_block_end
313
314
  token.map[1]++;
@@ -516,6 +517,36 @@ module.exports.addErrorContext = function addErrorContext(onError, lineNumber, c
516
517
  }
517
518
  addError(onError, lineNumber, null, context, range, fixInfo);
518
519
  };
520
+ /**
521
+ * Returns an array of code span ranges.
522
+ *
523
+ * @param {string[]} lines Lines to scan for code span ranges.
524
+ * @returns {number[][]} Array of ranges (line, index, length).
525
+ */
526
+ module.exports.inlineCodeSpanRanges = function (lines) {
527
+ var exclusions = [];
528
+ forEachInlineCodeSpan(lines.join("\n"), function (code, lineIndex, columnIndex) {
529
+ var codeLines = code.split(newLineRe);
530
+ // eslint-disable-next-line unicorn/no-for-loop
531
+ for (var i = 0; i < codeLines.length; i++) {
532
+ exclusions.push([lineIndex + i, columnIndex, codeLines[i].length]);
533
+ columnIndex = 0;
534
+ }
535
+ });
536
+ return exclusions;
537
+ };
538
+ /**
539
+ * Determines whether the specified range overlaps another range.
540
+ *
541
+ * @param {number[][]} ranges Array of ranges (line, index, length).
542
+ * @param {number} lineIndex Line index to check.
543
+ * @param {number} index Index to check.
544
+ * @param {number} length Length to check.
545
+ * @returns {boolean} True iff the specified range overlaps.
546
+ */
547
+ module.exports.overlapsAnyRange = function (ranges, lineIndex, index, length) { return (!ranges.every(function (span) { return ((lineIndex !== span[0]) ||
548
+ (index + length < span[1]) ||
549
+ (index > span[1] + span[2])); })); };
519
550
  // Returns a range object for a line by applying a RegExp
520
551
  module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {
521
552
  var range = null;
@@ -727,13 +758,6 @@ module.exports.applyFixes = function applyFixes(input, errors) {
727
758
  "use strict";
728
759
  // @ts-check
729
760
 
730
- var lineMetadata = null;
731
- module.exports.lineMetadata = function (value) {
732
- if (value) {
733
- lineMetadata = value;
734
- }
735
- return lineMetadata;
736
- };
737
761
  var flattenedLists = null;
738
762
  module.exports.flattenedLists = function (value) {
739
763
  if (value) {
@@ -741,9 +765,24 @@ module.exports.flattenedLists = function (value) {
741
765
  }
742
766
  return flattenedLists;
743
767
  };
768
+ var inlineCodeSpanRanges = null;
769
+ module.exports.inlineCodeSpanRanges = function (value) {
770
+ if (value) {
771
+ inlineCodeSpanRanges = value;
772
+ }
773
+ return inlineCodeSpanRanges;
774
+ };
775
+ var lineMetadata = null;
776
+ module.exports.lineMetadata = function (value) {
777
+ if (value) {
778
+ lineMetadata = value;
779
+ }
780
+ return lineMetadata;
781
+ };
744
782
  module.exports.clear = function () {
745
- lineMetadata = null;
746
783
  flattenedLists = null;
784
+ inlineCodeSpanRanges = null;
785
+ lineMetadata = null;
747
786
  };
748
787
 
749
788
 
@@ -769,16 +808,13 @@ var __assign = (this && this.__assign) || function () {
769
808
  };
770
809
  return __assign.apply(this, arguments);
771
810
  };
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;
811
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
812
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
813
+ to[j] = from[i];
814
+ return to;
778
815
  };
779
- var fs = __webpack_require__(/*! fs */ "?65c5");
780
- var path = __webpack_require__(/*! path */ "?0f27");
781
- var promisify = __webpack_require__(/*! util */ "?0bed").promisify;
816
+ var path = __webpack_require__(/*! path */ "?b85c");
817
+ var promisify = __webpack_require__(/*! util */ "?96a2").promisify;
782
818
  var markdownIt = __webpack_require__(/*! markdown-it */ "markdown-it");
783
819
  var rules = __webpack_require__(/*! ./rules */ "../lib/rules.js");
784
820
  var helpers = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js");
@@ -952,7 +988,7 @@ function annotateTokens(tokens, lines) {
952
988
  // Handle missing maps for table head/body
953
989
  if ((token.type === "thead_open") ||
954
990
  (token.type === "tbody_open")) {
955
- tableMap = token.map.slice();
991
+ tableMap = __spreadArray([], token.map);
956
992
  }
957
993
  else if ((token.type === "tr_close") &&
958
994
  tableMap) {
@@ -963,7 +999,7 @@ function annotateTokens(tokens, lines) {
963
999
  tableMap = null;
964
1000
  }
965
1001
  if (tableMap && !token.map) {
966
- token.map = tableMap.slice();
1002
+ token.map = __spreadArray([], tableMap);
967
1003
  }
968
1004
  // Update token metadata
969
1005
  if (token.map) {
@@ -1237,7 +1273,8 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1237
1273
  frontMatterLines: frontMatterLines
1238
1274
  };
1239
1275
  cache.lineMetadata(helpers.getLineMetadata(params));
1240
- cache.flattenedLists(helpers.flattenLists(params));
1276
+ cache.flattenedLists(helpers.flattenLists(params.tokens));
1277
+ cache.inlineCodeSpanRanges(helpers.inlineCodeSpanRanges(params.lines));
1241
1278
  // Function to run for each rule
1242
1279
  var result = (resultVersion === 0) ? {} : [];
1243
1280
  // eslint-disable-next-line jsdoc/require-jsdoc
@@ -1323,7 +1360,7 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1323
1360
  "lineNumber": errorInfo.lineNumber + frontMatterLines.length,
1324
1361
  "detail": errorInfo.detail || null,
1325
1362
  "context": errorInfo.context || null,
1326
- "range": errorInfo.range ? __spreadArrays(errorInfo.range) : null,
1363
+ "range": errorInfo.range ? __spreadArray([], errorInfo.range) : null,
1327
1364
  "fixInfo": fixInfo ? cleanFixInfo : null
1328
1365
  });
1329
1366
  }
@@ -1408,11 +1445,12 @@ function lintContent(ruleList, name, content, md, config, frontMatter, handleRul
1408
1445
  * @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
1409
1446
  * @param {boolean} noInlineConfig Whether to allow inline configuration.
1410
1447
  * @param {number} resultVersion Version of the LintResults object to return.
1448
+ * @param {Object} fs File system implementation.
1411
1449
  * @param {boolean} synchronous Whether to execute synchronously.
1412
1450
  * @param {Function} callback Callback (err, result) function.
1413
1451
  * @returns {void}
1414
1452
  */
1415
- function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, callback) {
1453
+ function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, callback) {
1416
1454
  // eslint-disable-next-line jsdoc/require-jsdoc
1417
1455
  function lintContentWrapper(err, content) {
1418
1456
  if (err) {
@@ -1422,11 +1460,10 @@ function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, n
1422
1460
  }
1423
1461
  // Make a/synchronous call to read file
1424
1462
  if (synchronous) {
1425
- // @ts-ignore
1426
- lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding));
1463
+ lintContentWrapper(null, fs.readFileSync(file, "utf8"));
1427
1464
  }
1428
1465
  else {
1429
- fs.readFile(file, helpers.utf8Encoding, lintContentWrapper);
1466
+ fs.readFile(file, "utf8", lintContentWrapper);
1430
1467
  }
1431
1468
  }
1432
1469
  /**
@@ -1449,7 +1486,7 @@ function lintInput(options, synchronous, callback) {
1449
1486
  }
1450
1487
  var files = [];
1451
1488
  if (Array.isArray(options.files)) {
1452
- files = options.files.slice();
1489
+ files = __spreadArray([], options.files);
1453
1490
  }
1454
1491
  else if (options.files) {
1455
1492
  files = [String(options.files)];
@@ -1469,6 +1506,7 @@ function lintInput(options, synchronous, callback) {
1469
1506
  // @ts-ignore
1470
1507
  md.use.apply(md, plugin);
1471
1508
  });
1509
+ var fs = options.fs || __webpack_require__(/*! fs */ "?ec0a");
1472
1510
  var results = newResults(ruleList);
1473
1511
  var done = false;
1474
1512
  // Linting of strings is always synchronous
@@ -1488,7 +1526,7 @@ function lintInput(options, synchronous, callback) {
1488
1526
  if (synchronous) {
1489
1527
  // Lint files synchronously
1490
1528
  while (!done && (syncItem = files.shift())) {
1491
- lintFile(ruleList, syncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, syncCallback);
1529
+ lintFile(ruleList, syncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, syncCallback);
1492
1530
  }
1493
1531
  return done || callback(null, results);
1494
1532
  }
@@ -1502,7 +1540,7 @@ function lintInput(options, synchronous, callback) {
1502
1540
  }
1503
1541
  else if (asyncItem) {
1504
1542
  concurrency++;
1505
- lintFile(ruleList, asyncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, synchronous, function (err, result) {
1543
+ lintFile(ruleList, asyncItem, md, config, frontMatter, handleRuleFailures, noInlineConfig, resultVersion, fs, synchronous, function (err, result) {
1506
1544
  concurrency--;
1507
1545
  if (err) {
1508
1546
  done = true;
@@ -1606,24 +1644,51 @@ function parseConfiguration(name, content, parsers) {
1606
1644
  *
1607
1645
  * @param {string} configFile Configuration file name.
1608
1646
  * @param {string} referenceId Referenced identifier to resolve.
1647
+ * @param {Object} fs File system implementation.
1648
+ * @param {ResolveConfigExtendsCallback} [callback] Callback (err, result)
1649
+ * function.
1650
+ * @returns {void}
1651
+ */
1652
+ function resolveConfigExtends(configFile, referenceId, fs, callback) {
1653
+ var configFileDirname = path.dirname(configFile);
1654
+ var resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
1655
+ fs.access(resolvedExtendsFile, function (err) {
1656
+ if (err) {
1657
+ // Not a file, try require.resolve
1658
+ try {
1659
+ return callback(null, dynamicRequire.resolve(referenceId, { "paths": [configFileDirname] }));
1660
+ }
1661
+ catch (_a) {
1662
+ // Unable to resolve, use resolvedExtendsFile
1663
+ }
1664
+ }
1665
+ return callback(null, resolvedExtendsFile);
1666
+ });
1667
+ }
1668
+ /**
1669
+ * Resolve referenced "extends" path in a configuration file
1670
+ * using path.resolve() with require.resolve() as a fallback.
1671
+ *
1672
+ * @param {string} configFile Configuration file name.
1673
+ * @param {string} referenceId Referenced identifier to resolve.
1674
+ * @param {Object} fs File system implementation.
1609
1675
  * @returns {string} Resolved path to file.
1610
1676
  */
1611
- function resolveConfigExtends(configFile, referenceId) {
1677
+ function resolveConfigExtendsSync(configFile, referenceId, fs) {
1612
1678
  var configFileDirname = path.dirname(configFile);
1613
1679
  var resolvedExtendsFile = path.resolve(configFileDirname, referenceId);
1614
1680
  try {
1615
- if (fs.statSync(resolvedExtendsFile).isFile()) {
1616
- return resolvedExtendsFile;
1617
- }
1681
+ fs.accessSync(resolvedExtendsFile);
1682
+ return resolvedExtendsFile;
1618
1683
  }
1619
1684
  catch (_a) {
1620
- // If not a file or fs.statSync throws, try require.resolve
1685
+ // Not a file, try require.resolve
1621
1686
  }
1622
1687
  try {
1623
1688
  return dynamicRequire.resolve(referenceId, { "paths": [configFileDirname] });
1624
1689
  }
1625
1690
  catch (_b) {
1626
- // If require.resolve throws, return resolvedExtendsFile
1691
+ // Unable to resolve, return resolvedExtendsFile
1627
1692
  }
1628
1693
  return resolvedExtendsFile;
1629
1694
  }
@@ -1633,17 +1698,27 @@ function resolveConfigExtends(configFile, referenceId) {
1633
1698
  * @param {string} file Configuration file name.
1634
1699
  * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
1635
1700
  * function(s).
1701
+ * @param {Object} [fs] File system implementation.
1636
1702
  * @param {ReadConfigCallback} [callback] Callback (err, result) function.
1637
1703
  * @returns {void}
1638
1704
  */
1639
- function readConfig(file, parsers, callback) {
1705
+ function readConfig(file, parsers, fs, callback) {
1640
1706
  if (!callback) {
1641
- // @ts-ignore
1642
- callback = parsers;
1643
- parsers = null;
1707
+ if (fs) {
1708
+ callback = fs;
1709
+ fs = null;
1710
+ }
1711
+ else {
1712
+ // @ts-ignore
1713
+ callback = parsers;
1714
+ parsers = null;
1715
+ }
1716
+ }
1717
+ if (!fs) {
1718
+ fs = __webpack_require__(/*! fs */ "?ec0a");
1644
1719
  }
1645
1720
  // Read file
1646
- fs.readFile(file, helpers.utf8Encoding, function (err, content) {
1721
+ fs.readFile(file, "utf8", function (err, content) {
1647
1722
  if (err) {
1648
1723
  return callback(err);
1649
1724
  }
@@ -1657,13 +1732,12 @@ function readConfig(file, parsers, callback) {
1657
1732
  var configExtends = config["extends"];
1658
1733
  if (configExtends) {
1659
1734
  delete config["extends"];
1660
- var resolvedExtends = resolveConfigExtends(file, configExtends);
1661
- return readConfig(resolvedExtends, parsers, function (errr, extendsConfig) {
1735
+ return resolveConfigExtends(file, configExtends, fs, function (_, resolvedExtends) { return readConfig(resolvedExtends, parsers, fs, function (errr, extendsConfig) {
1662
1736
  if (errr) {
1663
1737
  return callback(errr);
1664
1738
  }
1665
1739
  return callback(null, __assign(__assign({}, extendsConfig), config));
1666
- });
1740
+ }); });
1667
1741
  }
1668
1742
  return callback(null, config);
1669
1743
  });
@@ -1674,23 +1748,28 @@ var readConfigPromisify = promisify && promisify(readConfig);
1674
1748
  *
1675
1749
  * @param {string} file Configuration file name.
1676
1750
  * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1751
+ * @param {Object} [fs] File system implementation.
1677
1752
  * @returns {Promise<Configuration>} Configuration object.
1678
1753
  */
1679
- function readConfigPromise(file, parsers) {
1754
+ function readConfigPromise(file, parsers, fs) {
1680
1755
  // @ts-ignore
1681
- return readConfigPromisify(file, parsers);
1756
+ return readConfigPromisify(file, parsers, fs);
1682
1757
  }
1683
1758
  /**
1684
1759
  * Read specified configuration file synchronously.
1685
1760
  *
1686
1761
  * @param {string} file Configuration file name.
1687
1762
  * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1763
+ * @param {Object} [fs] File system implementation.
1688
1764
  * @returns {Configuration} Configuration object.
1765
+ * @throws An Error if processing fails.
1689
1766
  */
1690
- function readConfigSync(file, parsers) {
1767
+ function readConfigSync(file, parsers, fs) {
1768
+ if (!fs) {
1769
+ fs = __webpack_require__(/*! fs */ "?ec0a");
1770
+ }
1691
1771
  // Read file
1692
- // @ts-ignore
1693
- var content = fs.readFileSync(file, helpers.utf8Encoding);
1772
+ var content = fs.readFileSync(file, "utf8");
1694
1773
  // Try to parse file
1695
1774
  var _a = parseConfiguration(file, content, parsers), config = _a.config, message = _a.message;
1696
1775
  if (!config) {
@@ -1700,8 +1779,8 @@ function readConfigSync(file, parsers) {
1700
1779
  var configExtends = config["extends"];
1701
1780
  if (configExtends) {
1702
1781
  delete config["extends"];
1703
- var resolvedExtends = resolveConfigExtends(file, configExtends);
1704
- return __assign(__assign({}, readConfigSync(resolvedExtends, parsers)), config);
1782
+ var resolvedExtends = resolveConfigExtendsSync(file, configExtends, fs);
1783
+ return __assign(__assign({}, readConfigSync(resolvedExtends, parsers, fs)), config);
1705
1784
  }
1706
1785
  return config;
1707
1786
  }
@@ -2143,6 +2222,10 @@ module.exports = {
2143
2222
  "function": function MD010(params, onError) {
2144
2223
  var codeBlocks = params.config.code_blocks;
2145
2224
  var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
2225
+ var spacesPerTab = params.config.spaces_per_tab;
2226
+ var spaceMultiplier = (spacesPerTab === undefined) ?
2227
+ 1 :
2228
+ Math.max(0, Number(spacesPerTab));
2146
2229
  forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
2147
2230
  if (!inCode || includeCodeBlocks) {
2148
2231
  var match = null;
@@ -2152,7 +2235,7 @@ module.exports = {
2152
2235
  addError(onError, lineIndex + 1, "Column: " + column, null, [column, length_1], {
2153
2236
  "editColumn": column,
2154
2237
  "deleteCount": length_1,
2155
- "insertText": "".padEnd(length_1)
2238
+ "insertText": "".padEnd(length_1 * spaceMultiplier)
2156
2239
  });
2157
2240
  }
2158
2241
  }
@@ -2172,30 +2255,32 @@ module.exports = {
2172
2255
  "use strict";
2173
2256
  // @ts-check
2174
2257
 
2175
- var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachInlineChild = _a.forEachInlineChild, unescapeMarkdown = _a.unescapeMarkdown;
2176
- var reversedLinkRe = /\(([^)]+)\)\[([^\]^][^\]]*)]/g;
2258
+ var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
2259
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), inlineCodeSpanRanges = _b.inlineCodeSpanRanges, lineMetadata = _b.lineMetadata;
2260
+ var reversedLinkRe = /(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
2177
2261
  module.exports = {
2178
2262
  "names": ["MD011", "no-reversed-links"],
2179
2263
  "description": "Reversed link syntax",
2180
2264
  "tags": ["links"],
2181
2265
  "function": function MD011(params, onError) {
2182
- forEachInlineChild(params, "text", function (token) {
2183
- var lineNumber = token.lineNumber, content = token.content;
2184
- var match = null;
2185
- while ((match = reversedLinkRe.exec(content)) !== null) {
2186
- var reversedLink = match[0], linkText = match[1], linkDestination = match[2];
2187
- var line = params.lines[lineNumber - 1];
2188
- var column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
2189
- var length_1 = reversedLink.length;
2190
- var range = column ? [column, length_1] : null;
2191
- var fixInfo = column ?
2192
- {
2193
- "editColumn": column,
2194
- "deleteCount": length_1,
2195
- "insertText": "[" + linkText + "](" + linkDestination + ")"
2196
- } :
2197
- null;
2198
- addError(onError, lineNumber, reversedLink, null, range, fixInfo);
2266
+ var exclusions = inlineCodeSpanRanges();
2267
+ forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
2268
+ if (!inCode && !onFence) {
2269
+ var match = null;
2270
+ while ((match = reversedLinkRe.exec(line)) !== null) {
2271
+ var reversedLink = match[0], preChar = match[1], linkText = match[2], linkDestination = match[3];
2272
+ var index = match.index + preChar.length;
2273
+ var length_1 = match[0].length - preChar.length;
2274
+ if (!linkText.endsWith("\\") &&
2275
+ !linkDestination.endsWith("\\") &&
2276
+ !overlapsAnyRange(exclusions, lineIndex, index, length_1)) {
2277
+ addError(onError, lineIndex + 1, reversedLink.slice(preChar.length), null, [index + 1, length_1], {
2278
+ "editColumn": index + 1,
2279
+ "deleteCount": length_1,
2280
+ "insertText": "[" + linkText + "](" + linkDestination + ")"
2281
+ });
2282
+ }
2283
+ }
2199
2284
  }
2200
2285
  });
2201
2286
  }
@@ -3330,11 +3415,19 @@ module.exports = {
3330
3415
  resetRunTracking();
3331
3416
  forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence, inTable, inItem, onBreak, inMath) {
3332
3417
  var onItemStart = (inItem === 1);
3333
- if (inCode || inTable || onBreak || onItemStart || isBlankLine(line)) {
3418
+ if (inCode ||
3419
+ onFence ||
3420
+ inTable ||
3421
+ onBreak ||
3422
+ onItemStart ||
3423
+ isBlankLine(line)) {
3334
3424
  // Emphasis resets when leaving a block
3335
3425
  resetRunTracking();
3336
3426
  }
3337
- if (inCode || onBreak || inMath) {
3427
+ if (inCode ||
3428
+ onFence ||
3429
+ onBreak ||
3430
+ inMath) {
3338
3431
  // Emphasis has no meaning here
3339
3432
  return;
3340
3433
  }
@@ -3699,8 +3792,11 @@ module.exports = {
3699
3792
  var actual = levels_1[heading.tag] + " " + content;
3700
3793
  var expected = getExpected_1();
3701
3794
  if (expected === "*") {
3702
- matchAny_1 = true;
3703
- getExpected_1();
3795
+ var nextExpected = getExpected_1();
3796
+ if (nextExpected.toLowerCase() !== actual.toLowerCase()) {
3797
+ matchAny_1 = true;
3798
+ i_1--;
3799
+ }
3704
3800
  }
3705
3801
  else if (expected === "+") {
3706
3802
  matchAny_1 = true;
@@ -3717,8 +3813,10 @@ module.exports = {
3717
3813
  }
3718
3814
  }
3719
3815
  });
3816
+ var extraHeadings = requiredHeadings.length - i_1;
3720
3817
  if (!hasError_1 &&
3721
- (i_1 < requiredHeadings.length) &&
3818
+ ((extraHeadings > 1) ||
3819
+ ((extraHeadings === 1) && (requiredHeadings[i_1] !== "*"))) &&
3722
3820
  (anyHeadings_1 || !requiredHeadings.every(function (heading) { return heading === "*"; }))) {
3723
3821
  addErrorContext(onError, params.lines.length, requiredHeadings[i_1]);
3724
3822
  }
@@ -3738,9 +3836,8 @@ module.exports = {
3738
3836
  "use strict";
3739
3837
  // @ts-check
3740
3838
 
3741
- 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;
3742
- var startNonWordRe = /^\W/;
3743
- var endNonWordRe = /\W$/;
3839
+ 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;
3840
+ var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), inlineCodeSpanRanges = _b.inlineCodeSpanRanges, lineMetadata = _b.lineMetadata;
3744
3841
  module.exports = {
3745
3842
  "names": ["MD044", "proper-names"],
3746
3843
  "description": "Proper names should have the correct capitalization",
@@ -3748,73 +3845,59 @@ module.exports = {
3748
3845
  "function": function MD044(params, onError) {
3749
3846
  var names = params.config.names;
3750
3847
  names = Array.isArray(names) ? names : [];
3848
+ names.sort(function (a, b) { return (b.length - a.length) || a.localeCompare(b); });
3751
3849
  var codeBlocks = params.config.code_blocks;
3752
3850
  var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
3753
- // Text of automatic hyperlinks is implicitly a URL
3754
- var autolinkText = new Set();
3755
- filterTokens(params, "inline", function (token) {
3756
- var inAutoLink = false;
3757
- token.children.forEach(function (child) {
3758
- var info = child.info, type = child.type;
3759
- if ((type === "link_open") && (info === "auto")) {
3760
- inAutoLink = true;
3761
- }
3762
- else if (type === "link_close") {
3763
- inAutoLink = false;
3851
+ var exclusions = [];
3852
+ forEachLine(lineMetadata(), function (line, lineIndex) {
3853
+ if (linkReferenceRe.test(line)) {
3854
+ exclusions.push([lineIndex, 0, line.length]);
3855
+ }
3856
+ else {
3857
+ var match = null;
3858
+ while ((match = bareUrlRe.exec(line)) !== null) {
3859
+ exclusions.push([lineIndex, match.index, match[0].length]);
3764
3860
  }
3765
- else if ((type === "text") && inAutoLink) {
3766
- autolinkText.add(child);
3861
+ while ((match = linkRe.exec(line)) !== null) {
3862
+ var text = match[1], destination = match[2];
3863
+ if (destination) {
3864
+ exclusions.push([lineIndex, match.index + text.length, destination.length]);
3865
+ }
3767
3866
  }
3768
- });
3867
+ }
3769
3868
  });
3770
- // For each proper name...
3771
- names.forEach(function (name) {
3772
- var escapedName = escapeForRegExp(name);
3773
- var startNamePattern = startNonWordRe.test(name) ? "" : "\\S*\\b";
3774
- var endNamePattern = endNonWordRe.test(name) ? "" : "\\b\\S*";
3775
- var namePattern = "(" + startNamePattern + ")(" + escapedName + ")(" + endNamePattern + ")";
3776
- var anyNameRe = new RegExp(namePattern, "gi");
3777
- // eslint-disable-next-line jsdoc/require-jsdoc
3778
- function forToken(token) {
3779
- if (!autolinkText.has(token)) {
3780
- var fenceOffset_1 = (token.type === "fence") ? 1 : 0;
3781
- token.content.split(newLineRe).forEach(function (line, index) {
3782
- var match = null;
3783
- while ((match = anyNameRe.exec(line)) !== null) {
3784
- var fullMatch = match[0], leftMatch = match[1], nameMatch = match[2], rightMatch = match[3];
3785
- if (fullMatch.search(bareUrlRe) === -1) {
3786
- var wordMatch = fullMatch
3787
- .replace(new RegExp("^\\W{0," + leftMatch.length + "}"), "")
3788
- .replace(new RegExp("\\W{0," + rightMatch.length + "}$"), "");
3789
- if (!names.includes(wordMatch)) {
3790
- var lineNumber = token.lineNumber + index + fenceOffset_1;
3791
- var fullLine = params.lines[lineNumber - 1];
3792
- var matchLength = wordMatch.length;
3793
- var matchIndex = fullLine.indexOf(wordMatch);
3794
- var range = (matchIndex === -1) ?
3795
- null :
3796
- [matchIndex + 1, matchLength];
3797
- var fixInfo = (matchIndex === -1) ?
3798
- null :
3799
- {
3800
- "editColumn": matchIndex + 1,
3801
- "deleteCount": matchLength,
3802
- "insertText": name
3803
- };
3804
- addErrorDetailIf(onError, lineNumber, name, nameMatch, null, null, range, fixInfo);
3805
- }
3806
- }
3869
+ if (!includeCodeBlocks) {
3870
+ exclusions.push.apply(exclusions, inlineCodeSpanRanges());
3871
+ }
3872
+ var _loop_1 = function (name_1) {
3873
+ var escapedName = escapeForRegExp(name_1);
3874
+ var startNamePattern = /^\W/.test(name_1) ? "" : "\\b_*";
3875
+ var endNamePattern = /\W$/.test(name_1) ? "" : "_*\\b";
3876
+ var namePattern = "(" + startNamePattern + ")(" + escapedName + ")" + endNamePattern;
3877
+ var nameRe = new RegExp(namePattern, "gi");
3878
+ forEachLine(lineMetadata(), function (line, lineIndex, inCode, onFence) {
3879
+ if (includeCodeBlocks || (!inCode && !onFence)) {
3880
+ var match = null;
3881
+ while ((match = nameRe.exec(line)) !== null) {
3882
+ var leftMatch = match[1], nameMatch = match[2];
3883
+ var index = match.index + leftMatch.length;
3884
+ var length_1 = nameMatch.length;
3885
+ if (!overlapsAnyRange(exclusions, lineIndex, index, length_1)) {
3886
+ addErrorDetailIf(onError, lineIndex + 1, name_1, nameMatch, null, null, [index + 1, length_1], {
3887
+ "editColumn": index + 1,
3888
+ "deleteCount": length_1,
3889
+ "insertText": name_1
3890
+ });
3807
3891
  }
3808
- });
3892
+ exclusions.push([lineIndex, index, length_1]);
3893
+ }
3809
3894
  }
3810
- }
3811
- forEachInlineChild(params, "text", forToken);
3812
- if (includeCodeBlocks) {
3813
- forEachInlineChild(params, "code_inline", forToken);
3814
- filterTokens(params, "code_block", forToken);
3815
- filterTokens(params, "fence", forToken);
3816
- }
3817
- });
3895
+ });
3896
+ };
3897
+ for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
3898
+ var name_1 = names_1[_i];
3899
+ _loop_1(name_1);
3900
+ }
3818
3901
  }
3819
3902
  };
3820
3903
 
@@ -4010,17 +4093,6 @@ rules.forEach(function (rule) {
4010
4093
  module.exports = rules;
4011
4094
 
4012
4095
 
4013
- /***/ }),
4014
-
4015
- /***/ "../package.json":
4016
- /*!***********************!*\
4017
- !*** ../package.json ***!
4018
- \***********************/
4019
- /***/ ((module) => {
4020
-
4021
- "use strict";
4022
- module.exports = JSON.parse("{\"name\":\"markdownlint\",\"version\":\"0.23.1\",\"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\"]}");
4023
-
4024
4096
  /***/ }),
4025
4097
 
4026
4098
  /***/ "markdown-it":
@@ -4034,9 +4106,9 @@ module.exports = markdownit;
4034
4106
 
4035
4107
  /***/ }),
4036
4108
 
4037
- /***/ "?65c5":
4109
+ /***/ "?591e":
4038
4110
  /*!********************!*\
4039
- !*** fs (ignored) ***!
4111
+ !*** os (ignored) ***!
4040
4112
  \********************/
4041
4113
  /***/ (() => {
4042
4114
 
@@ -4044,9 +4116,9 @@ module.exports = markdownit;
4044
4116
 
4045
4117
  /***/ }),
4046
4118
 
4047
- /***/ "?5533":
4119
+ /***/ "?ec0a":
4048
4120
  /*!********************!*\
4049
- !*** os (ignored) ***!
4121
+ !*** fs (ignored) ***!
4050
4122
  \********************/
4051
4123
  /***/ (() => {
4052
4124
 
@@ -4054,7 +4126,7 @@ module.exports = markdownit;
4054
4126
 
4055
4127
  /***/ }),
4056
4128
 
4057
- /***/ "?0f27":
4129
+ /***/ "?b85c":
4058
4130
  /*!**********************!*\
4059
4131
  !*** path (ignored) ***!
4060
4132
  \**********************/
@@ -4064,7 +4136,7 @@ module.exports = markdownit;
4064
4136
 
4065
4137
  /***/ }),
4066
4138
 
4067
- /***/ "?0bed":
4139
+ /***/ "?96a2":
4068
4140
  /*!**********************!*\
4069
4141
  !*** util (ignored) ***!
4070
4142
  \**********************/
@@ -4072,6 +4144,17 @@ module.exports = markdownit;
4072
4144
 
4073
4145
  /* (ignored) */
4074
4146
 
4147
+ /***/ }),
4148
+
4149
+ /***/ "../package.json":
4150
+ /*!***********************!*\
4151
+ !*** ../package.json ***!
4152
+ \***********************/
4153
+ /***/ ((module) => {
4154
+
4155
+ "use strict";
4156
+ module.exports = JSON.parse('{"name":"markdownlint","version":"0.24.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-dotnet-docs":"cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet","clone-test-repos-eslint-eslint":"cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet","clone-test-repos-mkdocs-mkdocs":"cd test-repos && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet","clone-test-repos-mochajs-mocha":"cd test-repos && git clone https://github.com/mochajs/mocha mochajs-mocha --depth 1 --no-tags --quiet","clone-test-repos-pi-hole-docs":"cd test-repos && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet","clone-test-repos-v8-v8-dev":"cd test-repos && git clone https://github.com/v8/v8.dev v8-v8-dev --depth 1 --no-tags --quiet","clone-test-repos-webhintio-hint":"cd test-repos && git clone https://github.com/webhintio/hint webhintio-hint --depth 1 --no-tags --quiet","clone-test-repos-webpack-webpack-js-org":"cd test-repos && git clone https://github.com/webpack/webpack.js.org webpack-webpack-js-org --depth 1 --no-tags --quiet","clone-test-repos":"mkdir test-repos && cd test-repos && npm run clone-test-repos-eslint-eslint && npm run clone-test-repos-mkdocs-mkdocs && npm run clone-test-repos-mochajs-mocha && npm run clone-test-repos-pi-hole-docs && npm run clone-test-repos-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org","clone-test-repos-large":"npm run clone-test-repos && cd test-repos && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-v8-v8-dev","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.2.0"},"devDependencies":{"ava":"~3.15.0","c8":"~7.8.0","cpy-cli":"~3.1.1","eslint":"~7.32.0","eslint-plugin-jsdoc":"~36.0.7","eslint-plugin-node":"~11.1.0","eslint-plugin-unicorn":"~35.0.0","globby":"~11.0.4","js-yaml":"~4.1.0","markdown-it-for-inline":"~0.1.1","markdown-it-sub":"~1.0.0","markdown-it-sup":"~1.0.0","markdown-it-texmath":"~0.9.1","markdownlint-rule-helpers":"~0.14.0","npm-run-all":"~4.1.5","rimraf":"~3.0.2","strip-json-comments":"~3.1.1","toml":"~3.0.0","ts-loader":"~9.2.5","tv4":"~1.3.0","typescript":"~4.3.5","webpack":"~5.51.1","webpack-cli":"~4.8.0"},"keywords":["markdown","lint","md","CommonMark","markdownlint"]}');
4157
+
4075
4158
  /***/ })
4076
4159
 
4077
4160
  /******/ });
@@ -4082,8 +4165,9 @@ module.exports = markdownit;
4082
4165
  /******/ // The require function
4083
4166
  /******/ function __webpack_require__(moduleId) {
4084
4167
  /******/ // Check if module is in cache
4085
- /******/ if(__webpack_module_cache__[moduleId]) {
4086
- /******/ return __webpack_module_cache__[moduleId].exports;
4168
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
4169
+ /******/ if (cachedModule !== undefined) {
4170
+ /******/ return cachedModule.exports;
4087
4171
  /******/ }
4088
4172
  /******/ // Create a new module (and put it into the cache)
4089
4173
  /******/ var module = __webpack_module_cache__[moduleId] = {
@@ -4106,9 +4190,12 @@ module.exports = markdownit;
4106
4190
  /******/ })();
4107
4191
  /******/
4108
4192
  /************************************************************************/
4109
- /******/ // module exports must be returned from runtime so entry inlining is disabled
4193
+ /******/
4110
4194
  /******/ // startup
4111
4195
  /******/ // Load entry module and return exports
4112
- /******/ return __webpack_require__("../lib/markdownlint.js");
4196
+ /******/ // This entry module is referenced by other modules so it can't be inlined
4197
+ /******/ var __webpack_exports__ = __webpack_require__("../lib/markdownlint.js");
4198
+ /******/ markdownlint = __webpack_exports__;
4199
+ /******/
4113
4200
  /******/ })()
4114
4201
  ;