Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai-box
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
青山
ai-box
Commits
d0e6a913
Commit
d0e6a913
authored
Mar 28, 2025
by
fisherdaddy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Enhance WechatFormatter with custom styles for heading elements
parent
1dbf7332
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
WechatFormatter.jsx
src/components/WechatFormatter.jsx
+8
-0
No files found.
src/components/WechatFormatter.jsx
View file @
d0e6a913
...
...
@@ -196,6 +196,14 @@ const WechatFormatter = () => {
html
=
text
;
}
// 处理标题,使用微信公众号兼容的样式
html
=
html
.
replace
(
/<h1>
(
.*
?)
<
\/
h1>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 24px; color: #333; display: block;">
\
$1</strong></section>'
);
html
=
html
.
replace
(
/<h2>
(
.*
?)
<
\/
h2>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 20px; color: #333; display: block;">
\
$1</strong></section>'
);
html
=
html
.
replace
(
/<h3>
(
.*
?)
<
\/
h3>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 18px; color: #333; display: block;">
\
$1</strong></section>'
);
html
=
html
.
replace
(
/<h4>
(
.*
?)
<
\/
h4>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 16px; color: #333; display: block;">
\
$1</strong></section>'
);
html
=
html
.
replace
(
/<h5>
(
.*
?)
<
\/
h5>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 15px; color: #333; display: block;">
\
$1</strong></section>'
);
html
=
html
.
replace
(
/<h6>
(
.*
?)
<
\/
h6>/g
,
'<section style="margin-top: 1.5em; margin-bottom: 0.5em;"><strong style="font-size: 14px; color: #333; display: block;">
\
$1</strong></section>'
);
// 添加微信公众号特定的样式
const
wechatHtml
=
`
<div class="wechat-content prose max-w-none">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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