Skip to content

Commit cdbe136

Browse files
committed
Fix some Windows issues with path and regex
1 parent e07e51e commit cdbe136

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/parse.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ function parseContent(md) {
3030
const sections = {};
3131

3232
// Identify and remove the header
33-
const summaryMatch = parts.shift().match(/^#\s(?<tutorialTitle>.*)\n+(?<tutorialDescription>[^]*)/);
33+
const summaryMatch = parts.shift().match(/^#\s(?<tutorialTitle>.*)[\n\r]+(?<tutorialDescription>[^]*)/);
3434

3535
sections['summary'] = {
36-
title: summaryMatch.groups.tutorialTitle,
37-
description: summaryMatch.groups.tutorialDescription,
36+
title: summaryMatch.groups.tutorialTitle.trim(),
37+
description: summaryMatch.groups.tutorialDescription.trim(),
3838
};
3939

4040
// Identify each part of the content
4141
parts.forEach(section => {
42-
const levelRegex = /^(##\s(?<levelId>L\d+)\s(?<levelTitle>.*)\n*(>\s*(?<levelSummary>.*))?\n+(?<levelContent>[^]*))/;
43-
const stepRegex = /^(###\s(?<stepId>(?<levelId>L\d+)S\d+)\s(?<stepTitle>.*)\n+(?<stepContent>[^]*))/;
42+
const levelRegex = /^(##\s(?<levelId>L\d+)\s(?<levelTitle>.*)[\n\r]*(>\s+(?<levelSummary>.*))?[\n\r]+(?<levelContent>[^]*))/;
43+
const stepRegex = /^(###\s(?<stepId>(?<levelId>L\d+)S\d+)\s(?<stepTitle>.*)[\n\r]+(?<stepContent>[^]*))/;
4444

4545
const levelMatch = section.match(levelRegex);
4646
const stepMatch = section.match(stepRegex);
@@ -50,8 +50,8 @@ function parseContent(md) {
5050
[levelMatch.groups.levelId]: {
5151
id: levelMatch.groups.levelId,
5252
title: levelMatch.groups.levelTitle,
53-
summary: levelMatch.groups.levelSummary,
54-
content: levelMatch.groups.levelContent,
53+
summary: levelMatch.groups.levelSummary.trim(),
54+
content: levelMatch.groups.levelContent.trim(),
5555
}
5656
};
5757

@@ -66,7 +66,7 @@ function parseContent(md) {
6666
[stepMatch.groups.stepId]: {
6767
id: stepMatch.groups.stepId,
6868
// title: stepMatch.groups.stepTitle, //Not using at this momemnt
69-
content: stepMatch.groups.stepContent
69+
content: stepMatch.groups.stepContent.trim()
7070
}
7171
}
7272
}

0 commit comments

Comments
 (0)