diff --git a/src/lib/markdown.ts b/src/lib/markdown.ts
index 74b97d223..4c2b225dd 100644
--- a/src/lib/markdown.ts
+++ b/src/lib/markdown.ts
@@ -125,6 +125,7 @@ export const renderer = {
// trim eventual dashes on each side of the string.
heading(text: string, level: 1 | 2 | 3 | 4 | 5 | 6) {
const escapedText = text
+ // By lowercasing we avoid casing mismatches, between headings and links.
.toLowerCase()
.replace(/[^\w]+/g, "-")
.replace(/^-|-$/g, "");
@@ -143,10 +144,13 @@ export const renderer = {
return `
${liContent}`;
},
link(href: string, _title: string, text: string) {
- // If the link is not a URL nor starts with a #, we add the file-link class to it,
- // so we're able to query it in the Markdown component.
+ // Adding the file-link class to relative file names,
+ // so we're able to navigate to the file in the editor.
if (!isUrl(href) && !href.startsWith("#")) {
return `${text}`;
+ } else if (href.startsWith("#")) {
+ // By lowercasing we avoid casing mismatches, between headings and links.
+ return `${text}`;
}
return `${text}`;
},