File tree Expand file tree Collapse file tree 3 files changed +41
-21
lines changed Expand file tree Collapse file tree 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 {
9191 content : stepContent . trim ( ) ,
9292 } ;
9393 } else {
94- // parse hints from stepContent
9594 const hintDetectRegex = / ^ ( # { 4 } \s H I N T S [ \n \r ] + ( [ \* | \- ] \s (?< hintContent > [ ^ ] * ) ) [ \n \r ] + ) + / ;
9695 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` ) ;
108127 }
109128 }
110129 }
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.
14291429
14301430- Add one number
14311431- Add two numbers
1432- - Add three numbers` ;
1432+ - Add three numbers
1433+ ` ;
14331434 const skeleton = {
14341435 levels : [
14351436 {
@@ -1453,18 +1454,18 @@ Create a function \`add\` that can take a variety of params.
14531454 {
14541455 id : "1.1" ,
14551456 setup : {
1456- subtasks : [
1457- "Add one number" ,
1458- "Add two numbers" ,
1459- "Add three numbers" ,
1460- ] ,
14611457 commits : [ "abcdef1" ] ,
14621458 } ,
14631459 content :
14641460 "Create a function `add` that can take a variety of params." ,
14651461 solution : {
14661462 commits : [ "abcdef2" ] ,
14671463 } ,
1464+ subtasks : [
1465+ "Add one number" ,
1466+ "Add two numbers" ,
1467+ "Add three numbers" ,
1468+ ] ,
14681469 } ,
14691470 ] ,
14701471 } ,
@@ -1478,7 +1479,7 @@ Create a function \`add\` that can take a variety of params.
14781479 "1.1:S" : [ "abcdef2" ] ,
14791480 } ,
14801481 } ) ;
1481- expect ( result . levels ) . toEqual ( expected . levels ) ;
1482+ expect ( result . levels [ 0 ] ) . toEqual ( expected . levels [ 0 ] ) ;
14821483 } ) ;
14831484 } ) ;
14841485} ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export type Step = {
2727 content : string ;
2828 setup ?: StepActions ;
2929 solution ?: Maybe < StepActions > ;
30- subtasks ?: { [ testName : string ] : boolean } ;
30+ subtasks ?: string [ ] ;
3131 hints ?: string [ ] ;
3232} ;
3333
@@ -52,7 +52,7 @@ export type StepActions = {
5252 files ?: string [ ] ;
5353 watchers ?: string [ ] ;
5454 filter ?: string ;
55- subtasks ?: boolean ;
55+ subtasks ?: string [ ] ;
5656} ;
5757
5858export interface TestRunnerArgs {
You can’t perform that action at this time.
0 commit comments