Skip to content

Commit

Permalink
Merge pull request #2193 from obsidian-tasks-group/support-plus-lists
Browse files Browse the repository at this point in the history
feat: Add + sign to supported list markers
  • Loading branch information
claremacrae authored Aug 6, 2023
2 parents c4d6858 + 8e9596b commit b21c170
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 12 deletions.
7 changes: 5 additions & 2 deletions docs/Getting Started/Auto-Suggest.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ Here is a more detailed walk through of the creation of a new task, which can be

**Note**: the auto-suggest menu pops up only if the cursor is in a line that is recognized as a task, that is, the line contains:

- a bullet with a checkbox (`- [ ]` or `* [ ]`)
- a bullet with a checkbox, that is, one of:
- `- [ ]`
- `* [ ]`
- `+ [ ]`
- and the global filter (if any)

2. You can keep typing (to ignore the suggestions), or select one of the menu items in a variety of ways:
Expand Down Expand Up @@ -72,7 +75,7 @@ It triggers only on lines that will be recognised as tasks by the Tasks plugin:

- If you use a global task filter, for example `#task`, you will need to provide `- [ ] #task` before the menu pops up.
- If you don't use a global task filter, you will only need to provide `- [ ]` before the menu pops up.
- It also recognises lists starting with asterisk (`*`) characters.
- It also recognises lists starting with asterisk (`*`) and plus (`+`) characters.

The menu is smart: it will only offer valid options:

Expand Down
23 changes: 22 additions & 1 deletion docs/Getting Started/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@ publish: true

Tasks tracks your checklist items from your vault.
The simplest way to create a new task is to create a new checklist item.
The markdown syntax for checklist items is a list item that starts with spaced brackets: `- [ ] take out the trash`.
The markdown syntax for checklist items is a list item that starts with spaced brackets:

```text
- [ ] take out the trash`
```

Now Tasks tracks that you need to take out the trash!

> [!Info]
> You can write tasks using any of the following list styles:
>
> ```text
> - [ ] task starting with a hyphen
>
> * [ ] task starting with an asterisk
>
> + [ ] task starting with a plus sign
>
> 1. [ ] a task in a numbered list
> ```
> [!released]
> Support for tasks with `+` was introduced in Tasks X.Y.Z.
To list all open tasks in a markdown file, simply add a [[About Queries|query]] as a tasks code block like so:
````markdown
Expand Down
1 change: 1 addition & 0 deletions docs/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ publish: true

## What's New?

- X.Y.Z: 🔥 Support task in list items starting with [[Getting Started#Finding tasks in your vault|`+` signs]]
- 4.4.0: 🔥 Support [[Expressions#More complex expressions|variables, if statements, and functions]] in custom filters and groups
- 4.3.0: 🔥 Bug fixes, usability improvements and `explain` support for [[Regular Expressions|regular expression]] searches
- 4.2.0: 🔥 Add [[Custom Filters|custom filtering]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ Work through all the tasks below, until zero tasks remain in this query:
### Un-completion of tasks
- [x] #task Mark this task not complete in **Source view** using **Tasks: Toggle task done** command ✅ 2022-07-05
- [x] #task Mark this task not complete by clicking on it in **Reading view** ✅ 2022-07-05
- [x] #task Mark this task not complete by clicking on it in **Live Preview** ✅ 2022-07-05
- [ ] #task **check**: Checked all above methods for **un-completing tasks** - and they worked
<!-- markdownlint-disable ul-style -->
* [x] #task Mark this task not complete in **Source view** using **Tasks: Toggle task done** command ✅ 2022-07-05
* [x] #task Mark this task not complete by clicking on it in **Reading view** ✅ 2022-07-05
* [x] #task Mark this task not complete by clicking on it in **Live Preview** ✅ 2022-07-05
* [ ] #task **check**: Checked all above methods for **un-completing tasks** - and they worked
<!-- markdownlint-enable ul-style -->
### Recurring Tasks
Expand All @@ -88,9 +92,13 @@ Confirm that when a recurring task is completed, a new task is created, all the
Steps to do:
- [ ] #task View this file in **Reading view** and confirm that the tasks in this section are listed
- [ ] #task View this file in **Live Preview** and confirm that the tasks in this section are listed
- [ ] #task **check**: Checked all above steps for **viewing task blocks** worked
<!-- markdownlint-disable ul-style -->
+ [ ] #task View this file in **Reading view** and confirm that the tasks in this section are listed
+ [ ] #task View this file in **Live Preview** and confirm that the tasks in this section are listed
+ [ ] #task **check**: Checked all above steps for **viewing task blocks** worked
<!-- markdownlint-enable ul-style -->
---
Expand Down
4 changes: 2 additions & 2 deletions src/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class TaskRegularExpressions {
// Matches indentation before a list marker (including > for potentially nested blockquotes or Obsidian callouts)
public static readonly indentationRegex = /^([\s\t>]*)/;

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

// Matches a checkbox and saves the status character inside
public static readonly checkboxRegex = /\[(.)\]/u;
Expand Down
28 changes: 28 additions & 0 deletions tests/Task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ describe('parsing', () => {
expect(task!.originalMarkdown).toStrictEqual(line);
});

it('parses a task from a line starting with plus sign', () => {
// Arrange
const line = '+ [ ] this is a task in asterisk list';

// Act
const task = fromLine({
line,
});

// Assert
expect(task).not.toBeNull();
expect(task!.listMarker).toEqual('+');
expect(task!.originalMarkdown).toStrictEqual(line);
});

it('parses a task from a line (numbered)', () => {
// Arrange
const line = '1. [x] this is a done task';
Expand Down Expand Up @@ -87,6 +102,19 @@ describe('parsing', () => {
expect(task!.originalMarkdown).toStrictEqual(line);
});

it('done not parse a task from a line starting with @ sign', () => {
// Arrange
const line = '@ [ ] this is a task in asterisk list';

// Act
const task = fromLine({
line,
});

// Assert
expect(task).toBeNull();
});

it('supports capitalised status characters', () => {
// See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/520
// "In combination with SlrVb's S-Checkbox CSS, Task Plugin breaks that style"
Expand Down

0 comments on commit b21c170

Please sign in to comment.