Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/parser/frontmatter_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func ExtractFrontmatterFromContent(content string) (*FrontmatterResult, error) {
frontmatterLines := lines[1:endIndex]
frontmatterYAML := strings.Join(frontmatterLines, "\n")

// Sanitize no-break whitespace characters (U+00A0) which break the YAML parser
frontmatterYAML = strings.ReplaceAll(frontmatterYAML, "\u00A0", " ")

// Parse YAML
var frontmatter map[string]any
if err := yaml.Unmarshal([]byte(frontmatterYAML), &frontmatter); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/parser/frontmatter_extraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ This is a test workflow with empty frontmatter.`,
content: "---\ntitle: Test\nno closing delimiter",
wantErr: true,
},
{
name: "no-break whitespace in values",
content: "---\ntitle:\u00A0Test\u00A0Workflow\nengine:\u00A0copilot\n---\n\n# Content",
wantYAML: map[string]any{
"title": "Test Workflow",
"engine": "copilot",
},
wantMarkdown: "# Content",
},
}

for _, tt := range tests {
Expand Down
Loading