Closed pi43r closed 2 years ago
The way to do this would be to override the Link
renderer. You can take the default one as a starting point and add your logic there. (E.g. check if the href
as a protocol to see if its an external link or not. Add icons for external links. Etc.) When you have your renderer, you can pass it to <SvelteMarkdown>
on its renderers
prop like this:
<script>
import Link from './CustomLink.svelte';
export let source;
const renderers = {
link: Link,
}
</script>
<SvelteMarkdown {source} {renderers} />
The parsed
event is only to provide you a way to access to your the content after it's been parsed. For example, to add a table of contents.
I'm closing this, since it's not an issue per se! But feel free to ask more questions.
This helped me a lot, thank you so much!
Can I add this somewhere in the
options
? I couldn't find it at the marked documentation.Or do I have to add it manually
on:parsed
?