Add code_blocks parameter to MD010 to ignore hard tabs in code blocks (fixes #31).

This commit is contained in:
David Anson 2016-09-29 21:25:10 -07:00
parent c2982e2972
commit a2df7742c6
6 changed files with 87 additions and 3 deletions

View file

@ -328,8 +328,10 @@ module.exports = [
"tags": [ "whitespace", "hard_tab" ],
"aliases": [ "no-hard-tabs" ],
"func": function MD010(params, errors) {
params.lines.forEach(function forLine(line, lineIndex) {
if (/\t/.test(line)) {
var codeBlocks = params.options.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
forEachLine(params, function forLine(line, lineIndex, inCode) {
if (/\t/.test(line) && (!inCode || includeCodeBlocks)) {
errors.push(lineIndex + 1);
}
});