diff --git a/lib/md041.js b/lib/md041.js index 1d29be53..c34b4950 100644 --- a/lib/md041.js +++ b/lib/md041.js @@ -14,17 +14,14 @@ module.exports = { const tag = "h" + level; const frontMatterTitleRe = new RegExp(frontMatterTitle || "^\\s*title\\s*[:=]", "i"); - params.tokens.every(function forToken(token, index) { - if (token.type === "heading_open") { - if (!((token.lineNumber === 1) || (index > 0)) || - (token.tag !== tag)) { + params.tokens.every(function forToken(token) { + if (token.type === "html_block") { + return true; + } else if (token.type === "heading_open") { + if (token.tag !== tag) { shared.addErrorContext(onError, token.lineNumber, token.line); } - return false; - } else if (token.type === "html_block") { - return true; - } - if (((frontMatterTitle !== undefined) && !frontMatterTitle) || + } else if (((frontMatterTitle !== undefined) && !frontMatterTitle) || !params.frontMatterLines.some(function forLine(line) { return frontMatterTitleRe.test(line); })) { diff --git a/test/hugo-quickstart-example-issue.json b/test/hugo-quickstart-example-blank.json similarity index 100% rename from test/hugo-quickstart-example-issue.json rename to test/hugo-quickstart-example-blank.json diff --git a/test/hugo-quickstart-example-issue.md b/test/hugo-quickstart-example-blank.md similarity index 77% rename from test/hugo-quickstart-example-issue.md rename to test/hugo-quickstart-example-blank.md index 1bfb15ba..a0e98dc9 100644 --- a/test/hugo-quickstart-example-issue.md +++ b/test/hugo-quickstart-example-blank.md @@ -1,8 +1,8 @@ -+++ -date = "2016-02-14T16:11:58+05:30" -draft = true -title = "Good to Great Book Review" - -+++ - -# Heading 1 {MD041} ++++ +date = "2016-02-14T16:11:58+05:30" +draft = true +title = "Good to Great Book Review" + ++++ + +# Heading 1 diff --git a/test/md041-yaml-title-and-first-line-heading.json b/test/md041-yaml-title-and-first-line-heading.json new file mode 100644 index 00000000..e8e56758 --- /dev/null +++ b/test/md041-yaml-title-and-first-line-heading.json @@ -0,0 +1,9 @@ +{ + "default": true, + "MD002": { + "level": 2 + }, + "MD041": { + "level": 2 + } +} diff --git a/test/md041-yaml-title-and-first-line-heading.md b/test/md041-yaml-title-and-first-line-heading.md new file mode 100644 index 00000000..8f512b19 --- /dev/null +++ b/test/md041-yaml-title-and-first-line-heading.md @@ -0,0 +1,7 @@ +--- +path: "/post" +date: "2012-06-21T10:14:00.000+02:00" +title: "First level heading" +--- + +## Second level heading