@@ -45,20 +45,25 @@ export function parseMdContent(md: string): TutorialFrame | never {
4545mdContent . summary . description = summaryMatch . groups . tutorialDescription . trim ( ) ;
4646}
4747
48- let current = { level : - 1 , step :- 1 } ;
48+ let current = { levelId : "" , levelIndex : - 1 , stepIndex :- 1 } ;
4949// Identify each part of the content
5050parts . forEach ( ( section :string ) => {
5151// match level
5252const levelRegex = / ^ ( # { 2 } \s (?< levelId > L ? \d + \. ? ) \s (?< levelTitle > .* ) [ \n \r ] * ( > \s (?< levelSummary > .* ) ) ? [ \n \r ] + (?< levelContent > [ ^ ] * ) ) / ;
5353const levelMatch :RegExpMatchArray | null = section . match ( levelRegex ) ;
5454
5555if ( levelMatch && levelMatch . groups ) {
56- current = { level :current . level + 1 , step :- 1 } ;
56+ const levelId = levelMatch . groups . levelId . replace ( "." , "" ) ;
57+ current = {
58+ levelId :levelId ,
59+ levelIndex :current . levelIndex + 1 ,
60+ stepIndex :- 1 ,
61+ } ;
5762const { levelTitle, levelSummary, levelContent} = levelMatch . groups ;
5863
5964//@ts -ignore
60- mdContent . levels [ current . level ] = {
61- id :( current . level + 1 ) . toString ( ) ,
65+ mdContent . levels [ current . levelIndex ] = {
66+ id :levelId ,
6267title :levelTitle . trim ( ) ,
6368summary :
6469levelSummary && levelSummary . trim ( ) . length
@@ -75,10 +80,14 @@ export function parseMdContent(md: string): TutorialFrame | never {
7580const stepRegex = / ^ ( # { 3 } \s (?< stepTitle > .* ) [ \n \r ] + (?< stepContent > [ ^ ] * ) ) / ;
7681const stepMatch :RegExpMatchArray | null = section . match ( stepRegex ) ;
7782if ( stepMatch && stepMatch . groups ) {
78- current = { level :current . level , step :current . step + 1 } ;
83+ current = {
84+ levelId :current . levelId ,
85+ levelIndex :current . levelIndex ,
86+ stepIndex :current . stepIndex + 1 ,
87+ } ;
7988const { stepId, stepContent} = stepMatch . groups ;
80- mdContent . levels [ current . level ] . steps [ current . step ] = {
81- id :`${ current . level + 1 } .${ current . step + 1 } ` ,
89+ mdContent . levels [ current . levelIndex ] . steps [ current . stepIndex ] = {
90+ id :`${ current . levelId } .${ current . stepIndex + 1 } ` ,
8291content :stepContent . trim ( ) ,
8392} ;
8493} else {
@@ -92,7 +101,9 @@ export function parseMdContent(md: string): TutorialFrame | never {
92101. slice ( 1 ) // remove #### HINTS
93102. map ( ( h ) => h . trim ( ) ) ;
94103if ( hints . length ) {
95- mdContent . levels [ current . level ] . steps [ current . step ] . hints = hints ;
104+ mdContent . levels [ current . levelIndex ] . steps [
105+ current . stepIndex
106+ ] . hints = hints ;
96107}
97108}
98109}