mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD010/no-hard-tabs to add ignore_code_languages parameter (fixes #383).
This commit is contained in:
parent
0f845e9ba1
commit
b447c809bd
9 changed files with 112 additions and 3 deletions
|
@ -2550,7 +2550,7 @@ module.exports = {
|
|||
"use strict";
|
||||
// @ts-check
|
||||
|
||||
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
|
||||
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addError = _a.addError, filterTokens = _a.filterTokens, forEachLine = _a.forEachLine, overlapsAnyRange = _a.overlapsAnyRange;
|
||||
var _b = __webpack_require__(/*! ./cache */ "../lib/cache.js"), codeBlockAndSpanRanges = _b.codeBlockAndSpanRanges, lineMetadata = _b.lineMetadata;
|
||||
var tabRe = /\t+/g;
|
||||
module.exports = {
|
||||
|
@ -2560,11 +2560,21 @@ module.exports = {
|
|||
"function": function MD010(params, onError) {
|
||||
var codeBlocks = params.config.code_blocks;
|
||||
var includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
var ignoreCodeLanguages = new Set((params.config.ignore_code_languages || [])
|
||||
.map(function (language) { return language.toLowerCase(); }));
|
||||
var spacesPerTab = params.config.spaces_per_tab;
|
||||
var spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
var exclusions = includeCode ? [] : codeBlockAndSpanRanges();
|
||||
filterTokens(params, "fence", function (token) {
|
||||
var language = token.info.trim().toLowerCase();
|
||||
if (ignoreCodeLanguages.has(language)) {
|
||||
for (var i = token.map[0] + 1; i < token.map[1] - 1; i++) {
|
||||
exclusions.push([i, 0, params.lines[i].length]);
|
||||
}
|
||||
}
|
||||
});
|
||||
forEachLine(lineMetadata(), function (line, lineIndex, inCode) {
|
||||
if (includeCode || !inCode) {
|
||||
var match = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue