From 0bb38faa21c851f201bb6f85c710cfedac76a9c3 Mon Sep 17 00:00:00 2001 From: David Anson Date: Sun, 6 Jan 2019 22:20:59 -0800 Subject: [PATCH] Handle files with front matter only and no trailing newline (fixes #157). --- lib/shared.js | 2 +- test/front-matter-no-crlf.json | 4 ++++ test/front-matter-no-crlf.md | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/front-matter-no-crlf.json create mode 100644 test/front-matter-no-crlf.md diff --git a/lib/shared.js b/lib/shared.js index cd10c760..e7d063b3 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -7,7 +7,7 @@ module.exports.newLineRe = /\r[\n\u0085]?|[\n\u2424\u2028\u0085]/; // Regular expression for matching common front matter (YAML and TOML) -module.exports.frontMatterRe = /^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n)/m; +module.exports.frontMatterRe = /^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n|$)/m; // Regular expression for matching inline disable/enable comments const inlineCommentRe = diff --git a/test/front-matter-no-crlf.json b/test/front-matter-no-crlf.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/front-matter-no-crlf.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/front-matter-no-crlf.md b/test/front-matter-no-crlf.md new file mode 100644 index 00000000..84613604 --- /dev/null +++ b/test/front-matter-no-crlf.md @@ -0,0 +1,3 @@ +--- +front: matter +--- \ No newline at end of file