(filePath string)
| 378 | } |
| 379 | |
| 380 | func 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 | |
| 405 | func formatJSONSchemaValidationWithLocation( |
| 406 | jsonPaths []JSONPathInfo, |
no test coverage detected