MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / parseTasksFromBody

Function parseTasksFromBody

apps/desktop/src/mcp/vault-ops.ts:910–992  ·  view source on GitHub ↗
(
  body: string,
  ctx: { path: string; title: string; folder: NoteFolder }
)

Source from the content-addressed store, hash-verified

908}
909
910function parseTasksFromBody(
911 body: string,
912 ctx: { path: string; title: string; folder: NoteFolder }
913): VaultTask[] {
914 const normalized = body.replace(/\r\n/g, '\n')
915 const defaults = parseNoteDefaults(normalized)
916 const lines = normalized.split('\n')
917 const tasks: VaultTask[] = []
918
919 let taskIndex = 0
920 let inFence = false
921 let fenceMarker: string | null = null
922
923 for (let i = 0; i < lines.length; i++) {
924 const line = lines[i]
925 const fenceMatch = line.match(FENCE_LINE_RE)
926 if (fenceMatch) {
927 const marker = fenceMatch[2]
928 if (!inFence) {
929 inFence = true
930 fenceMarker = marker
931 } else if (marker === fenceMarker) {
932 inFence = false
933 fenceMarker = null
934 }
935 continue
936 }
937 if (inFence) continue
938
939 const m = line.match(TASK_LINE_RE)
940 if (!m) continue
941
942 const checkedChar = m[1]
943 const tail = m[2]
944 const checked = checkedChar === 'x' || checkedChar === 'X'
945
946 let due: string | undefined
947 let priority: 'high' | 'med' | 'low' | undefined
948 let waiting = false
949 const tags: string[] = []
950 let stripped = tail
951
952 const dueMatch = stripped.match(INLINE_DUE_RE)
953 if (dueMatch) {
954 if (isValidIsoDate(dueMatch[1])) due = dueMatch[1]
955 stripped = stripped.replace(INLINE_DUE_RE, ' ')
956 }
957 const priMatch = stripped.match(INLINE_PRIORITY_RE)
958 if (priMatch) {
959 priority = normalizePriority(priMatch[1])
960 stripped = stripped.replace(INLINE_PRIORITY_RE, ' ')
961 }
962 if (INLINE_WAITING_RE.test(stripped)) {
963 waiting = true
964 stripped = stripped.replace(INLINE_WAITING_RE, ' ')
965 }
966 INLINE_TAG_RE.lastIndex = 0
967 let tm: RegExpExecArray | null

Callers 2

scanAllTasksFunction · 0.70
toggleTaskFunction · 0.70

Calls 3

parseNoteDefaultsFunction · 0.70
isValidIsoDateFunction · 0.70
normalizePriorityFunction · 0.70

Tested by

no test coverage detected