Add support for tags
This commit is contained in:
@@ -22,10 +22,36 @@ task = "-" _ "[" status:. "]" _ label:label meta:meta* {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
label = text:([^⏬🔽🔼⏫🔺➕⏳🛫📅✅❌🔁🏁🆔⛔⏰]*) {
|
/**************************************************************************************************************************************/
|
||||||
return text.join("").trim()
|
|
||||||
|
label = spans:(tag / labelWord / labelWhitespace)* {
|
||||||
|
return spans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
labelWord = word:[^ \t\r⏬🔽🔼⏫🔺➕⏳🛫📅✅❌🔁🏁🆔⛔⏰]+ {
|
||||||
|
return {
|
||||||
|
span: "word",
|
||||||
|
value: word.join("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labelWhitespace = whitespace:[ \t\r]+ {
|
||||||
|
return {
|
||||||
|
span: "whitespace",
|
||||||
|
value: whitespace.join("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tag = "#" tag:[a-zA-Z0-9-]+ {
|
||||||
|
return {
|
||||||
|
span: "tag",
|
||||||
|
value: tag.join("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
meta = _ @(date / recurrence / delete / priority / dependency / reminder) _
|
meta = _ @(date / recurrence / delete / priority / dependency / reminder) _
|
||||||
|
|
||||||
/**************************************************************************************************************************************/
|
/**************************************************************************************************************************************/
|
||||||
|
|||||||
@@ -16,7 +16,24 @@ export class LazyTask implements Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get label(): string {
|
get label(): string {
|
||||||
return this.#parsed.label;
|
return this.#parsed.label
|
||||||
|
.filter(x => x.span === 'word' || x.span === 'whitespace')
|
||||||
|
.map(x => x.value)
|
||||||
|
.join("")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
get fullLabel(): string {
|
||||||
|
return this.#parsed.label
|
||||||
|
.map(x => x.span === 'tag' ? `#${x.value}` : x.value)
|
||||||
|
.join("")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
get tags(): string[] {
|
||||||
|
return this.#parsed.label
|
||||||
|
.filter(x => x.span === 'tag')
|
||||||
|
.map(x => x.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get priority(): TaskPriority {
|
get priority(): TaskPriority {
|
||||||
@@ -104,7 +121,8 @@ export class LazyTask implements Task {
|
|||||||
o("delete", this.onDelete),
|
o("delete", this.onDelete),
|
||||||
o("id", this.id),
|
o("id", this.id),
|
||||||
o("deps", this.dependsOn.join(",")),
|
o("deps", this.dependsOn.join(",")),
|
||||||
o("reminder", this.reminder)
|
o("reminder", this.reminder),
|
||||||
|
o("tags", this.tags.join(","))
|
||||||
];
|
];
|
||||||
|
|
||||||
return `- [${this.status}] ${this.label} {${items.filter(x => x.length > 0).join(", ")}}`;
|
return `- [${this.status}] ${this.label} {${items.filter(x => x.length > 0).join(", ")}}`;
|
||||||
|
|||||||
@@ -8,10 +8,15 @@ export type ParseResult = {
|
|||||||
|
|
||||||
export type ParsedTask = {
|
export type ParsedTask = {
|
||||||
status: string;
|
status: string;
|
||||||
label: string;
|
label: ParsedTaskLabel[];
|
||||||
meta: ParsedTaskMeta[];
|
meta: ParsedTaskMeta[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ParsedTaskLabel = {
|
||||||
|
span: 'word'|'whitespace'|'tag';
|
||||||
|
value: string
|
||||||
|
};
|
||||||
|
|
||||||
export type ParsedTaskMeta =
|
export type ParsedTaskMeta =
|
||||||
| ParsedTaskPriority
|
| ParsedTaskPriority
|
||||||
| ParsedTaskRecurrence
|
| ParsedTaskRecurrence
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { Dayjs } from "dayjs";
|
|||||||
export type Task = {
|
export type Task = {
|
||||||
status: string;
|
status: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
fullLabel: string;
|
||||||
|
tags: string[];
|
||||||
priority: TaskPriority;
|
priority: TaskPriority;
|
||||||
createdDate?: Dayjs;
|
createdDate?: Dayjs;
|
||||||
startDate?: Dayjs;
|
startDate?: Dayjs;
|
||||||
|
|||||||
Reference in New Issue
Block a user