fix(clients): keep backslashes in copied Codex citations (#12243)
Co-authored-by: Simone <[email protected]>
This commit is contained in:
1 parent
411da2a735
commit
2efb8178d8
2 files changed
+20
No files matched your search
@@ -44,6 +44,7 @@ function markdownLabel(value: string): string {
|
||||
|
||||
function markdownDestination(value: string): string {
|
||||
return value
|
||||
.replaceAll("\\", "%5C")
|
||||
.replaceAll("<", "%3C")
|
||||
.replaceAll(">", "%3E")
|
||||
.replaceAll("\r", "%0D")
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
renderCodexFileCitationsAsMarkdown,
|
||||
splitCodexArtifactTemplateMarkdown,
|
||||
} from "./codexMarkdownDirectives.js";
|
||||
import { parseMarkdownFileLink } from "./markdownLinks.js";
|
||||
|
||||
interface TestNode {
|
||||
readonly type: string;
|
||||
@@ -89,6 +90,24 @@ describe("remarkCodexDirectives", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
{ name: "renderCodexDirectivesForCopy", render: renderCodexDirectivesForCopy },
|
||||
{ name: "renderCodexFileCitationsAsMarkdown", render: renderCodexFileCitationsAsMarkdown },
|
||||
])("$name file citation round trips", ({ render }) => {
|
||||
it.each([
|
||||
"C:\\Users\\test\\[draft]\\report.md",
|
||||
"\\\\server\\share\\report.md",
|
||||
"outputs/report.md",
|
||||
"/tmp/report%5C.md",
|
||||
])("preserves the literal path and line: %s", (path) => {
|
||||
const markdown = render(`:codex-file-citation{path="${path}" line_range_start="7"}`);
|
||||
const link = parseOrdinaryMarkdown(markdown).children?.[0]?.children?.[0];
|
||||
|
||||
expect(link?.type).toBe("link");
|
||||
expect(parseMarkdownFileLink(link?.url ?? "")).toEqual({ path, line: 7 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("native Markdown adapters", () => {
|
||||
it("uses the same parser to render file citations as portable links", () => {
|
||||
expect(renderCodexFileCitationsAsMarkdown(`Created ${FILE_CITATION}.`)).toBe(
|
||||
|
||||
Reference in new issue
Block a user