From d748979368488a87b4a7cbd369f178202d23acf0 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Fri, 16 Oct 2026 17:34:30 -0400 Subject: [PATCH] fix(pstack): recognize matching inline code delimiters Signed-off-by: Rudy Celekli --- .../skills/poteto-mode/scripts/check-plan.mjs | 2 +- .../skills/poteto-mode/scripts/check-plan.test.ts | 14 ++++++++++++++ pstack/skills/poteto-mode/scripts/check-plan.mjs | 2 +- .../skills/poteto-mode/scripts/check-plan.test.ts | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs index c8626766c..c3ddc3989 100755 --- a/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs +++ b/harness/pstack/claude-code/skills/poteto-mode/scripts/check-plan.mjs @@ -72,7 +72,7 @@ for (let i = start; i < raw.length; i++) { lines.push({ n, text, code }); if (code) continue; const prose = text - .replace(/`[^`]*`/g, "`") + .replace(/(? { const result = runPlan("```markdown `invalid`\n## Example only\n```\n", 1); expect(result.stderr).toContain('"## Example only" after Close the program is not an appendix'); }); + +test("ignores prose punctuation inside matching multi-backtick code spans", () => { + for (const count of [2, 3, 4]) { + const delimiter = "`".repeat(count); + runPlan(`Use ${delimiter}echo \`x\`: “quoted” — example${delimiter}.\n`, 0); + } +}); + +test("checks prose following a multi-backtick span and unmatched delimiters", () => { + const outside = runPlan("Use ``echo `x`: y``. Bad: prose.\n", 1); + expect(outside.stderr).toContain("mid-sentence colon"); + const unmatched = runPlan("Use ``unclosed: bad` here.\n", 1); + expect(unmatched.stderr).toContain("mid-sentence colon"); +}); diff --git a/pstack/skills/poteto-mode/scripts/check-plan.mjs b/pstack/skills/poteto-mode/scripts/check-plan.mjs index c8626766c..c3ddc3989 100755 --- a/pstack/skills/poteto-mode/scripts/check-plan.mjs +++ b/pstack/skills/poteto-mode/scripts/check-plan.mjs @@ -72,7 +72,7 @@ for (let i = start; i < raw.length; i++) { lines.push({ n, text, code }); if (code) continue; const prose = text - .replace(/`[^`]*`/g, "`") + .replace(/(? { const result = runPlan("```markdown `invalid`\n## Example only\n```\n", 1); expect(result.stderr).toContain('"## Example only" after Close the program is not an appendix'); }); + +test("ignores prose punctuation inside matching multi-backtick code spans", () => { + for (const count of [2, 3, 4]) { + const delimiter = "`".repeat(count); + runPlan(`Use ${delimiter}echo \`x\`: “quoted” — example${delimiter}.\n`, 0); + } +}); + +test("checks prose following a multi-backtick span and unmatched delimiters", () => { + const outside = runPlan("Use ``echo `x`: y``. Bad: prose.\n", 1); + expect(outside.stderr).toContain("mid-sentence colon"); + const unmatched = runPlan("Use ``unclosed: bad` here.\n", 1); + expect(unmatched.stderr).toContain("mid-sentence colon"); +});