Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 87706b4

Browse files
Merge pull request #189 from Mathys-Gasnier/main
Adding support for CRLF in the parser
2 parents 8508752 + 581ae00 commit 87706b4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

‎utils/snippetParser.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ function raise(issue, snippet = '') {
2727
return null;
2828
}
2929

30-
const crlfRegex = /\r\n/gm;
3130
const propertyRegex = /^\s+([a-zA-Z]+):\s*(.+)/;
32-
const headerEndCodeStartRegex = /^\s*---\s*```.*\n/;
31+
const headerEndCodeStartRegex = /^\s*---\s*```.*\r?\n/;
3332
const codeRegex = /^(.+)```/s
3433
function parseSnippet(path, name, text) {
35-
if(crlfRegex.exec(text) !== null) return raise('Found CRLF line endings instead of LF line endings', path);
3634
let cursor = 0;
3735

3836
const fromCursor = () => text.substring(cursor);
@@ -68,7 +66,7 @@ function parseSnippet(path, name, text) {
6866
author: properties.author,
6967
tags: properties.tags.split(',').map((tag) => tag.trim()).filter((tag) => tag),
7068
contributors: 'contributors' in properties ? properties.contributors.split(',').map((contributor) => contributor.trim()).filter((contributor) => contributor) : [],
71-
code: code,
69+
code: code.replace(/\r\n/g,'\n'),
7270
}
7371
}
7472

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /