From 54a92bf2c647842faa163ef40958c83c9f9cf58f Mon Sep 17 00:00:00 2001
From: vectorstone <39456045+vectorstone@users.noreply.github.com>
Date: Sun, 31 Aug 2025 12:28:50 +0800
Subject: [PATCH] fix: support rendering and display of and
tags (#9699)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 修复issue https://github.com/CherryHQ/cherry-studio/issues/9635,支持 和标签渲染展示,后期可以考虑做成配置化,允许用户自定义标签展示逻辑,或者扩展rehypeRaw插件标签识别逻辑,支持任意标签的渲染展示
* 修复issue https://github.com/CherryHQ/cherry-studio/issues/9635,支持 和标签渲染展示,后期可以考虑做成配置化,允许用户自定义标签展示逻辑,或者扩展rehypeRaw插件标签识别逻辑,支持任意标签的渲染展示
---
src/renderer/src/pages/home/Markdown/Markdown.tsx | 2 +-
src/renderer/src/utils/markdownConverter.ts | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/renderer/src/pages/home/Markdown/Markdown.tsx b/src/renderer/src/pages/home/Markdown/Markdown.tsx
index c636b6d784..6ff47e57a8 100644
--- a/src/renderer/src/pages/home/Markdown/Markdown.tsx
+++ b/src/renderer/src/pages/home/Markdown/Markdown.tsx
@@ -34,7 +34,7 @@ import remarkDisableConstructs from './plugins/remarkDisableConstructs'
import Table from './Table'
const ALLOWED_ELEMENTS =
- /<(style|p|div|span|b|i|strong|em|ul|ol|li|table|tr|td|th|thead|tbody|h[1-6]|blockquote|pre|code|br|hr|svg|path|circle|rect|line|polyline|polygon|text|g|defs|title|desc|tspan|sub|sup)/i
+ /<(style|p|div|span|b|i|strong|em|ul|ol|li|table|tr|td|th|thead|tbody|h[1-6]|blockquote|pre|code|br|hr|svg|path|circle|rect|line|polyline|polygon|text|g|defs|title|desc|tspan|sub|sup|details|summary)/i
const DISALLOWED_ELEMENTS = ['iframe', 'script']
interface Props {
diff --git a/src/renderer/src/utils/markdownConverter.ts b/src/renderer/src/utils/markdownConverter.ts
index 4332813968..0b905689b8 100644
--- a/src/renderer/src/utils/markdownConverter.ts
+++ b/src/renderer/src/utils/markdownConverter.ts
@@ -625,7 +625,9 @@ export const sanitizeHtml = (html: string): string => {
'td',
'th',
'input',
- 'label'
+ 'label',
+ 'details',
+ 'summary'
],
ALLOWED_ATTR: [
'href',