From 2ecd06ece91889cfd16d0917d6a32fe8d7f14f7b Mon Sep 17 00:00:00 2001 From: Maxime Cannoodt Date: Fri, 24 Jun 2022 21:28:18 +0200 Subject: [PATCH] callout --- webapp/src/lib/marked/renderers/Blockquote.svelte | 4 +++- webapp/src/lib/marked/renderers/Callout.svelte | 12 ++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/webapp/src/lib/marked/renderers/Blockquote.svelte b/webapp/src/lib/marked/renderers/Blockquote.svelte index 6960026..fcfc7a6 100644 --- a/webapp/src/lib/marked/renderers/Blockquote.svelte +++ b/webapp/src/lib/marked/renderers/Blockquote.svelte @@ -3,7 +3,9 @@ export let raw: string; - let isCallout: boolean = raw.split('\n')[0].match(/>\s?\[!(.+)\](\s.*)?/) != null; + let isCallout: boolean = raw.split('\n')[0].match(/>\s?\[!(.+)\](\s.*|$)/) != null; + + console.log(raw.split('\n')[0]); {#if isCallout} diff --git a/webapp/src/lib/marked/renderers/Callout.svelte b/webapp/src/lib/marked/renderers/Callout.svelte index c6cde67..7668483 100644 --- a/webapp/src/lib/marked/renderers/Callout.svelte +++ b/webapp/src/lib/marked/renderers/Callout.svelte @@ -10,20 +10,12 @@ $: if (content) { const titleElement = content.getElementsByTagName('p')[0]; - console.log(titleElement.innerText.split('\n')[0]); const match = titleElement.innerText.split('\n')[0].match(/\[!(.+)\](\s([\w\s]+))?/); - console.log(match); if (match) { - console.log(match.length); - type = match[1]; - title = match[2] ?? ''; - console.log(title); + type = match[1]?.trim(); + title = match[2]?.trim() ?? ''; } } - - // onMount(() => { - // console.log('mounted'); - // });