Skip to content

Copy as Markdown breaks if the command's output contains a ``` sequence #24

Description

@thegoodengineer

From code review of #22.

renderAsMarkdown() (src/extension.ts) wraps the rendered execution in a hardcoded 3-backtick fence:

function renderAsMarkdown(execution: Execution): string {
  return '```\n' + renderOutputDocument(execution) + '\n```';
}

If the command or its captured output contains a literal ``` sequence (e.g. cat some-doc.md on a file with a fenced code block, output from a doc-generation tool, or output from another tool that itself uses fenced blocks), the fence closes early and everything after it renders as normal markdown instead of staying inside the code block when pasted - which directly undermines the feature's own stated purpose (pasting ground truth into an AI agent chat without losing layout to markdown reflow).

Neither of the two new tests uses output containing backticks, so this isn't caught.

Standard fix: use a fence longer than the longest backtick run found in the content (CommonMark allows any fence length ≥3) instead of a fixed 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions