From 509cf7d9b1a685bf58a980a1b3b08f0ec7e210bd Mon Sep 17 00:00:00 2001 From: Damian Stasik <920747+damianstasik@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:36:42 +0200 Subject: [PATCH] Do not trim admonition content Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> --- frontend/src/components/Markdown/P.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/Markdown/P.tsx b/frontend/src/components/Markdown/P.tsx index 22c81b85..f796cac5 100644 --- a/frontend/src/components/Markdown/P.tsx +++ b/frontend/src/components/Markdown/P.tsx @@ -20,26 +20,28 @@ function getAdmonitionClassName(prefix: string) { } function getAdmonitionMatch(children: ReactNode) { - let content = ""; + let text = ""; if (typeof children === "string") { - content = children; + text = children; } else if (Array.isArray(children) && typeof children[0] === "string") { - content = children[0]; + text = children[0]; } - if (!content) { + if (!text) { return null; } if ( - content.startsWith(WARNING_MARK) || - content.startsWith(DANGER_MARK) || - content.startsWith(NOTE_MARK) + text.startsWith(WARNING_MARK) || + text.startsWith(DANGER_MARK) || + text.startsWith(NOTE_MARK) ) { + const content = text.slice(2); + return { - prefix: content.slice(0, 2), - content: content.slice(2).trim(), + prefix: text.slice(0, 2), + content: content.trim() ? content : null, }; }