import { $ } from "bun"; import { join } from "node:path"; import { format } from "../../../crates/tidy_napi/index.js"; // Usage: mise run oracle:markdown:divergences // Runs each case in tests/oracle/markdown/divergences through Prettier and tidy's Prettier preset, with code blocks // left as written, and writes docs/markdown-divergences.md. A case where both now agree is marked, so a stale entry is easy // to find. tidy runs through its Node binding, which the task builds. const PRETTIER = "prettier@3.9.10"; type Kind = "meaning" | "layout"; type Case = { id: string; title: string; why: string; kind: Kind; signed: string; wrap?: string; width?: number; }; const cases: Case[] = [ { id: "task-html", kind: "meaning", signed: "rule", title: "HTML in a task item keeps its indent", why: "Prettier moves the HTML block to the margin, out of the list item, and indents its later lines past the box: each pass adds 4 more spaces.", }, { id: "continuation", kind: "meaning", signed: "rule", title: "An indented line that would open a block keeps its indent", why: "Without the indent, the fence, thematic break, or HTML tag opens a block and ends the paragraph.", }, { id: "link-target", kind: "meaning", signed: "rule", title: "Link targets stay as written where Prettier's form reads differently", why: "Prettier writes the parsed URL. An unbalanced `(` then ends the link, and a backslash, `<`, `>`, or an entity changes the target.", }, { id: "emphasis", kind: "meaning", signed: "rule", title: "An emphasis mark right after `*` is `_`", why: "Prettier writes `*`, which merges into `***` and nests the other way.", }, { id: "code-span", kind: "meaning", signed: "rule", title: "A code span over two lines keeps its second line as written", why: "Prettier writes it from the parsed value, without the container's indent or `>`, so the second line leaves the list item or quote.", }, { id: "nested-blank", kind: "meaning", signed: "rule", title: "A blank line before a nested list stays when it is all that keeps the list loose", why: "Prettier drops a blank line before a nested list after anything but a paragraph or code. When no other blank line keeps the list loose, it turns tight, and its paragraphs lose their `

`.", }, { id: "wrap-html", kind: "meaning", signed: "rule", wrap: "always", width: 20, title: "Filling never starts a line with a tag that opens an HTML block", why: "Prettier breaks before `

`, `