Add spaces_per_tab parameter to MD010/no-hard-tabs (fixes #384). (#385)

This commit is contained in:
Yash Singh 2021-04-09 16:33:01 -07:00 committed by GitHub
parent 6302b26c99
commit 47ff95e8d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 157 additions and 4 deletions

View file

@ -14,6 +14,10 @@ module.exports = {
"function": function MD010(params, onError) {
const codeBlocks = params.config.code_blocks;
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
const spacesPerTab = params.config.spaces_per_tab;
const spaceMultiplier = (spacesPerTab === undefined) ?
1 :
Math.max(0, Number(spacesPerTab));
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
if (!inCode || includeCodeBlocks) {
let match = null;
@ -29,7 +33,7 @@ module.exports = {
{
"editColumn": column,
"deleteCount": length,
"insertText": "".padEnd(length)
"insertText": "".padEnd(length * spaceMultiplier)
});
}
}