From c8edb8fcc738a1d4ccc43c61475a6b47fcb1d4eb Mon Sep 17 00:00:00 2001 From: Fedor Katurov <gotham48@gmail.com> Date: Fri, 10 Apr 2020 17:16:49 +0700 Subject: [PATCH] added some markdown --- .../comment/CommentTextBlock/styles.scss | 17 ++++++++++++++++- src/utils/dom.ts | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/comment/CommentTextBlock/styles.scss b/src/components/comment/CommentTextBlock/styles.scss index 6a14f11c..b3430bc6 100644 --- a/src/components/comment/CommentTextBlock/styles.scss +++ b/src/components/comment/CommentTextBlock/styles.scss @@ -7,8 +7,23 @@ position: relative; color: #cccccc; word-break: break-word; + width: 100%; b { - font-weight: 600; + font-weight: 900; + } + + i { + font-style: italic; + } + + hr { + height: 1px; + background: rgba(255, 255, 255, 0.1); + border: none; + } + + :global(.green) { + color: $wisegreen; } } diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 3d658418..21a1dfbd 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -94,7 +94,11 @@ export const formatText = (text: string): string => ) .replace(/:\/\//gim, ':|--|') .replace(/(\/\/[^\n]+)/gim, '<span class="grey">$1</span>') + .replace(/(\*\*[\s\S]*?\*\*)/gim, '<b class="bold white">$1</b>') + .replace(/(\_\_[\s\S]*?\_\_)/gim, '<i>$1</i>') + .replace(/(\!\![\s\S]*?(\!\!|\n|$))/gim, '<span class="green">$1</span>') .replace(/(\/\*[\s\S]*?\*\/)/gim, '<span class="grey">$1</span>') + .replace(/([=|-]{5,})/gim, '<hr />') .replace(/:\|--\|/gim, '://') .split('\n') .filter(el => el.trim().length)