From 1d3fdefa1775729fce7be0925f67ed0cf5313b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=EB=8D=94?= Date: Fri, 29 Jan 2021 20:23:48 +0900 Subject: [PATCH] feat: added markdown component --- components/Markdown.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 components/Markdown.tsx diff --git a/components/Markdown.tsx b/components/Markdown.tsx new file mode 100644 index 0000000..f7ca5ba --- /dev/null +++ b/components/Markdown.tsx @@ -0,0 +1,27 @@ +import { anchorHeader } from '@utils/Tools' +import MarkdownView from 'react-showdown' +import sanitizeHtml from 'sanitize-html' + +const Markdown = ({ text }:MarkdownProps):JSX.Element => { + return
+ sanitizeHtml(html, { + allowedTags: [ + 'addr', 'address', 'article', 'aside', 'h1', 'h2', 'h3', 'h4', + 'h5', 'h6', 'section', 'blockquote', 'dd', 'div', + 'dl', 'dt', 'hr', 'li', 'ol', 'p', 'pre', + 'ul', 'a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'code', 'data', 'dfn', + 'em', 'i', 'kbd', 'mark', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', + 'small', 'span', 'strong', 'sub', 'sup', 'time', 'u', 'var', 'wbr', 'caption', + 'col', 'colgroup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'del', + 'img', 'svg', 'input' + ], + allowedAttributes: false + })} /> +
+} + +interface MarkdownProps { + text: string +} + +export default Markdown \ No newline at end of file