GeezerVison is showing github.com — fix(shared): preserve literal ampersands in citation Markdown paths (… · pingdotgg/t3code@f161a4d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/shared/src/codexFileCitations.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,7 @@ describe("codexFileCitationMarkdown", () => { |
64 | 64 | path: "reports/*draft*_[copy]`<&.txt", |
65 | 65 | }); |
66 | 66 | expect(citation && codexFileCitationMarkdown(citation)).toBe( |
67 | | - "[\\*draft\\*\\_\\[copy\\]\\`\\<\\&.txt](<reports/*draft*_[copy]`%3C&.txt>)", |
| 67 | + "[\\*draft\\*\\_\\[copy\\]\\`\\<\\&.txt](<reports/*draft*_[copy]`%3C%26.txt>)", |
68 | 68 | ); |
69 | 69 | }); |
70 | 70 | }); |
Collapse file
Copy file name to clipboardExpand all lines: packages/shared/src/codexFileCitations.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,7 @@ function markdownLabel(value: string): string { |
45 | 45 | function markdownDestination(value: string): string { |
46 | 46 | return value |
47 | 47 | .replaceAll("\\", "%5C") |
| 48 | + .replaceAll("&", "%26") |
48 | 49 | .replaceAll("<", "%3C") |
49 | 50 | .replaceAll(">", "%3E") |
50 | 51 | .replaceAll("\r", "%0D") |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/shared/src/codexMarkdownDirectives.test.ts +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -106,6 +106,16 @@ describe.each([ |
106 | 106 | expect(link?.type).toBe("link"); |
107 | 107 | expect(parseMarkdownFileLink(link?.url ?? "")).toEqual({ path, line: 7 }); |
108 | 108 | }); |
| 109 | + |
| 110 | + it("keeps an entity-like ampersand in the path literal", () => { |
| 111 | + const markdown = render( |
| 112 | + ':codex-file-citation{path="/tmp/a&copy;.txt" line_range_start="7"}', |
| 113 | + ); |
| 114 | + const link = parseOrdinaryMarkdown(markdown).children?.[0]?.children?.[0]; |
| 115 | + |
| 116 | + expect(link?.type).toBe("link"); |
| 117 | + expect(parseMarkdownFileLink(link?.url ?? "")).toEqual({ path: "/tmp/a©.txt", line: 7 }); |
| 118 | + }); |
109 | 119 | }); |
110 | 120 |
|
111 | 121 | describe("native Markdown adapters", () => { |
|