Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-wasps-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@portaljs/remark-wiki-link': patch
---

Updated the exitWikiLink function to support upgrades to underlying dependencies. See #1059 for more information.
29 changes: 15 additions & 14 deletions packages/remark-wiki-link/src/lib/fromMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down