web(markdown): support <think> without trailing newline in preprocessThinkTag (#27776)

Signed-off-by: SherlockShemol <shemol@163.com>
This commit is contained in:
Shemol
2025-11-04 09:35:54 +08:00
committed by GitHub
parent 95471b1188
commit ed3d02dc6d

View File

@@ -32,8 +32,8 @@ export const preprocessLaTeX = (content: string) => {
}
export const preprocessThinkTag = (content: string) => {
const thinkOpenTagRegex = /(<think>\n)+/g
const thinkCloseTagRegex = /\n<\/think>/g
const thinkOpenTagRegex = /(<think>\s*)+/g
const thinkCloseTagRegex = /(\s*<\/think>)+/g
return flow([
(str: string) => str.replace(thinkOpenTagRegex, '<details data-think=true>\n'),
(str: string) => str.replace(thinkCloseTagRegex, '\n[ENDTHINKFLAG]</details>'),