mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Support JSON front matter as used by the Hugo site generator (fixes #270).
This commit is contained in:
parent
47d82d6fd4
commit
bb157b2ce7
11 changed files with 60 additions and 7 deletions
|
@ -12,7 +12,7 @@ module.exports.newLineRe = newLineRe;
|
|||
// Regular expression for matching common front matter (YAML and TOML)
|
||||
module.exports.frontMatterRe =
|
||||
// eslint-disable-next-line max-len
|
||||
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m;
|
||||
/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$)|(^\{\s*$[^]*?^\}\s*$))(\r\n|\r|\n|$)/m;
|
||||
|
||||
// Regular expression for matching inline disable/enable comments
|
||||
const inlineCommentRe =
|
||||
|
@ -502,7 +502,10 @@ module.exports.frontMatterHasTitle =
|
|||
const ignoreFrontMatter =
|
||||
(frontMatterTitlePattern !== undefined) && !frontMatterTitlePattern;
|
||||
const frontMatterTitleRe =
|
||||
new RegExp(String(frontMatterTitlePattern || "^\\s*title\\s*[:=]"), "i");
|
||||
new RegExp(
|
||||
String(frontMatterTitlePattern || "^\\s*\"?title\"?\\s*[:=]"),
|
||||
"i"
|
||||
);
|
||||
return !ignoreFrontMatter &&
|
||||
frontMatterLines.some((line) => frontMatterTitleRe.test(line));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue