mirror of
https://github.com/comeonzhj/Auto-Redbook-Skills.git
synced 2026-03-27 12:49:27 +08:00
Merge pull request #5 from rebill/main
This commit is contained in:
@@ -58,7 +58,8 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
word-break: break-all;
|
word-break: normal;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cover-subtitle {
|
.cover-subtitle {
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ body {
|
|||||||
-webkit-text-fill-color: transparent;
|
-webkit-text-fill-color: transparent;
|
||||||
background-clip: text;
|
background-clip: text;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
word-break: break-all;
|
word-break: normal;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cover-subtitle {
|
.cover-subtitle {
|
||||||
@@ -199,7 +200,9 @@ body {
|
|||||||
overflow-x: visible;
|
overflow-x: visible;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
word-break: break-all;
|
overflow-wrap: break-word;
|
||||||
|
word-wrap: break-word;
|
||||||
|
word-break: normal;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
@@ -315,4 +318,4 @@ body {
|
|||||||
|
|
||||||
.bg-gradient-8 {
|
.bg-gradient-8 {
|
||||||
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
|
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
|
||||||
}
|
}
|
||||||
10
package.json
10
package.json
@@ -2,9 +2,9 @@
|
|||||||
"name": "md2redbook",
|
"name": "md2redbook",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"description": "小红书笔记素材创作工具 - 支持多种排版样式和智能分页",
|
"description": "小红书笔记素材创作工具 - 支持多种排版样式和智能分页",
|
||||||
"main": "scripts/render_xhs.js",
|
"main": "scripts/render_xhs_v2.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"render": "node scripts/render_xhs.js",
|
"render": "node scripts/render_xhs_v2.js",
|
||||||
"install-browsers": "npx playwright install chromium"
|
"install-browsers": "npx playwright install chromium"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"marked": "^11.0.0",
|
"marked": "^11.0.0",
|
||||||
"yaml": "^2.3.0",
|
"playwright": "^1.58.0"
|
||||||
"playwright": "^1.40.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,12 +148,20 @@ def generate_cover_html(metadata: dict, theme: str, width: int, height: int) ->
|
|||||||
title = metadata.get('title', '标题')
|
title = metadata.get('title', '标题')
|
||||||
subtitle = metadata.get('subtitle', '')
|
subtitle = metadata.get('subtitle', '')
|
||||||
|
|
||||||
# 限制标题和副标题长度
|
|
||||||
if len(title) > 15:
|
|
||||||
title = title[:15]
|
|
||||||
if len(subtitle) > 15:
|
|
||||||
subtitle = subtitle[:15]
|
|
||||||
|
|
||||||
|
# 动态调整标题字体大小
|
||||||
|
title_len = len(title)
|
||||||
|
if title_len <= 6:
|
||||||
|
title_size = int(width * 0.14) # 极大
|
||||||
|
elif title_len <= 10:
|
||||||
|
title_size = int(width * 0.12) # 大
|
||||||
|
elif title_len <= 18:
|
||||||
|
title_size = int(width * 0.09) # 中
|
||||||
|
elif title_len <= 30:
|
||||||
|
title_size = int(width * 0.07) # 小
|
||||||
|
else:
|
||||||
|
title_size = int(width * 0.055) # 极小
|
||||||
|
|
||||||
# 获取主题背景色
|
# 获取主题背景色
|
||||||
theme_backgrounds = {
|
theme_backgrounds = {
|
||||||
'default': 'linear-gradient(180deg, #f3f3f3 0%, #f9f9f9 100%)',
|
'default': 'linear-gradient(180deg, #f3f3f3 0%, #f9f9f9 100%)',
|
||||||
@@ -231,7 +239,7 @@ def generate_cover_html(metadata: dict, theme: str, width: int, height: int) ->
|
|||||||
|
|
||||||
.cover-title {{
|
.cover-title {{
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
font-size: {int(width * 0.12)}px;
|
font-size: {title_size}px;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
background: {title_bg};
|
background: {title_bg};
|
||||||
-webkit-background-clip: text;
|
-webkit-background-clip: text;
|
||||||
|
|||||||
@@ -295,12 +295,20 @@ def generate_cover_html(metadata: dict, style_key: str = "purple") -> str:
|
|||||||
title = metadata.get('title', '标题')
|
title = metadata.get('title', '标题')
|
||||||
subtitle = metadata.get('subtitle', '')
|
subtitle = metadata.get('subtitle', '')
|
||||||
|
|
||||||
# 限制标题和副标题长度
|
|
||||||
if len(title) > 15:
|
|
||||||
title = title[:15]
|
|
||||||
if len(subtitle) > 15:
|
|
||||||
subtitle = subtitle[:15]
|
|
||||||
|
|
||||||
|
# 动态调整标题字体大小
|
||||||
|
title_len = len(title)
|
||||||
|
if title_len <= 6:
|
||||||
|
title_size = 150 # 极大 (width * 0.14)
|
||||||
|
elif title_len <= 10:
|
||||||
|
title_size = 130 # 大 (width * 0.12)
|
||||||
|
elif title_len <= 18:
|
||||||
|
title_size = 100 # 中 (width * 0.09)
|
||||||
|
elif title_len <= 30:
|
||||||
|
title_size = 80 # 小 (width * 0.07)
|
||||||
|
else:
|
||||||
|
title_size = 60 # 极小 (width * 0.055)
|
||||||
|
|
||||||
# 暗黑模式特殊处理
|
# 暗黑模式特殊处理
|
||||||
is_dark = style_key == "dark"
|
is_dark = style_key == "dark"
|
||||||
text_color = "#ffffff" if is_dark else "#000000"
|
text_color = "#ffffff" if is_dark else "#000000"
|
||||||
@@ -335,14 +343,15 @@ def generate_cover_html(metadata: dict, style_key: str = "purple") -> str:
|
|||||||
}}
|
}}
|
||||||
.cover-emoji {{ font-size: 180px; line-height: 1.2; margin-bottom: 50px; }}
|
.cover-emoji {{ font-size: 180px; line-height: 1.2; margin-bottom: 50px; }}
|
||||||
.cover-title {{
|
.cover-title {{
|
||||||
font-weight: 900; font-size: 130px; line-height: 1.4;
|
font-weight: 900; font-size: {title_size}px; line-height: 1.4;
|
||||||
background: {title_gradient};
|
background: {title_gradient};
|
||||||
-webkit-background-clip: text;
|
-webkit-background-clip: text;
|
||||||
-webkit-text-fill-color: transparent;
|
-webkit-text-fill-color: transparent;
|
||||||
background-clip: text;
|
background-clip: text;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex; align-items: flex-start;
|
display: flex; align-items: flex-start;
|
||||||
word-break: break-all;
|
word-break: normal;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}}
|
}}
|
||||||
.cover-subtitle {{
|
.cover-subtitle {{
|
||||||
font-weight: 350; font-size: 72px; line-height: 1.4;
|
font-weight: 350; font-size: 72px; line-height: 1.4;
|
||||||
@@ -463,7 +472,8 @@ def generate_card_html(content: str, page_number: int = 1, total_pages: int = 1,
|
|||||||
overflow-x: visible;
|
overflow-x: visible;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
word-break: break-all;
|
word-break: normal;
|
||||||
|
overflow-wrap: break-word;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-size: 36px; line-height: 1.5;
|
font-size: 36px; line-height: 1.5;
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user