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:
Sebastian Martinez
2023-07-22 08:02:00 +02:00
parent 50d046ce86
commit f631c7f171
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ export class Renderer extends BaseRenderer {
const markedInstance = new Marked(
katexMarkedExtension({ throwOnError: false }),
markedLinkifyIt(),
markedLinkifyIt({}, { fuzzyLink: false }),
{
extensions: [
emojisMarkedExtension,
+23
View File
@@ -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`,
Binary file not shown.