File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ export function parseMdContent(md: string): TutorialFrame | never {
6969 title : levelTitle . trim ( ) ,
7070 summary : levelSummary
7171 ? levelSummary . trim ( )
72- : truncate ( levelContent . trim ( ) , { length : 80 , omission : "..." } ) ,
72+ : truncate ( levelContent . split ( / [ \n \r ] + / ) [ 0 ] . trim ( ) , {
73+ length : 80 ,
74+ omission : "..." ,
75+ } ) ,
7376 content : levelContent . trim ( ) ,
7477 } ;
7578 current = { level : levelId , step : "0" } ;
Original file line number Diff line number Diff line change @@ -166,6 +166,37 @@ Some text that becomes the summary and goes beyond the maximum length of 80 so t
166166 expect ( result . levels [ 0 ] . summary ) . toMatch ( / \. \. \. $ / ) ;
167167 } ) ;
168168
169+ it ( "should only truncate the first line of a level description" , ( ) => {
170+ const md = `# Title
171+
172+ Description.
173+
174+ ## L1 Put Level's title here
175+
176+ Some text.
177+
178+ But not including this line.
179+ ` ;
180+
181+ const skeleton = { levels : [ { id : "L1" } ] } ;
182+ const result = parse ( {
183+ text : md ,
184+ skeleton,
185+ commits : { } ,
186+ } ) ;
187+ const expected = {
188+ levels : [
189+ {
190+ id : "L1" ,
191+ title : "Put Level's title here" ,
192+ summary : "Some text." ,
193+ content : "Some text.\n\nBut not including this line." ,
194+ } ,
195+ ] ,
196+ } ;
197+ expect ( result . levels [ 0 ] . summary ) . toEqual ( "Some text." ) ;
198+ } ) ;
199+
169200 it ( "should match line breaks with double line breaks for proper spacing" , ( ) => {
170201 const md = `# Title
171202
You can’t perform that action at this time.
0 commit comments