-
-
Notifications
You must be signed in to change notification settings - Fork 130
Adding support for CRLF in the parser #189
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,10 @@ function raise(issue, snippet = '') { | |
return null; | ||
} | ||
|
||
const crlfRegex = /\r\n/gm; | ||
const propertyRegex = /^\s+([a-zA-Z]+):\s*(.+)/; | ||
const headerEndCodeStartRegex = /^\s*---\s*```.*\n/; | ||
const headerEndCodeStartRegex = /^\s*---\s*```.*\r?\n/; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's rarely used anymore but some systems (I think macs) used to use CR or \r for new line. Should we add support for that also? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should worry about that, otherwise everything is going to get complicated, really quickly |
||
const codeRegex = /^(.+)```/s | ||
function parseSnippet(path, name, text) { | ||
if(crlfRegex.exec(text) !== null) return raise('Found CRLF line endings instead of LF line endings', path); | ||
let cursor = 0; | ||
|
||
const fromCursor = () => text.substring(cursor); | ||
|
@@ -68,7 +66,7 @@ function parseSnippet(path, name, text) { | |
author: properties.author, | ||
tags: properties.tags.split(',').map((tag) => tag.trim()).filter((tag) => tag), | ||
contributors: 'contributors' in properties ? properties.contributors.split(',').map((contributor) => contributor.trim()).filter((contributor) => contributor) : [], | ||
code: code, | ||
code: code.replace(/\r\n/g, '\n'), | ||
} | ||
} | ||
|
||
|