MCPcopy Create free account
hub / github.com/SethGammon/Citadel / parseFrontmatter

Function parseFrontmatter

scripts/integration-test.js:175–187  ·  view source on GitHub ↗

Extract YAML frontmatter from a markdown string. Returns {} if none found.

(content)

Source from the content-addressed store, hash-verified

173// ── Campaign helpers ───────────────────────────────────────────────────────────
174
175/** Extract YAML frontmatter from a markdown string. Returns {} if none found. */
176function parseFrontmatter(content) {
177 const m = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
178 if (!m) return {};
179 const result = {};
180 for (const line of m[1].split(/\r?\n/)) {
181 const kv = line.match(/^(\w+):\s*(.*)$/);
182 if (kv) {
183 const val = kv[2].trim().replace(/^["']|["']$/g, '');
184 result[kv[1]] = isNaN(val) ? val : Number(val);
185 }
186 }
187 return result;
188}
189
190function makeCampaignFile(name, status = 'active', phaseCount = 3, currentPhase = 1) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected