add support for \r as well

This commit is contained in:
harshbansal7
2026-02-18 16:58:27 +05:30
parent 994ec72d91
commit 02b5811b95
+4 -3
View File
@@ -313,9 +313,10 @@ func (sl *SkillsLoader) parseSimpleYAML(content string) map[string]string {
}
func (sl *SkillsLoader) extractFrontmatter(content string) string {
// Support both Unix (\n) and Windows (\r\n) line endings for frontmatter blocks
// (?s) enables DOTALL so . matches newlines; ^--- at start, then ... --- at start of line
re := regexp.MustCompile(`(?s)^---\r?\n(.*?)\r?\n---`)
// Support \n (Unix), \r\n (Windows), and \r (classic Mac) line endings for frontmatter blocks
// (?s) enables DOTALL so . matches newlines;
// ^--- at start, then ... --- at start of line, honoring all three line ending types
re := regexp.MustCompile(`(?s)^---(?:\r\n|\n|\r)(.*?)(?:\r\n|\n|\r)---`)
match := re.FindStringSubmatch(content)
if len(match) > 1 {
return match[1]