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: dollar-sign escaping in preprocessLaTeX code‐block handling (#21796)

ShadowJobs86179beaa554
diff --git a/web/app/components/base/markdown/markdown-utils.ts b/web/app/components/base/markdown/markdown-utils.ts
index dc3c7a97846..209fcd0b329 100644
--- a/web/app/components/base/markdown/markdown-utils.ts
+++ b/web/app/components/base/markdown/markdown-utils.ts
@@ -11,6 +11,7 @@ export const preprocessLaTeX = (content: string) => {
const codeBlockRegex = /```[\s\S]*?```/g
const codeBlocks = content.match(codeBlockRegex) || []
+ const escapeReplacement = (str: string) => str.replace(/\$/g, '_TMP_REPLACE_DOLLAR_')
let processedContent = content.replace(codeBlockRegex, 'CODE_BLOCK_PLACEHOLDER')
processedContent = flow([
@@ -21,9 +22,11 @@ export const preprocessLaTeX = (content: string) => {
])(processedContent)
codeBlocks.forEach((block) => {
- processedContent = processedContent.replace('CODE_BLOCK_PLACEHOLDER', block)
+ processedContent = processedContent.replace('CODE_BLOCK_PLACEHOLDER', escapeReplacement(block))
})
+ processedContent = processedContent.replace(/_TMP_REPLACE_DOLLAR_/g, '$')
+
return processedContent
}