mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-13 22:29:48 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e63e21786d | |||
| b3a3b632c8 | |||
| 3aafe60463 | |||
| 246e90bf28 |
@@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
||||||
"version": "2.0.0"
|
"version": "2.0.1"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
English | [中文](./CHANGELOG.zh.md)
|
English | [中文](./CHANGELOG.zh.md)
|
||||||
|
|
||||||
|
## 2.0.1 - 2026-05-24
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- `baoyu-post-to-wechat`: convert `newspic` (image-text) `content` from HTML to plain text before sending to the WeChat draft API. The previous behavior passed raw HTML, triggering error 45166 (invalid content) when multiple images pushed the body over WeChat's length limit. The new `htmlToPlainText` helper turns `<br>` and block-closing tags into line breaks, strips remaining tags, decodes named/numeric (decimal and hex) entities, and collapses whitespace (by @Go1dFinger, [#164](https://github.com/JimLiu/baoyu-skills/pull/164), closes [#163](https://github.com/JimLiu/baoyu-skills/issues/163))
|
||||||
|
|
||||||
|
### Credits
|
||||||
|
- `baoyu-post-to-wechat` newspic plain-text fix contributed by @Go1dFinger ([#164](https://github.com/JimLiu/baoyu-skills/pull/164))
|
||||||
|
|
||||||
## 2.0.0 - 2026-05-24
|
## 2.0.0 - 2026-05-24
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
[English](./CHANGELOG.md) | 中文
|
[English](./CHANGELOG.md) | 中文
|
||||||
|
|
||||||
|
## 2.0.1 - 2026-05-24
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
- `baoyu-post-to-wechat`:发布 `newspic`(图文)时,将 `content` 字段从 HTML 转换为纯文本后再提交微信草稿接口。此前直接传 HTML,多图场景下内容长度超出限制会触发错误 45166(invalid content)。新增 `htmlToPlainText` 工具:把 `<br>` 和块级闭合标签转成换行、剥离其余标签、解码命名实体与十进制/十六进制数字实体、合并多余空白 (by @Go1dFinger, [#164](https://github.com/JimLiu/baoyu-skills/pull/164), 关联 [#163](https://github.com/JimLiu/baoyu-skills/issues/163))
|
||||||
|
|
||||||
|
### 致谢
|
||||||
|
- `baoyu-post-to-wechat` 的 newspic 纯文本修复由 @Go1dFinger 贡献([#164](https://github.com/JimLiu/baoyu-skills/pull/164))
|
||||||
|
|
||||||
## 2.0.0 - 2026-05-24
|
## 2.0.0 - 2026-05-24
|
||||||
|
|
||||||
### 破坏性变更
|
### 破坏性变更
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: baoyu-article-illustrator
|
name: baoyu-article-illustrator
|
||||||
description: Analyzes article structure, identifies positions requiring visual aids, generates illustrations with Type × Style × Palette three-dimension approach. Use when user asks to "illustrate article", "add images", "generate images for article", or "为文章配图".
|
description: Analyzes article structure, identifies positions requiring visual aids, generates illustrations with Type × Style × Palette three-dimension approach. Use when user asks to "illustrate article", "add images", "generate images for article", or "为文章配图".
|
||||||
version: 1.59.1
|
version: 1.117.3
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-article-illustrator
|
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-article-illustrator
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: baoyu-comic
|
name: baoyu-comic
|
||||||
description: Knowledge comic creator supporting multiple art styles and tones. Creates original educational comics with detailed panel layouts and batch-capable image generation. Use when user asks to create "知识漫画", "教育漫画", "biography comic", "tutorial comic", or "Logicomix-style comic".
|
description: Knowledge comic creator supporting multiple art styles and tones. Creates original educational comics with detailed panel layouts and batch-capable image generation. Use when user asks to create "知识漫画", "教育漫画", "biography comic", "tutorial comic", or "Logicomix-style comic".
|
||||||
version: 1.57.1
|
version: 1.117.3
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-comic
|
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-comic
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: baoyu-infographic
|
name: baoyu-infographic
|
||||||
description: Generate professional infographics with 21 layout types and 22 visual styles. Analyzes content, recommends layout×style combinations, and generates publication-ready infographics. Use when user asks to create "infographic", "信息图", "visual summary", "可视化", or "高密度信息大图".
|
description: Generate professional infographics with 21 layout types and 22 visual styles. Analyzes content, recommends layout×style combinations, and generates publication-ready infographics. Use when user asks to create "infographic", "信息图", "visual summary", "可视化", or "高密度信息大图".
|
||||||
version: 1.58.1
|
version: 1.117.3
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-infographic
|
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-infographic
|
||||||
|
|||||||
@@ -99,6 +99,63 @@ function toHttpsUrl(url: string | undefined): string {
|
|||||||
return url.startsWith("http://") ? url.replace(/^http:\/\//i, "https://") : url;
|
return url.startsWith("http://") ? url.replace(/^http:\/\//i, "https://") : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function htmlToPlainText(html: string): string {
|
||||||
|
if (!html) return "";
|
||||||
|
|
||||||
|
let text = html;
|
||||||
|
|
||||||
|
// 1. 将 <br>, <br/>, <br /> 替换为换行符
|
||||||
|
text = text.replace(/<br\s*\/?>/gi, "\n");
|
||||||
|
|
||||||
|
// 2. 将 </p>, </div>, </h1>, </h2>, </h3>, </h4>, </h5>, </h6>, </li> 替换为换行符
|
||||||
|
text = text.replace(/<\/(?:p|div|h[1-6]|li|tr|td|th)>/gi, "\n");
|
||||||
|
|
||||||
|
// 3. 去掉所有剩余的 HTML 标签
|
||||||
|
text = text.replace(/<[^>]+>/g, "");
|
||||||
|
|
||||||
|
// 4. 解码 HTML 实体
|
||||||
|
const entityMap: Record<string, string> = {
|
||||||
|
" ": " ",
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
"&": "&",
|
||||||
|
""": '"',
|
||||||
|
"'": "'",
|
||||||
|
"'": "'",
|
||||||
|
"—": "—",
|
||||||
|
"–": "–",
|
||||||
|
"…": "…",
|
||||||
|
"“": "“",
|
||||||
|
"”": "”",
|
||||||
|
"‘": "‘",
|
||||||
|
"’": "’",
|
||||||
|
};
|
||||||
|
text = text.replace(/&(?:[a-zA-Z]+|#x[0-9a-fA-F]+|#\d+);/g, (entity) => {
|
||||||
|
if (entityMap[entity]) return entityMap[entity];
|
||||||
|
const hexMatch = entity.match(/^&#x([0-9a-fA-F]+);$/);
|
||||||
|
if (hexMatch) {
|
||||||
|
return String.fromCodePoint(Number.parseInt(hexMatch[1]!, 16));
|
||||||
|
}
|
||||||
|
const numMatch = entity.match(/^&#(\d+);$/);
|
||||||
|
if (numMatch) {
|
||||||
|
return String.fromCodePoint(Number.parseInt(numMatch[1]!, 10));
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 5. 合并多个连续空白字符(空格、制表符、换行)为一个空格
|
||||||
|
text = text.replace(/[ \t]+/g, " ");
|
||||||
|
|
||||||
|
// 6. 合并多个连续换行为一个换行
|
||||||
|
text = text.replace(/\n{3,}/g, "\n\n");
|
||||||
|
|
||||||
|
// 7. 去掉行首行尾空白
|
||||||
|
text = text.split("\n").map(line => line.trim()).join("\n");
|
||||||
|
|
||||||
|
// 8. 最终 trim
|
||||||
|
return text.trim();
|
||||||
|
}
|
||||||
|
|
||||||
async function uploadImage(
|
async function uploadImage(
|
||||||
imagePath: string,
|
imagePath: string,
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
@@ -295,10 +352,15 @@ async function publishToDraft(
|
|||||||
if (!options.imageMediaIds || options.imageMediaIds.length === 0) {
|
if (!options.imageMediaIds || options.imageMediaIds.length === 0) {
|
||||||
throw new Error("newspic requires at least one image");
|
throw new Error("newspic requires at least one image");
|
||||||
}
|
}
|
||||||
|
// newspic 的 content 应该是纯文本,需要:
|
||||||
|
// 1. 去掉 HTML 标签
|
||||||
|
// 2. 解码 HTML 实体( 、< 等)
|
||||||
|
// 3. 合并多余空白字符
|
||||||
|
const plainContent = htmlToPlainText(options.content);
|
||||||
article = {
|
article = {
|
||||||
article_type: "newspic",
|
article_type: "newspic",
|
||||||
title: options.title,
|
title: options.title,
|
||||||
content: options.content,
|
content: plainContent,
|
||||||
need_open_comment: noc,
|
need_open_comment: noc,
|
||||||
only_fans_can_comment: ofcc,
|
only_fans_can_comment: ofcc,
|
||||||
image_info: {
|
image_info: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: baoyu-slide-deck
|
name: baoyu-slide-deck
|
||||||
description: Generates professional slide deck images from content. Creates outlines with style instructions, then generates individual slide images. Use when user asks to "create slides", "make a presentation", "generate deck", "slide deck", or "PPT".
|
description: Generates professional slide deck images from content. Creates outlines with style instructions, then generates individual slide images. Use when user asks to "create slides", "make a presentation", "generate deck", "slide deck", or "PPT".
|
||||||
version: 1.57.1
|
version: 1.117.3
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-slide-deck
|
homepage: https://github.com/JimLiu/baoyu-skills#baoyu-slide-deck
|
||||||
|
|||||||
Reference in New Issue
Block a user