We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3aca9e5 commit aa1c560Copy full SHA for aa1c560
1 file changed
packages/ui/src/components/markdown.tsx
@@ -2,9 +2,18 @@ import { useMarked } from "../context/marked"
2
import { ComponentProps, createResource, splitProps } from "solid-js"
3
4
function strip(text: string): string {
5
- const wrappedRe = /^\s*<([A-Za-z]\w*)>\s*([\s\S]*?)\s*<\/\1>\s*$/
6
- const match = text.match(wrappedRe)
7
- return match ? match[2] : text
+ const trimmed = text.trim()
+ const match = trimmed.match(/^<([A-Za-z]\w*)>/)
+ if (!match) return text
8
+
9
+ const tagName = match[1]
10
+ const closingTag = `</${tagName}>`
11
+ if (trimmed.endsWith(closingTag)) {
12
+ const content = trimmed.slice(match[0].length, -closingTag.length)
13
+ return content.trim()
14
+ }
15
16
+ return text
17
}
18
19
export function Markdown(
0 commit comments