Skip to content

Commit

Permalink
[packages/remark-wiki-link][xs]: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
olayway committed May 16, 2023
1 parent 077dce2 commit cd85c53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/remark-wiki-link/src/lib/fromMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -104,7 +104,7 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) {
});

// TODO this is ugly
let link =
const link =
matchingPermalink ||
(pathFormat === "obsidian-absolute"
? "/" + possibleWikiLinkPermalinks[0]
Expand All @@ -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;
Expand Down Expand Up @@ -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 }];
}
Expand Down
8 changes: 4 additions & 4 deletions packages/remark-wiki-link/src/lib/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -89,7 +89,7 @@ function html(opts: HtmlOptions = {}) {
});

// TODO this is ugly
let link =
const link =
matchingPermalink ||
(pathFormat === "obsidian-absolute"
? "/" + possibleWikiLinkPermalinks[0]
Expand All @@ -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;
Expand All @@ -124,7 +124,7 @@ function html(opts: HtmlOptions = {}) {
}
} else {
this.tag(
`<a href="${hrefTemplate(link + heading)}" class="${classNames}">`
`<a href="${hrefTemplate(link + headingId)}" class="${classNames}">`
);
this.raw(displayName);
this.tag("</a>");
Expand Down

0 comments on commit cd85c53

Please sign in to comment.