From cd85c53119c2408ba05ec1255b0129d22287e098 Mon Sep 17 00:00:00 2001 From: olayway Date: Tue, 16 May 2023 11:50:28 +0200 Subject: [PATCH] [packages/remark-wiki-link][xs]: lint fixes --- packages/remark-wiki-link/src/lib/fromMarkdown.ts | 8 ++++---- packages/remark-wiki-link/src/lib/html.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/remark-wiki-link/src/lib/fromMarkdown.ts b/packages/remark-wiki-link/src/lib/fromMarkdown.ts index 19d2a0746..469cd2e0d 100644 --- a/packages/remark-wiki-link/src/lib/fromMarkdown.ts +++ b/packages/remark-wiki-link/src/lib/fromMarkdown.ts @@ -80,7 +80,7 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { } = wikiLink; // eslint-disable-next-line no-useless-escape const wikiLinkWithHeadingPattern = /([\w\s\/\.-]*)(#.*)?/; - let [, path, heading = ""] = target.match(wikiLinkWithHeadingPattern); + const [, path, heading = ""] = target.match(wikiLinkWithHeadingPattern); const possibleWikiLinkPermalinks = wikiLinkResolver(path); @@ -104,7 +104,7 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { }); // TODO this is ugly - let link = + const link = matchingPermalink || (pathFormat === "obsidian-absolute" ? "/" + possibleWikiLinkPermalinks[0] @@ -116,7 +116,7 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { // remove leading # if the target is a heading on the same page const displayName = alias || target.replace(/^#/, ""); - heading = heading.replace(/\s+/, "-").toLowerCase(); + const headingId = heading.replace(/\s+/, "-").toLowerCase(); let classNames = wikiLinkClassName; if (!matchingPermalink) { classNames += " " + newClassName; @@ -151,7 +151,7 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { wikiLink.data.hName = "a"; wikiLink.data.hProperties = { className: classNames, - href: hrefTemplate(link) + heading, + href: hrefTemplate(link) + headingId, }; wikiLink.data.hChildren = [{ type: "text", value: displayName }]; } diff --git a/packages/remark-wiki-link/src/lib/html.ts b/packages/remark-wiki-link/src/lib/html.ts index 13ef18497..8f23278d5 100644 --- a/packages/remark-wiki-link/src/lib/html.ts +++ b/packages/remark-wiki-link/src/lib/html.ts @@ -65,7 +65,7 @@ function html(opts: HtmlOptions = {}) { const isEmbed = token.isType === "embed"; // eslint-disable-next-line no-useless-escape const wikiLinkWithHeadingPattern = /([\w\s\/\.-]*)(#.*)?/; - let [, path, heading = ""] = target.match(wikiLinkWithHeadingPattern); + const [, path, heading = ""] = target.match(wikiLinkWithHeadingPattern); const possibleWikiLinkPermalinks = wikiLinkResolver(path); @@ -89,7 +89,7 @@ function html(opts: HtmlOptions = {}) { }); // TODO this is ugly - let link = + const link = matchingPermalink || (pathFormat === "obsidian-absolute" ? "/" + possibleWikiLinkPermalinks[0] @@ -99,7 +99,7 @@ function html(opts: HtmlOptions = {}) { // remove leading # if the target is a heading on the same page const displayName = alias || target.replace(/^#/, ""); // replace spaces with dashes and lowercase headings - heading = heading.replace(/\s+/, "-").toLowerCase(); + const headingId = heading.replace(/\s+/, "-").toLowerCase(); let classNames = wikiLinkClassName; if (!matchingPermalink) { classNames += " " + newClassName; @@ -124,7 +124,7 @@ function html(opts: HtmlOptions = {}) { } } else { this.tag( - `` + `` ); this.raw(displayName); this.tag("");