File tree 2 files changed +35
-1
lines changed
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 {
69
69
title : levelTitle . trim ( ) ,
70
70
summary : levelSummary
71
71
? levelSummary . trim ( )
72
- : truncate ( levelContent . trim ( ) , { length : 80 , omission : "..." } ) ,
72
+ : truncate ( levelContent . split ( / [ \n \r ] + / ) [ 0 ] . trim ( ) , {
73
+ length : 80 ,
74
+ omission : "..." ,
75
+ } ) ,
73
76
content : levelContent . trim ( ) ,
74
77
} ;
75
78
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
166
166
expect ( result . levels [ 0 ] . summary ) . toMatch ( / \. \. \. $ / ) ;
167
167
} ) ;
168
168
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
+
169
200
it ( "should match line breaks with double line breaks for proper spacing" , ( ) => {
170
201
const md = `# Title
171
202
You can’t perform that action at this time.
0 commit comments