Movatterモバイル変換


[0]ホーム

URL:


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

Commita00362b

Browse files
authored
Merge pull requestcoderoad#49 from coderoad/fix/parse-hints
Fix/parse hints
2 parents2d49042 +2571711 commita00362b

File tree

2 files changed

+83
-19
lines changed

2 files changed

+83
-19
lines changed

‎src/utils/parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function parseMdContent(md: string): TutorialFrame | never {
8686
consthintDetectRegex=/^(#{4}\sHINTS[\n\r]+([\*|\-]\s(?<hintContent>[^]*))[\n\r]+)+/;
8787
consthintMatch=section.match(hintDetectRegex);
8888
if(!!hintMatch){
89-
consthintItemRegex=/[\n\r]+\*\s/;
89+
consthintItemRegex=/[\n\r]+[\*|\-]\s/;
9090
consthints=section
9191
.split(hintItemRegex)
9292
.slice(1)// remove #### HINTS

‎tests/parse.test.ts

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ The first step
299299
text:md,
300300
skeleton,
301301
commits:{
302-
"1.1Q":["abcdefg1"],
302+
"1.1:T":["abcdefg1"],
303303
},
304304
});
305305
constexpected={
@@ -355,7 +355,7 @@ The first step
355355
text:md,
356356
skeleton,
357357
commits:{
358-
"1.1Q":["abcdefg1","123456789"],
358+
"1.1:T":["abcdefg1","123456789"],
359359
},
360360
});
361361
constexpected={
@@ -465,7 +465,7 @@ Another line
465465
skeleton,
466466
commits:{
467467
"1":["abcdefg1"],
468-
"1.1Q":["12345678"],
468+
"1.1:T":["12345678"],
469469
},
470470
});
471471
constexpected={
@@ -519,8 +519,8 @@ The first step
519519
text:md,
520520
skeleton,
521521
commits:{
522-
"1.1Q":["abcdefg1","123456789"],
523-
"1.1A":["1gfedcba","987654321"],
522+
"1.1:T":["abcdefg1","123456789"],
523+
"1.1:S":["1gfedcba","987654321"],
524524
},
525525
});
526526
constexpected={
@@ -644,12 +644,12 @@ The third step
644644
text:md,
645645
skeleton,
646646
commits:{
647-
"1.1Q":["abcdef1","123456789"],
648-
"1.1A":["1fedcba","987654321"],
649-
"1.2Q":["2abcdef"],
650-
"1.2A":["3abcdef"],
651-
"2.1Q":["4abcdef"],
652-
"2.1A":["5abcdef"],
647+
"1.1:T":["abcdef1","123456789"],
648+
"1.1:S":["1fedcba","987654321"],
649+
"1.2:T":["2abcdef"],
650+
"1.2:S":["3abcdef"],
651+
"2.1:T":["4abcdef"],
652+
"2.1:S":["5abcdef"],
653653
},
654654
});
655655
constexpected={
@@ -759,7 +759,7 @@ The first step
759759
text:md,
760760
skeleton,
761761
commits:{
762-
"1.1Q":["abcdef1","123456789"],
762+
"1.1:T":["abcdef1","123456789"],
763763
},
764764
});
765765
constexpected={
@@ -936,7 +936,7 @@ Description.
936936
});
937937

938938
describe("hints",()=>{
939-
it("should parse hints for a step",()=>{
939+
it("should parse hints for a step with '*",()=>{
940940
constmd=`# Title
941941
942942
Description.
@@ -971,7 +971,71 @@ The first step
971971
text:md,
972972
skeleton,
973973
commits:{
974-
"1.1Q":["abcdef1","123456789"],
974+
"1.1:T":["abcdef1","123456789"],
975+
},
976+
});
977+
constexpected={
978+
summary:{
979+
description:"Description.",
980+
},
981+
levels:[
982+
{
983+
id:"1",
984+
title:"Title 1",
985+
summary:"First level content.",
986+
content:"First level content.",
987+
steps:[
988+
{
989+
id:"1.1",
990+
content:"The first step",
991+
setup:{
992+
commits:["abcdef1","123456789"],
993+
},
994+
hints:["First Hint","Second Hint"],
995+
},
996+
],
997+
},
998+
],
999+
};
1000+
expect(result.levels).toEqual(expected.levels);
1001+
});
1002+
1003+
it("should parse hints for a step with '-'",()=>{
1004+
constmd=`# Title
1005+
1006+
Description.
1007+
1008+
## 1. Title 1
1009+
1010+
First level content.
1011+
1012+
### 1.1
1013+
1014+
The first step
1015+
1016+
#### HINTS
1017+
1018+
- First Hint
1019+
- Second Hint
1020+
1021+
`;
1022+
constskeleton={
1023+
levels:[
1024+
{
1025+
id:"1",
1026+
steps:[
1027+
{
1028+
id:"1.1",
1029+
},
1030+
],
1031+
},
1032+
],
1033+
};
1034+
constresult=parse({
1035+
text:md,
1036+
skeleton,
1037+
commits:{
1038+
"1.1:T":["abcdef1","123456789"],
9751039
},
9761040
});
9771041
constexpected={
@@ -1040,7 +1104,7 @@ And spans multiple lines.
10401104
text:md,
10411105
skeleton,
10421106
commits:{
1043-
"1.1Q":["abcdef1","123456789"],
1107+
"1.1:T":["abcdef1","123456789"],
10441108
},
10451109
});
10461110
constexpected={
@@ -1119,9 +1183,9 @@ The second uninterrupted step
11191183
text:md,
11201184
skeleton,
11211185
commits:{
1122-
"1.1Q":["abcdef1"],
1123-
"1.1A":["123456789"],
1124-
"1.2Q":["fedcba1"],
1186+
"1.1:T":["abcdef1"],
1187+
"1.1:S":["123456789"],
1188+
"1.2:T":["fedcba1"],
11251189
},
11261190
});
11271191
constexpected={

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp