Browse Source

fix(desktop): markdown rendering perf

Adam 2 months ago
parent
commit
583751ecae
1 changed files with 1 additions and 16 deletions
  1. 1 16
      packages/ui/src/components/markdown.tsx

+ 1 - 16
packages/ui/src/components/markdown.tsx

@@ -1,21 +1,6 @@
 import { useMarked } from "../context/marked"
 import { useMarked } from "../context/marked"
 import { ComponentProps, createResource, splitProps } from "solid-js"
 import { ComponentProps, createResource, splitProps } from "solid-js"
 
 
-function strip(text: string): string {
-  const trimmed = text.trim()
-  const match = trimmed.match(/^<([A-Za-z]\w*)>/)
-  if (!match) return text
-
-  const tagName = match[1]
-  const closingTag = `</${tagName}>`
-  if (trimmed.endsWith(closingTag)) {
-    const content = trimmed.slice(match[0].length, -closingTag.length)
-    return content.trim()
-  }
-
-  return text
-}
-
 export function Markdown(
 export function Markdown(
   props: ComponentProps<"div"> & {
   props: ComponentProps<"div"> & {
     text: string
     text: string
@@ -26,7 +11,7 @@ export function Markdown(
   const [local, others] = splitProps(props, ["text", "class", "classList"])
   const [local, others] = splitProps(props, ["text", "class", "classList"])
   const marked = useMarked()
   const marked = useMarked()
   const [html] = createResource(
   const [html] = createResource(
-    () => strip(local.text),
+    () => local.text,
     async (markdown) => {
     async (markdown) => {
       return marked.parse(markdown)
       return marked.parse(markdown)
     },
     },