From ae1f38cdcc321c626fb6822a5bbccdbfa827fc1a Mon Sep 17 00:00:00 2001 From: 666ghj <670939375@qq.com> Date: Sat, 14 Feb 2026 18:25:20 +0800 Subject: [PATCH] fix(report_agent): improve markdown rendering by cleaning up
tags around block-level elements and enhancing list formatting --- frontend/src/components/Step4Report.vue | 12 +++++++----- frontend/src/components/Step5Interaction.vue | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Step4Report.vue b/frontend/src/components/Step4Report.vue index f383344..22f2bdc 100644 --- a/frontend/src/components/Step4Report.vue +++ b/frontend/src/components/Step4Report.vue @@ -1932,13 +1932,15 @@ const renderMarkdown = (content) => { html = html.replace(/(<\/h[2-5]>)<\/p>/g, '$1') html = html.replace(/

(|<\/ol>|<\/blockquote>|<\/pre>)<\/p>/g, '$1') - // 清理列表前后的
标签 - html = html.replace(/
\s*(|<\/ol>)\s*
/g, '$1') + // 清理块级元素前后的
标签 + html = html.replace(/
\s*(|<\/ol>|<\/blockquote>)\s*
/g, '$1') + // 清理


紧跟块级元素的情况(多余空行导致) + html = html.replace(/

(
\s*)+( 标签 html = html.replace(/(
\s*){2,}/g, '
') - // 清理列表后紧跟的段落开始标签前的
- html = html.replace(/(<\/ol>|<\/ul>)
( + html = html.replace(/(<\/ol>|<\/ul>|<\/blockquote>)
( 被段落内容隔开时,保持编号递增 const tokens = html.split(/(

    (?:
  1. ]*>[\s\S]*?<\/li>)+<\/ol>)/g) diff --git a/frontend/src/components/Step5Interaction.vue b/frontend/src/components/Step5Interaction.vue index d09de03..3d84c7c 100644 --- a/frontend/src/components/Step5Interaction.vue +++ b/frontend/src/components/Step5Interaction.vue @@ -599,13 +599,15 @@ const renderMarkdown = (content) => { html = html.replace(/(<\/h[2-5]>)<\/p>/g, '$1') html = html.replace(/

    (|<\/ol>|<\/blockquote>|<\/pre>)<\/p>/g, '$1') - // 清理列表前后的
    标签 - html = html.replace(/
    \s*(|<\/ol>)\s*
    /g, '$1') + // 清理块级元素前后的
    标签 + html = html.replace(/
    \s*(|<\/ol>|<\/blockquote>)\s*
    /g, '$1') + // 清理


    紧跟块级元素的情况(多余空行导致) + html = html.replace(/

    (
    \s*)+( 标签 html = html.replace(/(
    \s*){2,}/g, '
    ') - // 清理列表后紧跟的段落开始标签前的
    - html = html.replace(/(<\/ol>|<\/ul>)
    ( + html = html.replace(/(<\/ol>|<\/ul>|<\/blockquote>)
    ( 被段落内容隔开时,保持编号递增 const tokens = html.split(/(

      (?:
    1. ]*>[\s\S]*?<\/li>)+<\/ol>)/g)