[GH-ISSUE #153] YAML Front Matter Regex Not Handling Pandoc Mixed Fencing #1981

Closed
opened 2026-03-07 20:03:23 +03:00 by kerem · 2 comments
Owner

Originally created by @jason-dour on GitHub (Nov 5, 2018).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/153

Right or wrong, Pandoc promotes the use of mixed fencing on YAML Front Matter. Throughout their documentation, they promote the following front matter style:

---
title: Blah
yadda: Foo
...

Which triggers rule MD041 to not recognize the front matter. As I dove in further, I don't think it is MD041 itself being triggered (no amount of options settings of front_matter_title made a difference), but the recognition of the front matter as existing thanks to:

shared.js:9-10

// Regular expression for matching common front matter (YAML and TOML)
module.exports.frontMatterRe = /^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n)/m;

Whereas, if I tweak that regex to be the following, Pandoc front matter is recognized appropriately:

shared.js:9-10

// Regular expression for matching common front matter (YAML and TOML)
module.exports.frontMatterRe = /^([-]{3}|[+]{3}|[.]{3})$[\s\S]+^([-]{3}|[+]{3}|[.]{3})$/m;

I don't know if Pandoc YAML FM is important enough to modify this in your release codebase. Just figured I'd share what I found. Thanks.

Originally created by @jason-dour on GitHub (Nov 5, 2018). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/153 Right or wrong, Pandoc promotes the use of mixed fencing on YAML Front Matter. Throughout their documentation, they promote the following front matter style: ``` YAML --- title: Blah yadda: Foo ... ``` Which triggers rule MD041 to not recognize the front matter. As I dove in further, I don't think it is MD041 itself being triggered (no amount of options settings of `front_matter_title` made a difference), but the recognition of the front matter as existing thanks to: `shared.js:9-10` ``` javascript // Regular expression for matching common front matter (YAML and TOML) module.exports.frontMatterRe = /^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n)/m; ``` Whereas, if I tweak that regex to be the following, Pandoc front matter is recognized appropriately: `shared.js:9-10` ``` javascript // Regular expression for matching common front matter (YAML and TOML) module.exports.frontMatterRe = /^([-]{3}|[+]{3}|[.]{3})$[\s\S]+^([-]{3}|[+]{3}|[.]{3})$/m; ``` I don't know if Pandoc YAML FM is important enough to modify this in your release codebase. Just figured I'd share what I found. Thanks.
kerem 2026-03-07 20:03:23 +03:00
Author
Owner

@DavidAnson commented on GitHub (Nov 5, 2018):

Why, Pandoc, why?

<!-- gh-comment-id:435952357 --> @DavidAnson commented on GitHub (Nov 5, 2018): Why, Pandoc, why?
Author
Owner

@jason-dour commented on GitHub (Nov 5, 2018):

I don't know. I don't make the "standards"; I just get impacted by them. 😄

<!-- gh-comment-id:435998549 --> @jason-dour commented on GitHub (Nov 5, 2018): I don't know. I don't make the _"standards"_; I just get impacted by them. 😄
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#1981
No description provided.