MCPcopy Index your code
hub / github.com/simstudioai/sim / parseFrontmatter

Method parseFrontmatter

apps/sim/lib/chunkers/docs-chunker.ts:227–252  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

225 }
226
227 private parseFrontmatter(content: string): { data: Frontmatter; content: string } {
228 const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/
229 const match = content.match(frontmatterRegex)
230
231 if (!match) {
232 return { data: {}, content }
233 }
234
235 const [, frontmatterText, markdownContent] = match
236 const data: Frontmatter = {}
237
238 const lines = frontmatterText.split('\n')
239 for (const line of lines) {
240 const colonIndex = line.indexOf(':')
241 if (colonIndex > 0) {
242 const key = line.slice(0, colonIndex).trim()
243 const value = line
244 .slice(colonIndex + 1)
245 .trim()
246 .replace(/^['"]|['"]$/g, '')
247 data[key] = value
248 }
249 }
250
251 return { data, content: markdownContent }
252 }
253
254 /** Detects table boundaries to avoid splitting tables across chunks. */
255 private detectTableBoundaries(content: string): { start: number; end: number }[] {

Callers 1

chunkMdxFileMethod · 0.95

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected