mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Fix absolute links with files in markdown
We had a regression because of introducing marked-linkify-it, which took links for CONTRIBUTING.md or HACKING.md as domains of a new page instead than files to be navigating to. This commit sets the `fuzzyLink` option for marked-linkify-it to false, which disables this behavior Also tests that the browser tree expands itself when navigating to a file inside a directory Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
+1
-1
@@ -143,7 +143,7 @@ export class Renderer extends BaseRenderer {
|
||||
|
||||
const markedInstance = new Marked(
|
||||
katexMarkedExtension({ throwOnError: false }),
|
||||
markedLinkifyIt(),
|
||||
markedLinkifyIt({}, { fuzzyLink: false }),
|
||||
{
|
||||
extensions: [
|
||||
emojisMarkedExtension,
|
||||
|
||||
@@ -451,6 +451,29 @@ test("external markdown link", async ({ page }) => {
|
||||
await expect(page).toHaveURL("https://example.com");
|
||||
});
|
||||
|
||||
test("internal file markdown link", async ({ page }) => {
|
||||
await page.goto(`${markdownUrl}/tree/main/link-files.md`);
|
||||
await page.getByRole("link", { name: "Markdown Cheatsheet" }).click();
|
||||
await expect(page).toHaveURL(`${markdownUrl}/tree/main/cheatsheet.md`);
|
||||
await expect(
|
||||
page.locator(".file-header", { hasText: "cheatsheet.md" }),
|
||||
).toBeVisible();
|
||||
|
||||
await page.goto(`${markdownUrl}/tree/main/link-files.md`);
|
||||
await page.getByRole("link", { name: "black square" }).click();
|
||||
await expect(page).toHaveURL(
|
||||
`${markdownUrl}/tree/main/assets/black-square.png`,
|
||||
);
|
||||
await expect(
|
||||
page.locator(".file-header", {
|
||||
hasText: "assets/".concat(String.fromCharCode(160), "black-square.png"),
|
||||
}),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("link", { name: "black-square.png" }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("diff selection de-select", async ({ page }) => {
|
||||
await page.goto(
|
||||
`${cobUrl}/patches/013f8b2734df1840b2e33d52ff5632c8d66b199a?tab=files#README.md:H0L0H0L3`,
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user