ST-cmowjelb1: Parser: bestand-relatieve regel + hint-detectie in YAMLParseError-tak

- Voeg `hint?: string` toe aan PlanParseError type
- Bereken bestand-relatief regelnummer (yamlLine + 1 voor de openings-`---`)
- Detecteer markdown-patronen (numbered/bullet lijst) op de offending regel
- Zet Nederlandstalige hint bij markdown-match
- Render hint als "Tip: …" onder het foutbericht in IdeaMdEditor
This commit is contained in:
Scrum4Me Agent 2026-05-08 12:38:02 +02:00
parent 8c63ba377d
commit d394ced20f
2 changed files with 21 additions and 7 deletions

View file

@ -123,6 +123,11 @@ export function IdeaMdEditor({ ideaId, kind, initialValue, onCancel }: Props) {
<li key={i}>
{err.line ? `Regel ${err.line}: ` : ''}
{err.message}
{err.hint && (
<span className="block mt-0.5 text-status-blocked/80">
Tip: {err.hint}
</span>
)}
</li>
))}
</ul>

View file

@ -13,7 +13,7 @@ import {
type IdeaPlanFrontmatter,
} from '@/lib/schemas/idea'
export type PlanParseError = { line?: number; message: string }
export type PlanParseError = { line?: number; message: string; hint?: string }
export type PlanParseResult =
| { ok: true; plan: IdeaPlanFrontmatter; body: string }
@ -43,14 +43,23 @@ export function parsePlanMd(md: string): PlanParseResult {
parsed = parseYaml(frontmatterRaw)
} catch (err) {
if (err instanceof YAMLParseError) {
const yamlLine = err.linePos?.[0]?.line
const fileLine = yamlLine != null ? yamlLine + 1 : undefined
const offendingLine =
yamlLine != null
? frontmatterRaw.split(/\r?\n/)[(yamlLine ?? 1) - 1]
: undefined
const isMarkdown =
offendingLine != null &&
(/^\s*\d+\.\s+\*\*/.test(offendingLine) ||
/^\s*[-*]\s+\*\*/.test(offendingLine) ||
/^\s*\d+\..*:/.test(offendingLine))
const hint = isMarkdown
? 'Lijkt op markdown-content (genummerde of opsommingslijst) binnen YAML-frontmatter. Verplaats deze regels naar na de afsluitende `---`, of zet ze in een `description: |` blok.'
: undefined
return {
ok: false,
errors: [
{
line: err.linePos?.[0]?.line,
message: err.message,
},
],
errors: [{ line: fileLine, message: err.message, hint }],
}
}
return {