File tree 3 files changed +41
-21
lines changed
3 files changed +41
-21
lines changed Original file line number Diff line number Diff line change @@ -91,20 +91,39 @@ export function parseMdContent(md: string): TutorialFrame | never {
91
91
content : stepContent . trim ( ) ,
92
92
} ;
93
93
} else {
94
- // parse hints from stepContent
95
94
const hintDetectRegex = / ^ ( # { 4 } \s H I N T S [ \n \r ] + ( [ \* | \- ] \s (?< hintContent > [ ^ ] * ) ) [ \n \r ] + ) + / ;
96
95
const hintMatch = section . match ( hintDetectRegex ) ;
97
- if ( ! ! hintMatch ) {
98
- const hintItemRegex = / [ \n \r ] + [ \* | \- ] \s / ;
99
- const hints = section
100
- . split ( hintItemRegex )
101
- . slice ( 1 ) // remove #### HINTS
102
- . map ( ( h ) => h . trim ( ) ) ;
103
- if ( hints . length ) {
104
- mdContent . levels [ current . levelIndex ] . steps [
105
- current . stepIndex
106
- ] . hints = hints ;
107
- }
96
+ const subtaskDetectRegex = / ^ ( # { 4 } \s S U B T A S K S [ \n \r ] + ( [ \* | \- ] \s (?< subtaskContent > [ ^ ] * ) ) [ \n \r ] + ) + / ;
97
+ const subtaskMatch = section . match ( subtaskDetectRegex ) ;
98
+ const listItemregex = / [ \n \r ] + [ \* | \- ] \s / ;
99
+
100
+ switch ( true ) {
101
+ // parse hints from stepContent
102
+ case ! ! hintMatch :
103
+ const hints = section
104
+ . split ( listItemregex )
105
+ . slice ( 1 ) // remove #### HINTS
106
+ . map ( ( h ) => h . trim ( ) ) ;
107
+ if ( hints . length ) {
108
+ mdContent . levels [ current . levelIndex ] . steps [
109
+ current . stepIndex
110
+ ] . hints = hints ;
111
+ }
112
+ return ;
113
+ // parse subtasks from stepContent
114
+ case ! ! subtaskMatch :
115
+ const subtasks = section
116
+ . split ( listItemregex )
117
+ . slice ( 1 ) // remove #### SUBTASKS
118
+ . map ( ( h ) => h . trim ( ) ) ;
119
+ if ( subtasks . length ) {
120
+ mdContent . levels [ current . levelIndex ] . steps [
121
+ current . stepIndex
122
+ ] . subtasks = subtasks ;
123
+ }
124
+ return ;
125
+ default :
126
+ console . warn ( `No build parser match found for:\n${ section } \n` ) ;
108
127
}
109
128
}
110
129
}
Original file line number Diff line number Diff line change @@ -1429,7 +1429,8 @@ Create a function \`add\` that can take a variety of params.
1429
1429
1430
1430
- Add one number
1431
1431
- Add two numbers
1432
- - Add three numbers` ;
1432
+ - Add three numbers
1433
+ ` ;
1433
1434
const skeleton = {
1434
1435
levels : [
1435
1436
{
@@ -1453,18 +1454,18 @@ Create a function \`add\` that can take a variety of params.
1453
1454
{
1454
1455
id : "1.1" ,
1455
1456
setup : {
1456
- subtasks : [
1457
- "Add one number" ,
1458
- "Add two numbers" ,
1459
- "Add three numbers" ,
1460
- ] ,
1461
1457
commits : [ "abcdef1" ] ,
1462
1458
} ,
1463
1459
content :
1464
1460
"Create a function `add` that can take a variety of params." ,
1465
1461
solution : {
1466
1462
commits : [ "abcdef2" ] ,
1467
1463
} ,
1464
+ subtasks : [
1465
+ "Add one number" ,
1466
+ "Add two numbers" ,
1467
+ "Add three numbers" ,
1468
+ ] ,
1468
1469
} ,
1469
1470
] ,
1470
1471
} ,
@@ -1478,7 +1479,7 @@ Create a function \`add\` that can take a variety of params.
1478
1479
"1.1:S" : [ "abcdef2" ] ,
1479
1480
} ,
1480
1481
} ) ;
1481
- expect ( result . levels ) . toEqual ( expected . levels ) ;
1482
+ expect ( result . levels [ 0 ] ) . toEqual ( expected . levels [ 0 ] ) ;
1482
1483
} ) ;
1483
1484
} ) ;
1484
1485
} ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export type Step = {
27
27
content : string ;
28
28
setup ?: StepActions ;
29
29
solution ?: Maybe < StepActions > ;
30
- subtasks ?: { [ testName : string ] : boolean } ;
30
+ subtasks ?: string [ ] ;
31
31
hints ?: string [ ] ;
32
32
} ;
33
33
@@ -52,7 +52,7 @@ export type StepActions = {
52
52
files ?: string [ ] ;
53
53
watchers ?: string [ ] ;
54
54
filter ?: string ;
55
- subtasks ?: boolean ;
55
+ subtasks ?: string [ ] ;
56
56
} ;
57
57
58
58
export interface TestRunnerArgs {
You can’t perform that action at this time.
0 commit comments