From 2fc0d421586935a64b9944705cde25a40baea696 Mon Sep 17 00:00:00 2001 From: John Turner <10634270+johndturn@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:14:08 -0600 Subject: [PATCH 1/2] Added fix for remark-wiki-link package See issue #1059 referencing the error and the proposed fix. --- .../remark-wiki-link/src/lib/fromMarkdown.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/remark-wiki-link/src/lib/fromMarkdown.ts b/packages/remark-wiki-link/src/lib/fromMarkdown.ts index 088142248..7aab22de6 100644 --- a/packages/remark-wiki-link/src/lib/fromMarkdown.ts +++ b/packages/remark-wiki-link/src/lib/fromMarkdown.ts @@ -83,10 +83,11 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { } function exitWikiLink(token) { - const wikiLink = this.exit(token); + const wikiLink = top(this.stack) const { - data: { isEmbed, target, alias }, + data: {isEmbed, target, alias}, } = wikiLink; + this.exit(token); // eslint-disable-next-line no-useless-escape const wikiLinkWithHeadingPattern = /^(.*?)(#.*)?$/u; const [, path, heading = ''] = target.match(wikiLinkWithHeadingPattern); @@ -162,19 +163,19 @@ function fromMarkdown(opts: FromMarkdownOptions = {}) { // Take the target as alt text except if alt name was provided [[target|alt text]] const altText = hasDimensions || !alias ? target : alias; - wikiLink.data.hName = 'img'; - wikiLink.data.hProperties = { - className: classNames, - src: hrefTemplate(link), + wikiLink.data.hName = 'img'; + wikiLink.data.hProperties = { + className: classNames, + src: hrefTemplate(link), alt: altText - }; - - if (hasDimensions) { - const { width, height } = getImageSize(alias as string); - Object.assign(wikiLink.data.hProperties, { - width, - height, - }); + }; + + if (hasDimensions) { + const { width, height } = getImageSize(alias as string); + Object.assign(wikiLink.data.hProperties, { + width, + height, + }); } } } else { From 3b0d0cfc58f215078c6e96a429c8040e7973dd61 Mon Sep 17 00:00:00 2001 From: John Turner <10634270+johndturn@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:27:36 -0600 Subject: [PATCH 2/2] Added changeset entry for adjustments. --- .changeset/smooth-wasps-hunt.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/smooth-wasps-hunt.md diff --git a/.changeset/smooth-wasps-hunt.md b/.changeset/smooth-wasps-hunt.md new file mode 100644 index 000000000..c68fb13bc --- /dev/null +++ b/.changeset/smooth-wasps-hunt.md @@ -0,0 +1,5 @@ +--- +'@portaljs/remark-wiki-link': patch +--- + +Updated the exitWikiLink function to support upgrades to underlying dependencies. See #1059 for more information.