Revert "fix: 网页链接附带中文标点解析错误"
This reverts commit 16feb49e9e91382155c29d4f05ce6410b24e63bd.
This commit is contained in:
parent
9a6aad35b0
commit
26e3871688
@ -2,7 +2,7 @@ import 'katex/dist/katex.min.css'
|
|||||||
|
|
||||||
import { useSettings } from '@renderer/hooks/useSettings'
|
import { useSettings } from '@renderer/hooks/useSettings'
|
||||||
import { Message } from '@renderer/types'
|
import { Message } from '@renderer/types'
|
||||||
import { escapeBrackets, fixPunctuation, removeSvgEmptyLines, withGeminiGrounding } from '@renderer/utils/formats'
|
import { escapeBrackets, removeSvgEmptyLines, withGeminiGrounding } from '@renderer/utils/formats'
|
||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
import { FC, useMemo } from 'react'
|
import { FC, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@ -34,10 +34,8 @@ const Markdown: FC<Props> = ({ message }) => {
|
|||||||
const messageContent = useMemo(() => {
|
const messageContent = useMemo(() => {
|
||||||
const empty = isEmpty(message.content)
|
const empty = isEmpty(message.content)
|
||||||
const paused = message.status === 'paused'
|
const paused = message.status === 'paused'
|
||||||
let content = empty && paused ? t('message.chat.completion.paused') : withGeminiGrounding(message)
|
const content = empty && paused ? t('message.chat.completion.paused') : withGeminiGrounding(message)
|
||||||
content = removeSvgEmptyLines(escapeBrackets(content))
|
return removeSvgEmptyLines(escapeBrackets(content))
|
||||||
content = fixPunctuation(content)
|
|
||||||
return content
|
|
||||||
}, [message, t])
|
}, [message, t])
|
||||||
|
|
||||||
const rehypePlugins = useMemo(() => {
|
const rehypePlugins = useMemo(() => {
|
||||||
|
|||||||
@ -107,11 +107,3 @@ export function withMessageThought(message: Message) {
|
|||||||
|
|
||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fixPunctuation(text: string): string {
|
|
||||||
// 将网页链接后的中文标点符号与链接分开
|
|
||||||
return text.replace(
|
|
||||||
/(https?:\/\/[^\s)]+)(\p{P})/gu,
|
|
||||||
`<a href="$1" target="_blank" rel="noreferrer">$1</a><span style="margin-left: 0.2em;">$2</span>`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user