| ... | ... | @@ -8,6 +8,7 @@ import { |
| 8 | 8 | renderCodexFileCitationsAsMarkdown, |
| 9 | 9 | splitCodexArtifactTemplateMarkdown, |
| 10 | 10 | } from "./codexMarkdownDirectives.js"; |
| 11 | import { parseMarkdownFileLink } from "./markdownLinks.js"; |
| 11 | 12 | |
| 12 | 13 | interface TestNode { |
| 13 | 14 | readonly type: string; |
| ... | ... | @@ -89,6 +90,24 @@ describe("remarkCodexDirectives", () => { |
| 89 | 90 | }); |
| 90 | 91 | }); |
| 91 | 92 | |
| 93 | describe.each([ |
| 94 | { name: "renderCodexDirectivesForCopy", render: renderCodexDirectivesForCopy }, |
| 95 | { name: "renderCodexFileCitationsAsMarkdown", render: renderCodexFileCitationsAsMarkdown }, |
| 96 | ])("$name file citation round trips", ({ render }) => { |
| 97 | it.each([ |
| 98 | "C:\\Users\\test\\[draft]\\report.md", |
| 99 | "\\\\server\\share\\report.md", |
| 100 | "outputs/report.md", |
| 101 | "/tmp/report%5C.md", |
| 102 | ])("preserves the literal path and line: %s", (path) => { |
| 103 | const markdown = render(`:codex-file-citation{path="${path}" line_range_start="7"}`); |
| 104 | const link = parseOrdinaryMarkdown(markdown).children?.[0]?.children?.[0]; |
| 105 | |
| 106 | expect(link?.type).toBe("link"); |
| 107 | expect(parseMarkdownFileLink(link?.url ?? "")).toEqual({ path, line: 7 }); |
| 108 | }); |
| 109 | }); |
| 110 | |
| 92 | 111 | describe("native Markdown adapters", () => { |
| 93 | 112 | it("uses the same parser to render file citations as portable links", () => { |
| 94 | 113 | expect(renderCodexFileCitationsAsMarkdown(`Created ${FILE_CITATION}.`)).toBe( |