From f5ce19220d9a5fe9aa69977dc982716d200d7404 Mon Sep 17 00:00:00 2001 From: H1d3rOne Date: Sat, 7 Mar 2026 18:07:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4AI=E8=A7=A3=E9=87=8A?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=AF=8F=E8=A1=8C=E5=BC=80=E5=A4=B4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=A0=BC/=E7=BC=A9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用trimStart()移除每行开头的空格 - 移除段落首行缩进(text-indent) - 确保内容顶格显示 --- xuan-deduct-uniapp/src/utils/markdownToHtml.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xuan-deduct-uniapp/src/utils/markdownToHtml.js b/xuan-deduct-uniapp/src/utils/markdownToHtml.js index 9a7815c..b6c7619 100644 --- a/xuan-deduct-uniapp/src/utils/markdownToHtml.js +++ b/xuan-deduct-uniapp/src/utils/markdownToHtml.js @@ -6,7 +6,7 @@ export function markdownToHtml(markdown) { const lines = html.split('\n') if (lines.length > 0) { lines.shift() - html = lines.join('\n').trim() + html = lines.map(line => line.trimStart()).join('\n').trim() } html = html.replace(/^### (.*$)/gim, '

$1

') @@ -20,19 +20,19 @@ export function markdownToHtml(markdown) { html = html.replace(/_(.+?)_/g, '$1') html = html.replace(/`(.+?)`/g, '$1') - html = html.replace(/^\s*[-•]\s(.+)$/gim, '
  • $1
  • ') - html = html.replace(/^\s*\*\s(.+)$/gim, '
  • $1
  • ') - html = html.replace(/^\s*\+\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^[-•]\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^\*\s(.+)$/gim, '
  • $1
  • ') + html = html.replace(/^\+\s(.+)$/gim, '
  • $1
  • ') html = html.replace(/(]*>.*<\/li>\n?)+/g, function(match) { return '' }) - html = html.replace(/\n\n/g, '

    ') + html = html.replace(/\n\n/g, '

    ') html = html.replace(/\n/g, '
    ') if (!html.startsWith('<')) { - html = '

    ' + html + '

    ' + html = '

    ' + html + '

    ' } return html