You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
675 B
26 lines
675 B
2 years ago
|
<script>
|
||
|
import snarkdown from "snarkdown";
|
||
|
|
||
|
export let content = "<b>Markdown:</b> No content? Forgot to #await?";
|
||
|
export let with_p = true;
|
||
|
export let using = snarkdown;
|
||
|
|
||
|
const render = () => {
|
||
|
// the documentation for snarkdown says do NOT use sanitize, read that
|
||
|
// as usual there are timing issues so give some default values
|
||
|
if(with_p && using === snarkdown) {
|
||
|
// weird that snarkdown doesn't do this, or maybe I just don't see the option
|
||
|
return content.split("\n\n").map(line => `<p>${using(line)}</p>`).join("\n");
|
||
|
} else {
|
||
|
return using(content);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
const html = render();
|
||
|
</script>
|
||
|
|
||
|
<div>
|
||
|
{@html html}
|
||
|
</div>
|