| | |
| | | export const hasChinese = (str: string) => { |
| | | return /[\u4e00-\u9fa5]/.test(str) |
| | | } |
| | | |
| | | export const formatReasoningContent = (content: string) => { |
| | | // 匹配 "数字" + "." + ("中文"或"空格") + "其他内容" + ":" |
| | | const stepRegex = /(\d+\.(?:[\u4e00-\u9fa5]|\s)[^:]*:)(\s*)/g; |
| | | |
| | | // 替换逻辑: |
| | | // - 如果标题后没有换行(即 `$2` 是空或只有空格),则添加 `<br>` |
| | | // - 如果标题后已有换行(如 `\n` 或 `<br>`),则不额外添加 |
| | | return content.replace( |
| | | stepRegex, |
| | | (match, title, whitespace) => { |
| | | const hasNewline = whitespace.includes('\\n') || whitespace.includes('<br>'); |
| | | const lineBreak = hasNewline ? '' : '<br>'; |
| | | return `<strong style="font-size: 16px; line-height: 32px; color: #FFFFFF;">${title}</strong>${lineBreak}`; |
| | | } |
| | | ); |
| | | } |