From 8bac0023a2fb4d5172419e4c7e9a5b0de6be5698 Mon Sep 17 00:00:00 2001 From: yj-oh Date: Thu, 25 Nov 2021 06:51:30 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=ED=8F=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=9E=87=20|=20markdown=20=EC=A4=84=EB=B0=94=EA=BF=88?= =?UTF-8?q?=20=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 정규식을 이용하여 포스트잇 내용에 대한 문자열을 검사한다. 2. 개행문자 앞에 태그가 없을 경우 해당 개행문자를
태그로 치환한다. - 모든 개행문자를
로 단순 치환할 경우 태그 다음에 존재하는 개행문자까지 변환되어 줄 간격이 지나치게 벌어지는 문제가 생기기 때문. fixed #5 --- src/components/PostIt.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/PostIt.svelte b/src/components/PostIt.svelte index d308cdd..aed2698 100644 --- a/src/components/PostIt.svelte +++ b/src/components/PostIt.svelte @@ -151,6 +151,11 @@ return list.filter(postIt => postIt.id !== id); }); } + + function convertMarkdownToHtml(markdown) { + const html = marked(markdown); + return html.replaceAll(/(?)\n/gm, '
'); + }
{content} {:else}
-
{@html marked(content)}
+
{@html convertMarkdownToHtml(content)}
{/if}