mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add getHtmlAttributeRe helper for creating a RegExp to match an HTML attribute name/value.
This commit is contained in:
parent
531e58ed9a
commit
06466905a5
4 changed files with 36 additions and 15 deletions
|
|
@ -126,6 +126,16 @@ function cloneIfUrl(url) {
|
|||
}
|
||||
module.exports.cloneIfUrl = cloneIfUrl;
|
||||
|
||||
/**
|
||||
* Gets a Regular Expression for matching the specified HTML attribute.
|
||||
*
|
||||
* @param {string} name HTML attribute name.
|
||||
* @returns {RegExp} Regular Expression for matching.
|
||||
*/
|
||||
module.exports.getHtmlAttributeRe = function getHtmlAttributeRe(name) {
|
||||
return new RegExp(`\\s${name}\\s*=\\s*['"]?([^'"\\s>]*)`, "iu");
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true iff the input line is blank (contains nothing, whitespace, or
|
||||
* comments (unclosed start/end comments allowed)).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue