MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / parseFrontmatterFromContent

Method parseFrontmatterFromContent

src/utils/TaskManager.ts:961–984  ·  view source on GitHub ↗
(
		content: string,
		path?: string
	)

Source from the content-addressed store, hash-verified

959 }
960
961 private parseFrontmatterFromContent(
962 content: string,
963 path?: string
964 ): Record<string, unknown> | null {
965 const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
966 if (!match) return null;
967
968 try {
969 const parsed = parseYaml(match[1] || "");
970 if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
971 return null;
972 }
973 return parsed as Record<string, unknown>;
974 } catch (error) {
975 const fileContext = path ? ` for ${path}` : "";
976 tasknotesLogger.warn(`TaskManager: Failed to parse frontmatter fallback${fileContext}`, {
977 category: "validation",
978 operation: "taskmanager-parse-frontmatter-fallback",
979 details: path ? { path } : undefined,
980 error: error,
981 });
982 return null;
983 }
984 }
985
986 /**
987 * Check if initialized

Callers 1

Calls 2

parseYamlFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected