diff --git a/components/Markdown.tsx b/components/Markdown.tsx index dd6f9a7..1af8000 100644 --- a/components/Markdown.tsx +++ b/components/Markdown.tsx @@ -5,7 +5,7 @@ import Emoji from 'node-emoji' const Markdown = ({ text }:MarkdownProps):JSX.Element => { return
- sanitizeHtml(html, { + sanitizeHtml(html, { allowedTags: [ 'addr', 'address', 'article', 'aside', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'section', 'blockquote', 'dd', 'div', diff --git a/utils/Regex.ts b/utils/Regex.ts index 35bb69f..dd8e1d4 100644 --- a/utils/Regex.ts +++ b/utils/Regex.ts @@ -9,3 +9,4 @@ export const Url = urlRegex({ strict: true }) export const Emoji = '(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])' export const Heading = '(.*?)<\\/h(\\d)>' export const EmojiSyntax = ':(\\w+):' +export const ImageTag = /]*?alt\s*=\s*['"]([^'"]*?)['"][^>]*?>/ diff --git a/utils/ShowdownExtensions.ts b/utils/ShowdownExtensions.ts index 340c363..34a4e27 100644 --- a/utils/ShowdownExtensions.ts +++ b/utils/ShowdownExtensions.ts @@ -1,4 +1,4 @@ -import { Emoji, EmojiSyntax, Heading } from './Regex' +import { Emoji, EmojiSyntax, Heading, ImageTag } from './Regex' import Twemoji from 'twemoji' import { KoreanbotsEmoji } from './Constants' @@ -8,13 +8,14 @@ export const anchorHeader = { replace: function (__match: string, id:string, title:string, level:number) { // github anchor style - const octicon_html = `` - return `${octicon_html}${title}` + return `${octicon_html}${title}` } } @@ -23,8 +24,10 @@ export const twemoji = { regex: `${Emoji}{2}|${Emoji}`, replace: function(__match: string, two: string, one: string) { const parsed = __match || two || one + console.log(parsed) const emoj = Twemoji.parse(parsed, { folder: 'svg', ext: '.svg' }) if(!emoj) return parsed + console.log(emoj) return emoj } }