Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
水玉婷
ai-wechat
Commits
f5683e1f
Commit
f5683e1f
authored
Dec 04, 2025
by
水玉婷
Browse files
feat:优化md引用块
parent
e34be04d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/views/components/utils/markdownTemplate.ts
View file @
f5683e1f
...
@@ -83,7 +83,13 @@ export const parseMarkdown = (text: string): string => {
...
@@ -83,7 +83,13 @@ export const parseMarkdown = (text: string): string => {
}
}
// 处理引用块(必须在HTML转义之前,避免>被转义为>)
// 处理引用块(必须在HTML转义之前,避免>被转义为>)
text
=
text
.
replace
(
/^>
\s
*
(
.*
)
$/gim
,
'
<blockquote>$1</blockquote>
'
);
// 改进的多行引用块处理,支持连续引用行
text
=
text
.
replace
(
/^>
\s
*
(
.*
(?:\n
>
\s
*.*
)
*
)
$/gim
,
(
match
,
content
)
=>
{
// 将多行引用内容合并,并用<br>分隔
const
lines
=
content
.
split
(
/
\n
>
\s
*/
);
const
processedContent
=
lines
.
map
(
line
=>
line
.
trim
()).
join
(
'
<br>
'
);
return
`<blockquote>
${
processedContent
}
</blockquote>`
;
});
// 处理图片(必须在任何格式处理之前,避免图片格式被破坏)
// 处理图片(必须在任何格式处理之前,避免图片格式被破坏)
text
=
text
.
replace
(
/!
\[([^\]]
*
)\]\(([^\)]
+
)\)
/g
,
(
match
,
alt
,
src
)
=>
{
text
=
text
.
replace
(
/!
\[([^\]]
*
)\]\(([^\)]
+
)\)
/g
,
(
match
,
alt
,
src
)
=>
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment