import { findAndReplaceText, type MarkdownNode, type TextMatch, } from "~/vendor/mdast-find-and-replace"; /** `id` is positional on purpose: the same attachment can be embedded twice in one body. */ export type PullRequestBodySegment = | { readonly id: string; readonly kind: "markdown"; readonly text: string } | { readonly id: string; readonly kind: "attachment"; readonly url: string; /** * What the reader can be told the upload is. The uuid says nothing on its own — the type * only appears in the signed redirect GitHub answers with — but the shape does: GitHub * writes a dropped image into the body as an `` tag, so a bare attachment link on its * own line is what it does with a video. Anything else keeps the neutral name. */ readonly media: "video" | "unknown"; }; const FENCE_PATTERN = /^\s{0,3}((?:`{3,})|(?:~{3,}))(.*)$/u; /** * How far a `