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. 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 {