pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
360 stars 50 forks source link

Can I set an option (breaks: true) globally? #70

Closed marcfilleul closed 1 year ago

marcfilleul commented 1 year ago

Hi, I'd like to always render line breaks whenever I use a SvelteMarkdown component.

I just discovered some days ago that I could use:

import SvelteMarkdown from "svelte-markdown"
  let options = {
        breaks: true,
    }

then:

<SvelteMarkdown source={mysource} {options} />

But for now I have to add that anytime I want to use it, which isn't ideal.

Is there a way to use this option by default?

Thanks

marcfilleul commented 1 year ago

Nevermind, I post my solution here in case it helps.

I created my own wrapper component called Markdown.svelte:

<script>
    import SvelteMarkdown from "svelte-markdown";
    let options = {
        breaks: true
    };
    export let source;
</script>

<SvelteMarkdown {source} {options} />

So I just have to import and use Markdown.svelte with the source prop only :)