Skip to content

Commit a661bbb

Browse files
committed
fix: Recognise '1) ' as a numbered list item.
Fixes #3401
1 parent add8767 commit a661bbb

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/Task/TaskRegularExpressions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export class TaskRegularExpressions {
55
// Matches indentation before a list marker (including > for potentially nested blockquotes or Obsidian callouts)
66
public static readonly indentationRegex = /^([\s\t>]*)/;
77

8-
// Matches - * and + list markers, or numbered list markers (eg 1.)
9-
public static readonly listMarkerRegex = /([-*+]|[0-9]+\.)/;
8+
// Matches - * and + list markers, or numbered list markers, for example 1. and 1)
9+
public static readonly listMarkerRegex = /([-*+]|[0-9]+[.)])/;
1010

1111
// Matches a checkbox and saves the status character inside
1212
public static readonly checkboxRegex = /\[(.)\]/u;

tests/Obsidian/Cache.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('cache', () => {
151151
expect(tasks.length).toEqual(2);
152152
});
153153

154-
it.failing('should read numbered list items with closing parenthesis', () => {
154+
it('should read numbered list items with closing parenthesis', () => {
155155
// See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3401
156156
// "Unexpected failure to create a list item from line" warning when parsing "1)" style numbered list
157157
const data = numbered_list_items_with_paren;
@@ -167,7 +167,13 @@ describe('cache', () => {
167167
"
168168
`);
169169

170-
expect(printRoots(tasks)).toMatchInlineSnapshot('""');
170+
expect(printRoots(tasks)).toMatchInlineSnapshot(`
171+
"1) [ ] #task Task 1 in 'numbered_list_items_with_paren' : Task
172+
1) Sub-item 1 : ListItem
173+
2) [ ] #task Task 2 in 'numbered_list_items_with_paren' : Task
174+
1) Sub-item 2 : ListItem
175+
"
176+
`);
171177
expect(tasks.length).toEqual(2);
172178
});
173179

@@ -846,7 +852,6 @@ describe('all mock files', () => {
846852
const files_without_tasks = [
847853
'Test Data/docs_sample_for_explain_query_file_defaults.md',
848854
'Test Data/non_tasks.md',
849-
'Test Data/numbered_list_items_with_paren.md',
850855
];
851856
if (files_without_tasks.includes(path)) {
852857
expect(tasks.length).toEqual(0);

tests/Task/TaskRegularExpressions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe('List Markers', () => {
99
'0.',
1010
'1.',
1111
'12345.',
12+
'0)',
13+
'1)',
14+
'12345)',
1215
])('should be a valid list marker: "%s"', (candidate: string) => {
1316
expect(TaskRegularExpressions.listMarkerRegex.exec(candidate)).not.toBeNull();
1417
});
@@ -18,9 +21,6 @@ describe('List Markers', () => {
1821
'%',
1922
'.',
2023
')',
21-
'0)',
22-
'1)',
23-
'12345)',
2424
])('should NOT be a valid list marker: "%s"', (candidate: string) => {
2525
expect(TaskRegularExpressions.listMarkerRegex.exec(candidate)).toBeNull();
2626
});

0 commit comments

Comments
 (0)