fix: Handle special cases of LLM output not following markdown syntax 20250525

This commit introduces a utility function  to address rendering issues in LLM output, particularly for Chinese characters and parentheses. The function ensures minimal modification of the original text while fixing markdown parsing problems.

Changes include:
- Added  in  for handling specific cases.
- Updated  in  to incorporate the new utility.

The fix ensures proper rendering of bold/italic text containing Chinese parentheses, improving readability for non-English content.
This commit is contained in:
YuQX
2025-05-25 13:58:32 +08:00
parent ec97fdf5d6
commit 49fe137553
2 changed files with 87 additions and 0 deletions
+6
View File
@@ -20,6 +20,8 @@ import markedExtension from '$lib/utils/marked/extension';
import markedKatexExtension from '$lib/utils/marked/katex-extension';
import hljs from 'highlight.js';
import { specialCases } from '$lib/utils/processResponseContent/special-cases'
//////////////////////////
// Helper functions
//////////////////////////
@@ -90,6 +92,9 @@ export const sanitizeResponseContent = (content: string) => {
};
export const processResponseContent = (content: string) => {
// This function is used to process the response content
// before the response content is rendered.
content = specialCases(content);
return content.trim();
};
@@ -324,6 +329,7 @@ export const copyToClipboard = async (text, formatted = false) => {
};
marked.use(markedKatexExtension(options));
marked.use(markedExtension(options));
// DEVELOPER NOTE: Go to `$lib/components/chat/Messages/Markdown.svelte` to add extra markdown extensions for rendering.
const htmlContent = marked.parse(text);