mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +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
|
|
@ -19,7 +19,8 @@ const inlineCommentStartRe =
|
|||
module.exports.inlineCommentStartRe = inlineCommentStartRe;
|
||||
|
||||
// Regular expression for matching HTML elements
|
||||
module.exports.htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g;
|
||||
const htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g;
|
||||
module.exports.htmlElementRe = htmlElementRe;
|
||||
|
||||
// Regular expressions for range matching
|
||||
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*(?:\/|[^\s\]"'\W])/ig;
|
||||
|
|
@ -603,6 +604,25 @@ module.exports.codeBlockAndSpanRanges = (params, lineMetadata) => {
|
|||
return exclusions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of HTML element ranges.
|
||||
*
|
||||
* @param {Object} params RuleParams instance.
|
||||
* @param {Object} lineMetadata Line metadata object.
|
||||
* @returns {number[][]} Array of ranges (lineIndex, columnIndex, length).
|
||||
*/
|
||||
module.exports.htmlElementRanges = (params, lineMetadata) => {
|
||||
const exclusions = [];
|
||||
forEachLine(lineMetadata, (line, lineIndex, inCode) => {
|
||||
let match = null;
|
||||
// eslint-disable-next-line no-unmodified-loop-condition
|
||||
while (!inCode && ((match = htmlElementRe.exec(line)) !== null)) {
|
||||
exclusions.push([ lineIndex, match.index, match[0].length ]);
|
||||
}
|
||||
});
|
||||
return exclusions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the specified range overlaps another range.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue