Skip to content

Commit a4fcef8

Browse files
committed
revert GFM list reformatting
1 parent 327f3f1 commit a4fcef8

File tree

2 files changed

+2
-55
lines changed

2 files changed

+2
-55
lines changed

src/Note.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,15 @@ export type MarkdownNote = {
3535
};
3636

3737
export default class Note extends NPXObject {
38-
public readonly elements: NoteElement[];
39-
4038
constructor(
4139
public readonly title: string,
4240
public readonly time: number = new Date().getTime(),
43-
elements: NoteElement[] = [],
41+
public readonly elements: NoteElement[] = [],
4442
public readonly bibliography: Source[] = [],
4543
internalRef?: string,
4644
parent?: Parent | string
4745
) {
4846
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-
);
5647
}
5748

5849
public addElement(element: NoteElement): Note {
@@ -97,7 +88,7 @@ export default class Note extends NPXObject {
9788
return this.elements
9889
.filter(e => e.type === 'markdown')
9990
.map(e => e.content.match(/(^|\s)(#[a-z\d-]+)/gi))
100-
.filter(Boolean)
91+
.filter(res => !!res)
10192
.map(matches => Array.from(matches!))
10293
.reduce((acc, val) => acc.concat(val), [])
10394
.map(hashtag => hashtag.trim());

src/tests/Note.spec.ts

-44
Original file line numberDiff line numberDiff line change
@@ -238,50 +238,6 @@ describe('Note', () => {
238238
expect(res).toMatchSnapshot();
239239
});
240240

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-
285241
describe('canOptimiseElement', () => {
286242
it('should be true for image elements when not specified', () => {
287243
expect(canOptimiseElement({

0 commit comments

Comments
 (0)