File tree 2 files changed +2
-55
lines changed
2 files changed +2
-55
lines changed Original file line number Diff line number Diff line change @@ -35,24 +35,15 @@ export type MarkdownNote = {
35
35
} ;
36
36
37
37
export default class Note extends NPXObject {
38
- public readonly elements : NoteElement [ ] ;
39
-
40
38
constructor (
41
39
public readonly title : string ,
42
40
public readonly time : number = new Date ( ) . getTime ( ) ,
43
- elements : NoteElement [ ] = [ ] ,
41
+ public readonly elements : NoteElement [ ] = [ ] ,
44
42
public readonly bibliography : Source [ ] = [ ] ,
45
43
internalRef ?: string ,
46
44
parent ?: Parent | string
47
45
) {
48
46
super ( title , internalRef , parent ) ;
49
-
50
- // Fix historical GFM task list inconsistency
51
- this . elements = elements . map ( el =>
52
- el . type === 'markdown'
53
- ? { ...el , content : el . content . replace ( / [ - * ] \[ \] / gm, '- [ ]' ) }
54
- : el
55
- ) ;
56
47
}
57
48
58
49
public addElement ( element : NoteElement ) : Note {
@@ -97,7 +88,7 @@ export default class Note extends NPXObject {
97
88
return this . elements
98
89
. filter ( e => e . type === 'markdown' )
99
90
. map ( e => e . content . match ( / ( ^ | \s ) ( # [ a - z \d - ] + ) / gi) )
100
- . filter ( Boolean )
91
+ . filter ( res => ! ! res )
101
92
. map ( matches => Array . from ( matches ! ) )
102
93
. reduce ( ( acc , val ) => acc . concat ( val ) , [ ] )
103
94
. map ( hashtag => hashtag . trim ( ) ) ;
Original file line number Diff line number Diff line change @@ -238,50 +238,6 @@ describe('Note', () => {
238
238
expect ( res ) . toMatchSnapshot ( ) ;
239
239
} ) ;
240
240
241
- describe ( 'task list compatibility' , ( ) => {
242
- const expected = '- [ ] not done\n* - [ ] not done\n\t- [x] done\n* [X] also done' ;
243
-
244
- it ( 'should ignore correct GFM syntax' , ( ) => {
245
- // Arrange
246
- // Act
247
- let note = new Note ( 'So much to do, so little time' , 0 , [
248
- {
249
- type : 'markdown' ,
250
- content : expected ,
251
- args : {
252
- id : 'testmd' ,
253
- x : '0' ,
254
- y : '0' ,
255
- width : 'auto'
256
- }
257
- }
258
- ] ) ;
259
-
260
- // Assert
261
- expect ( note . elements [ 0 ] . content ) . toEqual ( expected ) ;
262
- } ) ;
263
-
264
- it ( 'should fix incorrect GFM syntax' , ( ) => {
265
- // Arrange
266
- // Act
267
- let note = new Note ( 'So much to do, so little time' , 0 , [
268
- {
269
- type : 'markdown' ,
270
- content : '- [] not done\n* - [] not done\n\t- [x] done\n* [X] also done' ,
271
- args : {
272
- id : 'testmd' ,
273
- x : '0' ,
274
- y : '0' ,
275
- width : 'auto'
276
- }
277
- }
278
- ] ) ;
279
-
280
- // Assert
281
- expect ( note . elements [ 0 ] . content ) . toEqual ( expected ) ;
282
- } ) ;
283
- } ) ;
284
-
285
241
describe ( 'canOptimiseElement' , ( ) => {
286
242
it ( 'should be true for image elements when not specified' , ( ) => {
287
243
expect ( canOptimiseElement ( {
You can’t perform that action at this time.
0 commit comments