From 2237eb2ef343a4f530b8f9ed6e4b59f520738da6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 16:30:07 +0000 Subject: [PATCH] Improve YAML handling with special character quoting and documentation Co-authored-by: estruyf <2900833+estruyf@users.noreply.github.com> --- lite/src/PanelProvider.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lite/src/PanelProvider.ts b/lite/src/PanelProvider.ts index e5205854..5564df72 100644 --- a/lite/src/PanelProvider.ts +++ b/lite/src/PanelProvider.ts @@ -97,6 +97,15 @@ export class PanelProvider implements vscode.WebviewViewProvider { } } + /** + * Parse front matter from markdown content + * Note: This is a simplified YAML parser that handles basic key: value pairs + * Limitations: + * - Only supports bracket-style arrays: [item1, item2] + * - Does not support dash-style arrays (- item) + * - Does not handle multiline values + * - May not handle special YAML characters in strings + */ private _parseFrontMatter(content: string): Record { const frontMatterRegex = /^---\s*\n([\s\S]*?)\n---/; const match = content.match(frontMatterRegex); @@ -160,11 +169,14 @@ export class PanelProvider implements vscode.WebviewViewProvider { const key = line.substring(0, colonIndex).trim(); if (key === field) { // Format the value + // Note: String values with special characters should ideally be quoted + // This simple implementation may not handle all YAML edge cases let formattedValue: string; if (Array.isArray(value)) { formattedValue = `[${value.map(v => `"${v}"`).join(', ')}]`; } else if (typeof value === 'string') { - formattedValue = value; + // Add quotes if value contains special characters + formattedValue = value.match(/[:\[\]{}]/) ? `"${value}"` : value; } else { formattedValue = String(value); } @@ -181,7 +193,8 @@ export class PanelProvider implements vscode.WebviewViewProvider { if (Array.isArray(value)) { formattedValue = `[${value.map(v => `"${v}"`).join(', ')}]`; } else if (typeof value === 'string') { - formattedValue = value; + // Add quotes if value contains special characters + formattedValue = value.match(/[:\[\]{}]/) ? `"${value}"` : value; } else { formattedValue = String(value); }