mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Update MD044/proper-names to add html_elements parameter (fixes #435).
This commit is contained in:
parent
8afec14376
commit
0f845e9ba1
15 changed files with 186 additions and 14 deletions
12
lib/md044.js
12
lib/md044.js
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
const { addErrorDetailIf, bareUrlRe, escapeForRegExp, forEachLine,
|
||||
forEachLink, overlapsAnyRange, linkReferenceRe } = require("../helpers");
|
||||
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
||||
const { codeBlockAndSpanRanges, htmlElementRanges, lineMetadata } =
|
||||
require("./cache");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD044", "proper-names" ],
|
||||
|
|
@ -15,7 +16,11 @@ module.exports = {
|
|||
names = Array.isArray(names) ? names : [];
|
||||
names.sort((a, b) => (b.length - a.length) || a.localeCompare(b));
|
||||
const codeBlocks = params.config.code_blocks;
|
||||
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
const includeCodeBlocks =
|
||||
(codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
const htmlElements = params.config.html_elements;
|
||||
const includeHtmlElements =
|
||||
(htmlElements === undefined) ? true : !!htmlElements;
|
||||
const exclusions = [];
|
||||
forEachLine(lineMetadata(), (line, lineIndex) => {
|
||||
if (linkReferenceRe.test(line)) {
|
||||
|
|
@ -37,6 +42,9 @@ module.exports = {
|
|||
if (!includeCodeBlocks) {
|
||||
exclusions.push(...codeBlockAndSpanRanges());
|
||||
}
|
||||
if (!includeHtmlElements) {
|
||||
exclusions.push(...htmlElementRanges());
|
||||
}
|
||||
for (const name of names) {
|
||||
const escapedName = escapeForRegExp(name);
|
||||
const startNamePattern = /^\W/.test(name) ? "" : "\\b_*";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue