MCPcopy Create free account
hub / github.com/Make-md/makemd / parseTask

Function parseTask

src/adapters/obsidian/utils/task.ts:8–26  ·  view source on GitHub ↗
(task: string)

Source from the content-addressed store, hash-verified

6 completed: boolean;
7 };
8export const parseTask = (task: string) : Task => {
9 let completed = false;
10 let text = '';
11 if (task.startsWith("- [ ] ")) {
12 completed = false;
13 text = task.slice(6);
14 } else if (task.startsWith("- [x] ")) {
15 completed = true;
16 text = task.slice(6);
17 }
18 const tags = text.match(/#(\w+)/g) ?? [];
19 const date = text.match(/\^(\d{4}-\d{2}-\d{2})/) ?? [];
20 return {
21 text: text.replace(/#(\w+)/g, "").replace(/\^(\d{4}-\d{2}-\d{2})/, ""),
22 tags: tags.map(f => f.replace("#", "")),
23 date: date[1],
24 completed
25 }
26}
27

Callers

nothing calls this directly

Calls 5

startsWithMethod · 0.80
sliceMethod · 0.80
matchMethod · 0.80
replaceMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected