Reimplement MD037/no-space-in-emphasis to better handle multiple fixes on a line and more scenarios (fixes #251).

This commit is contained in:
David Anson 2020-03-28 14:16:28 -07:00
parent de86a26e4e
commit 29f16bf402
4 changed files with 121 additions and 40 deletions

View file

@ -234,17 +234,22 @@ module.exports.getLineMetadata = function getLineMetadata(params) {
}
});
filterTokens(params, "list_item_open", function forToken(token) {
let count = 1;
for (let i = token.map[0]; i < token.map[1]; i++) {
lineMetadata[i][5] = true;
lineMetadata[i][5] = count;
count++;
}
});
filterTokens(params, "hr", function forToken(token) {
lineMetadata[token.map[0]][6] = true;
});
return lineMetadata;
};
// Calls the provided function for each line (with context)
module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
lineMetadata.forEach(function forMetadata(metadata) {
// Parameters: line, lineIndex, inCode, onFence, inTable
// Parameters: line, lineIndex, inCode, onFence, inTable, inBreak
handler(...metadata);
});
};