fix: fix markdown escape issue (#30299)

This commit is contained in:
wangxiaolei 2025-12-30 16:40:52 +08:00 committed by GitHub
parent c1af6a7127
commit bf76f10653
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -18,12 +18,19 @@ const BasicContent: FC<BasicContentProps> = ({
if (annotation?.logAnnotation)
return <Markdown content={annotation?.logAnnotation.content || ''} />
// Preserve Windows UNC paths and similar backslash-heavy strings by
// wrapping them in inline code so Markdown renders backslashes verbatim.
let displayContent = content
if (typeof content === 'string' && /^\\\\\S.*/.test(content) && !/^`.*`$/.test(content)) {
displayContent = `\`${content}\``
}
return (
<Markdown
className={cn(
item.isError && '!text-[#F04438]',
)}
content={content}
content={displayContent}
/>
)
}

View File

@ -111,7 +111,7 @@ const Answer: FC<AnswerProps> = ({
}
}, [switchSibling, item.prevSibling, item.nextSibling])
const contentIsEmpty = content.trim() === ''
const contentIsEmpty = typeof content === 'string' && content.trim() === ''
return (
<div className="mb-2 flex last:mb-0">