From: Zetaphor Date: Thu, 22 Jun 2023 19:05:20 +0000 (-0300) Subject: Cleanup, only check for /u/ if /c/ and /m/ checks fail X-Git-Url: http://these/git/%22https:/nerdica.net/%7B%24%7B%60data:application/static/%7BinboxRss%7D?a=commitdiff_plain;h=d58fd63113bc2933377ec2d90f8091b34b16e74f;p=lemmy-ui.git Cleanup, only check for /u/ if /c/ and /m/ checks fail --- diff --git a/src/shared/markdown.ts b/src/shared/markdown.ts index adee474..9f1ec73 100644 --- a/src/shared/markdown.ts +++ b/src/shared/markdown.ts @@ -101,7 +101,6 @@ function localInstanceLinkParser(md: MarkdownIt) { newTokens.push(textToken); } - // Determine the new href let href; if (match[0].startsWith("!")) { href = "/c/" + match[0].substring(1); @@ -109,10 +108,9 @@ function localInstanceLinkParser(md: MarkdownIt) { href = "/c/" + match[0].substring(3); } else { href = match[0]; - } - - if (match[0].startsWith("/u/")) { - linkClass = "user-link"; + if (match[0].startsWith("/u/")) { + linkClass = "user-link"; + } } const linkOpenToken = new state.Token("link_open", "a", 1); @@ -137,7 +135,6 @@ function localInstanceLinkParser(md: MarkdownIt) { newTokens.push(textToken); } - // Replace the original token with the new tokens inlineTokens.splice(j, 1, ...newTokens); } } @@ -162,7 +159,7 @@ export function setupMarkdown() { .use(markdown_it_footnote) .use(markdown_it_html5_embed, html5EmbedConfig) .use(markdown_it_container, "spoiler", spoilerConfig) - .use(localCommunityLinkParser); + .use(localInstanceLinkParser); // .use(markdown_it_emoji, { // defs: emojiDefs, // }); @@ -173,7 +170,7 @@ export function setupMarkdown() { .use(markdown_it_footnote) .use(markdown_it_html5_embed, html5EmbedConfig) .use(markdown_it_container, "spoiler", spoilerConfig) - .use(localCommunityLinkParser) + .use(localInstanceLinkParser) // .use(markdown_it_emoji, { // defs: emojiDefs, // })