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

fix: frontmatter parsing in windows (CLRF) #2631

Closed
wants to merge 2 commits into from

Conversation

bukowa
Copy link
Contributor

@bukowa bukowa commented Jul 9, 2024

fixes #2628

It's not pretty but it works. ^^

Copy link
Collaborator

@Gerrit0 Gerrit0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this a bit nicer + more robust by using a regex to extract the frontmatter.

If we use firstBlock.text.match(/^(---\r?\n)([\s\S]+)(\r?\n---\r?\n)/), we'll either have a returned object with how much we need to skip when reporting error positions (match[1].length), the yaml text to parse (match[2].length) and the new start position of the first block (match[0].length), or no object, in which case there wasn't frontmatter. Thoughts?

This will also handle the issue where a file has mixed line endings, as some people don't normalize those...

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 10, 2024

I spent a bit more time looking at this... and turns out that earlier assumption was bad because of eemeli/yaml#127, I ended up pulling your branch to play around with how to fix that, and fixed it another way..

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 10, 2024

I wasn't thinking, so rebased when looking at this locally instead of merging... merged with:

21cf5ae
ef0f26e

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

Successfully merging this pull request may close these issues.

Line endings on windows break frontmatter in projectDocuments CLRF
2 participants