@@ -52,7 +52,7 @@ export function parseMdContent(md: string): TutorialFrame | never {
5252// Identify each part of the content
5353parts . forEach ( ( section :string ) => {
5454// match level
55- const levelRegex = / ^ ( # # \s (?< levelId > L \d + ) \s (?< levelTitle > .* ) [ \n \r ] * ( > \s * (?< levelSummary > .* ) ) ? [ \n \r ] + (?< levelContent > [ ^ ] * ) ) / ;
55+ const levelRegex = / ^ ( # { 2 } \s (?< levelId > L \d + ) \s (?< levelTitle > .* ) [ \n \r ] * ( > \s * (?< levelSummary > .* ) ) ? [ \n \r ] + (?< levelContent > [ ^ ] * ) ) / ;
5656const levelMatch :RegExpMatchArray | null = section . match ( levelRegex ) ;
5757if ( levelMatch && levelMatch . groups ) {
5858const {
@@ -73,10 +73,18 @@ export function parseMdContent(md: string): TutorialFrame | never {
7373} ;
7474} else {
7575// match step
76- const stepRegex = / ^ ( # # # \s (?< stepId > (?< levelId > L \d + ) S \d + ) \s (?< stepTitle > .* ) [ \n \r ] + (?< stepContent > [ ^ ] * ) ) / ;
76+ const stepRegex = / ^ ( # { 3 } \s (?< stepId > (?< levelId > L \d + ) S \d + ) \s (?< stepTitle > .* ) [ \n \r ] + (?< stepContent > [ ^ ] * ) ) / ;
7777const stepMatch :RegExpMatchArray | null = section . match ( stepRegex ) ;
7878if ( stepMatch && stepMatch . groups ) {
7979const { stepId, stepContent} = stepMatch . groups ;
80+
81+ // parse hints from stepContent
82+ // const hintRegex = /^(#{4}\sHINTS[\n\r]+(?<hintContent>[^]*))/g;
83+
84+ // if (!!stepContent.match(hintRegex)) {
85+ // console.log("HAS HINT");
86+ // }
87+
8088mdContent . steps [ stepId ] = {
8189id :stepId ,
8290content :stepContent . trim ( ) ,
@@ -135,39 +143,45 @@ export function parse(params: ParseParams): any {
135143}
136144
137145// add level step commits
138- level . steps = ( level . steps || [ ] ) . map (
139- ( step :T . Step , stepIndex :number ) => {
140- const stepKey = `${ levelSetupKey } S${ stepIndex + 1 } ` ;
141- const stepSetupKey = `${ stepKey } Q` ;
142- if ( params . commits [ stepSetupKey ] ) {
143- if ( ! step . setup ) {
144- step . setup = {
145- commits :[ ] ,
146- } ;
146+ try {
147+ level . steps = ( level . steps || [ ] ) . map (
148+ ( step :T . Step , stepIndex :number ) => {
149+ const stepKey = `${ levelSetupKey } S${ stepIndex + 1 } ` ;
150+ const stepSetupKey = `${ stepKey } Q` ;
151+ if ( params . commits [ stepSetupKey ] ) {
152+ if ( ! step . setup ) {
153+ step . setup = {
154+ commits :[ ] ,
155+ } ;
156+ }
157+ step . setup . commits = params . commits [ stepSetupKey ] ;
147158}
148- step . setup . commits = params . commits [ stepSetupKey ] ;
149- }
150159
151- const stepSolutionKey = `${ stepKey } A` ;
152- if ( params . commits [ stepSolutionKey ] ) {
153- if ( ! step . solution ) {
154- step . solution = {
155- commits :[ ] ,
156- } ;
160+ const stepSolutionKey = `${ stepKey } A` ;
161+ if ( params . commits [ stepSolutionKey ] ) {
162+ if ( ! step . solution ) {
163+ step . solution = {
164+ commits :[ ] ,
165+ } ;
166+ }
167+ step . solution . commits = params . commits [ stepSolutionKey ] ;
157168}
158- step . solution . commits = params . commits [ stepSolutionKey ] ;
159- }
160169
161- // add markdown
162- const stepMarkdown :Partial < T . Step > = mdContent . steps [ step . id ] ;
163- if ( stepMarkdown ) {
164- step = { ...step , ...stepMarkdown } ;
165- }
170+ // add markdown
171+ const stepMarkdown :Partial < T . Step > = mdContent . steps [ step . id ] ;
172+ if ( stepMarkdown ) {
173+ step = { ...step , ...stepMarkdown } ;
174+ }
166175
167- step . id = `${ stepKey } ` ;
168- return step ;
169- }
170- ) ;
176+ step . id = `${ stepKey } ` ;
177+ return step ;
178+ }
179+ ) ;
180+ } catch ( error ) {
181+ console . log ( JSON . stringify ( level . steps ) ) ;
182+ console . error ( "Error parsing level steps" ) ;
183+ console . error ( error . message ) ;
184+ }
171185
172186return level ;
173187} )