Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces after yaml document start cause parse failure #53

Open
jayvdb opened this issue Nov 1, 2017 · 6 comments
Open

Spaces after yaml document start cause parse failure #53

jayvdb opened this issue Nov 1, 2017 · 6 comments

Comments

@jayvdb
Copy link

jayvdb commented Nov 1, 2017

YAML spec allows spaces after the ---

The regex used by this package prevents that.

@wild-flame
Copy link
Contributor

I too encounterd with this problem

This can be fixed be changing var pattern to

var pattern = '^(' +
  optionalByteOrderMark +
  '(= yaml =|---)' +
  '$([\\s\\S]*?)' +
  '^(?:\\2|\\.\\.\\.)\\s*' +
  '$' +
  (process.platform === 'win32' ? '\\r?' : '') +
  '(?:\\n)?)'

@gr2m
Copy link

gr2m commented Sep 24, 2024

Hello from @github 👋🏼 The blog team is using this library, thank you so much!

Just wondering if you'd accept a pull request that fixes it? I can't promise when but I'd be happy to submit one, or try to find someone else you would.

@jayvdb
Copy link
Author

jayvdb commented Sep 24, 2024

Probably was fixed by #54

@gr2m
Copy link

gr2m commented Sep 24, 2024

We ran into it today, using the latest version (4.0.2), so I think it's not quite fixed?

@gr2m
Copy link

gr2m commented Sep 24, 2024

Here is a test case to reproduce the problem

const frontMatter = require("front-matter"); // v4.0.2

const markdownContent = `---  
foo: bar
---

content`;

console.log(frontMatter(markdownContent));

// {
//   attributes: {},
//   body: '---  \nfoo: bar\n---\n\ncontent',
//   bodyBegin: 1
// }

@jxson
Copy link
Owner

jxson commented Sep 24, 2024

Hi @gr2m,

I'll definitely take pull requests, especially if it includes a test ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants