diff --git a/web/src/ChatBox.js b/web/src/ChatBox.js index d0a0f3072..6c9d01eef 100644 --- a/web/src/ChatBox.js +++ b/web/src/ChatBox.js @@ -15,27 +15,10 @@ import React from "react"; import {Avatar, ChatContainer, ConversationHeader, MainContainer, Message, MessageInput, MessageList} from "@chatscope/chat-ui-kit-react"; import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css"; -import {marked} from "marked"; -import DOMPurify from "dompurify"; -import katex from "katex"; -import "katex/dist/katex.min.css"; -import hljs from "highlight.js"; -import "highlight.js/styles/atom-one-dark-reasonable.css"; import * as Conf from "./Conf"; import * as Setting from "./Setting"; import i18next from "i18next"; -marked.setOptions({ - renderer: new marked.Renderer(), - gfm: true, - tables: true, - breaks: true, - pedantic: false, - sanitize: false, - smartLists: true, - smartypants: true, -}); - class ChatBox extends React.Component { constructor(props) { super(props); @@ -117,61 +100,6 @@ class ChatBox extends React.Component { reader.readAsDataURL(file); }; - renderMarkdown(text) { - if (text === "") { - text = this.state.dots; - } - const rawHtml = marked(text); - let cleanHtml = DOMPurify.sanitize(rawHtml); - /* replace

with
, reduce paragraph spacing. */ - cleanHtml = cleanHtml.replace(/

/g, "

").replace(/<\/p>/g, "
"); - /* h2 is larger than h1, h2 is the largest, so replace h1 with h2, and set margin as 20px. */ - cleanHtml = cleanHtml.replace(/

/g, "

").replace(/<(h[1-6])>/g, "<$1 style='margin-top: 20px; margin-bottom: 20px'>"); - /* adjust margin and internal gap for unordered list and ordered list. */ - cleanHtml = cleanHtml.replace(/<(ul)>/g, "