Skip to content

Commit

Permalink
Try to fix wikilink-embed e2e tests by returning md content instead o…
Browse files Browse the repository at this point in the history
…f html content
  • Loading branch information
badsketch committed Aug 22, 2023
1 parent 7d97e78 commit 2598689
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/foam-vscode/src/features/preview/wikilink-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export const markdownItWikilinkEmbed = (
? inlineFormatter
: cardFormatter;

content = extractor(includedNote, parser, workspace);
html = formatter(content, md);
const rawContent = extractor(includedNote, parser, workspace);
content = formatter(rawContent, md);
break;
}
case 'attachment':
Expand All @@ -71,15 +71,14 @@ export const markdownItWikilinkEmbed = (
${md.renderInline('[[' + wikilink + ']]')}<br/>
Embed for attachments is not supported
</div>`;
html = md.render(content);
break;
case 'image':
content = `<div class="embed-container-image">${md.render(
`![](${md.normalizeLink(includedNote.uri.path)})`
)}</div>`;
html = md.render(content);
break;
}
html = md.render(content);
refsStack.pop();
return html;
} catch (e) {
Expand Down Expand Up @@ -168,13 +167,11 @@ function fullExtractor(
export type EmbedNoteFormatter = (content: string, md: markdownit) => string;

function cardFormatter(content: string, md: markdownit): string {
return md.render(
`<div class="embed-container-note">${md.render(content)}</div>`
);
return `<div class="embed-container-note">${md.render(content)}</div>`;
}

function inlineFormatter(content: string, md: markdownit): string {
return md.render(content);
return content;
}

export default markdownItWikilinkEmbed;

0 comments on commit 2598689

Please sign in to comment.