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(front-matter): remove os specific newline #5752

Merged

Conversation

timreichen
Copy link
Contributor

@timreichen timreichen commented Aug 20, 2024

Changes
This PR removes the os specific check for \r? before \n.

Reasoning
This is the only occurrence where a os check is done. Even the recognize() function in the same module doesn't do it:

const [firstLine] = str.split(/(\r?\n)/) as [string];

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (dea7d77) to head (edc6800).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5752      +/-   ##
==========================================
- Coverage   96.24%   96.23%   -0.01%     
==========================================
  Files         481      481              
  Lines       38751    38749       -2     
  Branches     5618     5617       -1     
==========================================
- Hits        37294    37290       -4     
- Misses       1415     1417       +2     
  Partials       42       42              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

The reasoning makes sense to me. But this is definitely not a chore. It's either a breaking change or refactor.

const NEWLINE = `${
globalThis?.Deno?.build?.os === "windows" ? "\\r?" : ""
}(?:\\n)?`;
const NEWLINE = "\\r?\\n?";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const NEWLINE = "\\r?\\n?";
const NEWLINE = "\\r?(?:\\n)?";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think these brackets don't do anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's merge as-is but keep this suggestion in mind in case anyone runs into any issues.

@timreichen timreichen changed the title chore(front-matter): remove os specific newline BREAKING(front-matter): remove os specific newline Aug 21, 2024
@kt3k
Copy link
Member

kt3k commented Aug 22, 2024

I don't think this breaks any existing practical usage as the condition is now more permissive (windows-style new line is now allowed in linux and mac).

How about tagging this as 'fix'?

@kt3k kt3k changed the title BREAKING(front-matter): remove os specific newline fix(front-matter): remove os specific newline Aug 22, 2024
@iuioiua
Copy link
Collaborator

iuioiua commented Aug 22, 2024

It's more permissive but changes expected behavior depending on the OS, no?

@kt3k
Copy link
Member

kt3k commented Aug 22, 2024

If we change the parsing behavior depending on the platform, that means the users can't share the exact same markdown files between different platforms (e.g. If windows user creates a markdown file with front-matter with CRLF, then that file can't be parsed in mac/linux). I don't think that meets the expectation of the users.

@iuioiua iuioiua enabled auto-merge (squash) August 22, 2024 07:36
@iuioiua iuioiua disabled auto-merge August 22, 2024 07:36
@iuioiua iuioiua merged commit 9be9eae into denoland:main Aug 22, 2024
16 checks passed
@timreichen timreichen deleted the front_matter-remove-os-specific-newline branch August 24, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants