Skip to content

Commit cea93a3

Browse files
committed
fix: Fix parsing of description for all supported list prefixes
1 parent 80c6a4a commit cea93a3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Task/ListItem.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { TaskRegularExpressions } from './TaskRegularExpressions';
2+
13
export class ListItem {
24
/** The original line read from file.
35
*
@@ -10,7 +12,7 @@ export class ListItem {
1012
public readonly description: string;
1113

1214
constructor(originalMarkdown: string, parent: ListItem | null) {
13-
this.description = originalMarkdown.replace(/^\s*- /, '');
15+
this.description = originalMarkdown.replace(TaskRegularExpressions.listItemRegex, '').trim();
1416
this.originalMarkdown = originalMarkdown;
1517
this.parent = parent;
1618

tests/Task/ListItem.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ describe('list item tests', () => {
7878

7979
it.each([
8080
['- ', true],
81-
['* ', false],
82-
['+ ', false],
83-
['17. ', false],
81+
['* ', true],
82+
['+ ', true],
83+
['17. ', true],
8484
[' - ', true],
85-
['> - ', false],
86-
['> > - ', false],
85+
['> - ', true],
86+
['> > - ', true],
8787
])('should parse description with list item prefix: "%s"', (prefix: string, shouldPass) => {
8888
const description = 'stuff';
8989
const line = prefix + description;

0 commit comments

Comments
 (0)