Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: Correctly render multiple think blocks in Markdown (#18310)

sayThQ199b287aaccecfa
diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx
index 24ae59af73b..d50c397177f 100644
--- a/web/app/components/base/markdown.tsx
+++ b/web/app/components/base/markdown.tsx
@@ -85,9 +85,11 @@ const preprocessLaTeX = (content: string) => {
}
const preprocessThinkTag = (content: string) => {
+ const thinkOpenTagRegex = /<think>\n/g
+ const thinkCloseTagRegex = /\n<\/think>/g
return flow([
- (str: string) => str.replace('<think>\n', '<details data-think=true>\n'),
- (str: string) => str.replace('\n</think>', '\n[ENDTHINKFLAG]</details>'),
+ (str: string) => str.replace(thinkOpenTagRegex, '<details data-think=true>\n'),
+ (str: string) => str.replace(thinkCloseTagRegex, '\n[ENDTHINKFLAG]</details>'),
])(content)
}