MCPcopy Create free account
hub / github.com/github/gh-aw / readFrontmatterContext

Function readFrontmatterContext

pkg/parser/schema_compiler.go:380–403  ·  view source on GitHub ↗
(filePath string)

Source from the content-addressed store, hash-verified

378}
379
380func readFrontmatterContext(filePath string) frontmatterContextData {
381 ctx := frontmatterContextData{
382 cleanPath: filepath.Clean(filePath),
383 frontmatterStart: 2,
384 contextLines: []string{"---", "# (frontmatter validation failed)", "---"},
385 }
386 if filePath == "" {
387 return ctx
388 }
389 content, err := os.ReadFile(ctx.cleanPath)
390 if err != nil {
391 return ctx
392 }
393 lines := strings.Split(string(content), "\n")
394 ctx.allLines = lines
395 startIdx, endIdx, frontmatterContent := findFrontmatterBounds(lines)
396 if startIdx < 0 || endIdx <= startIdx {
397 return ctx
398 }
399 ctx.frontmatterContent = frontmatterContent
400 ctx.frontmatterStart = startIdx + 2
401 ctx.contextLines = lines[max(0, startIdx):min(len(lines), endIdx+1)]
402 return ctx
403}
404
405func formatJSONSchemaValidationWithLocation(
406 jsonPaths []JSONPathInfo,

Callers 1

Calls 1

findFrontmatterBoundsFunction · 0.85

Tested by

no test coverage detected