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

Function parseNoteDefaults

src/shared/tasks.ts:105–128  ·  view source on GitHub ↗

Extract just the three keys we care about. Unparseable lines are ignored.

(body: string)

Source from the content-addressed store, hash-verified

103
104/** Extract just the three keys we care about. Unparseable lines are ignored. */
105function parseNoteDefaults(body: string): { defaults: NoteDefaults; fmEndOffset: number } {
106 const m = body.match(FRONTMATTER_RE)
107 if (!m) return { defaults: {}, fmEndOffset: 0 }
108 const block = m[1]
109 const defaults: NoteDefaults = {}
110 for (const rawLine of block.split('\n')) {
111 const line = rawLine.trim()
112 if (!line || line.startsWith('#')) continue
113 const colon = line.indexOf(':')
114 if (colon < 1) continue
115 const key = line.slice(0, colon).trim().toLowerCase()
116 const value = unquote(line.slice(colon + 1))
117 if (key === 'due') {
118 const d = normalizeDueDate(value)
119 if (d) defaults.due = d
120 } else if (key === 'priority') {
121 const p = normalizePriority(value)
122 if (p) defaults.priority = p
123 } else if (key === 'status') {
124 defaults.status = value.toLowerCase()
125 }
126 }
127 return { defaults, fmEndOffset: m[0].length }
128}
129
130// ---------------------------------------------------------------------------
131// Inline token extraction

Callers 1

parseTasksFromBodyFunction · 0.70

Calls 3

unquoteFunction · 0.70
normalizeDueDateFunction · 0.70
normalizePriorityFunction · 0.70

Tested by

no test coverage detected