MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / splitFrontmatter

Function splitFrontmatter

src/workspaces/issues/declaration.ts:237–253  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

235 * body (e.g. a markdown horizontal rule) never confuses the close fence. Returns
236 * null when there is no leading frontmatter block. */
237export function splitFrontmatter(raw: string): { frontmatter: string; body: string } | null {
238 const text = raw.replace(/^\uFEFF/, '')
239 const lines = text.split(/\r?\n/)
240 if (lines[0]?.trim() !== '---') return null
241 let end = -1
242 for (let i = 1; i < lines.length; i++) {
243 if (lines[i].trim() === '---') {
244 end = i
245 break
246 }
247 }
248 if (end === -1) return null
249 return {
250 frontmatter: lines.slice(1, end).join('\n'),
251 body: lines.slice(end + 1).join('\n').trim(),
252 }
253}

Callers 3

updateIssueFieldsFunction · 0.70
appendIssueCommentFunction · 0.70
parseIssueContentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected