Skip to content

Commit

Permalink
Merge pull request #3191 from obsidian-tasks-group/fix-on-completion-…
Browse files Browse the repository at this point in the history
…parsing

fix: - Allow multiple spaces after onCompletion emoji
  • Loading branch information
claremacrae authored Nov 21, 2024
2 parents 2c27987 + 6f40279 commit cae0faf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/TaskSerializer/DefaultTaskSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const DEFAULT_SYMBOLS: DefaultTaskSerializerSymbols = {
doneDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
cancelledDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu,
onCompletionRegex: /🏁 ?([a-zA-Z]+)$/iu,
onCompletionRegex: /🏁 *([a-zA-Z]+)$/iu,
dependsOnRegex: new RegExp('⛔\uFE0F? *(' + taskIdSequenceRegex.source + ')$', 'iu'),
idRegex: new RegExp('🆔 *(' + taskIdRegex.source + ')$', 'iu'),
},
Expand Down
10 changes: 8 additions & 2 deletions tests/TaskSerializer/DefaultTaskSerializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('validate emoji regular expressions', () => {
doneDateRegex: /✅ *(\\d{4}-\\d{2}-\\d{2})$/u
cancelledDateRegex: /❌ *(\\d{4}-\\d{2}-\\d{2})$/u
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu
onCompletionRegex: /🏁 ?([a-zA-Z]+)$/iu
onCompletionRegex: /🏁 *([a-zA-Z]+)$/iu
dependsOnRegex: /⛔️? *([a-zA-Z0-9-_]+( *, *[a-zA-Z0-9-_]+ *)*)$/iu
idRegex: /🆔 *([a-zA-Z0-9-_]+)$/iu"
`);
Expand Down Expand Up @@ -170,10 +170,16 @@ describe.each(symbolMap)("DefaultTaskSerializer with '$taskFormat' symbols", ({

describe('should parse onCompletion', () => {
it('should parse delete action', () => {
const onCompletion = `${onCompletionSymbol} delete`;
const onCompletion = `${onCompletionSymbol} Delete`;
const taskDetails = deserialize(onCompletion);
expect(taskDetails).toMatchTaskDetails({ onCompletion: OnCompletion.Delete });
});

it('should allow multiple spaces', () => {
const onCompletion = `${onCompletionSymbol} Keep`;
const taskDetails = deserialize(onCompletion);
expect(taskDetails).toMatchTaskDetails({ onCompletion: OnCompletion.Keep });
});
});

describe('should parse depends on', () => {
Expand Down

0 comments on commit cae0faf

Please sign in to comment.