with one click
wenyan-editor-troubleshooting
文言排版器故障排查 - 路由问题、图片加载、分页问题
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
文言排版器故障排查 - 路由问题、图片加载、分页问题
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
高德地图综合服务,支持POI搜索、路径规划、旅游规划、周边搜索和热力图数据可视化
Knowledge comic creator supporting multiple art styles and tones. Creates original educational comics with detailed panel layouts and sequential image generation. Use when user asks to create "知识漫画", "教育漫画", "biography comic", "tutorial comic", or "Logicomix-style comic".
Generate professional infographics with 21 layout types and 21 visual styles. Analyzes content, recommends layout×style combinations, and generates publication-ready infographics. Use when user asks to create "infographic", "visual summary", "信息图", "可视化", or "高密度信息大图".
Darwin Skill (达尔文.skill): autonomous skill optimizer inspired by Karpathy's autoresearch. Evaluates SKILL.md files using an 8-dimension rubric (structure + effectiveness), runs hill-climbing with git version control, validates improvements through test prompts, and generates visual result cards. Use when user mentions "优化skill", "skill评分", "自动优化", "auto optimize", "skill质量检查", "达尔文", "darwin", "帮我改改skill", "skill怎么样", "提升skill质量", "skill review", "skill打分".
从 DESIGN.md 生成预览图并截图的工作流 - 解决 Playwright 浏览器路径问题和 YAML 解析
Cron jobs auto-deliver final responses to configured targets — send_message to the same target gets deduplicated and skipped. Print report content directly as final response instead.
| name | wenyan-editor-troubleshooting |
| description | 文言排版器故障排查 - 路由问题、图片加载、分页问题 |
| tags | ["wenyan-editor","flask","css","pagination"] |
原因:Flask 路由顺序问题,/<path:filename> catch-all 路由在具体路由之前定义,导致拦截了 /api/proxy-image
解决:确保 /api/proxy-image 路由定义在 /<path:filename> 之前
# 正确顺序
@app.route('/api/proxy-image')
def proxy_image():
...
@app.route('/<path:filename>')
def serve_frontend(filename):
...
原因:URL 中包含空格等特殊字符(如 Pasted image 20260520.png),未编码就放入 query string
解决:使用 encodeURIComponent() 编码 URL
result = result.replace(
/src="(https?:\/\/[^\"]+\.(?:png|jpg|jpeg|gif|webp|bmp|svg))"/gi,
(match, url) => `src="/api/proxy-image?url=${encodeURIComponent(url)}"`
);
解决:分页计算时预留底部空间
const BOTTOM_MARGIN = 60; // 预留底部空间给小红书装饰
const MAX_CONTENT_H = pageHeight - PADDING * 2 - BOTTOM_MARGIN;
原因:图片刚好在分页处,上方文字占用部分空间后,图片被截断
解决:简单方案 - 图片直接放到下一页,不尝试缩放(缩放逻辑复杂且有 bug)
// 更可靠地检测图片元素(包括 img、picture、figure 等)
const isImage = block.tagName.toLowerCase() === 'img' ||
(block.querySelector && block.querySelector('img') !== null);
// 图片直接放到下一页,避免截断
if (isImage && currentPage.length > 0) {
pages.push(currentPage.map(b => b.outerHTML).join('\n'));
currentPage = [block];
currentH = padding + bH;
continue;
}
注意:曾尝试根据可见比例缩放图片(可见部分 >= 50% 则缩放,< 50% 则移下一页),但 scale 计算有误差且不同页面测量不一致,最终放弃此方案。
原因:分页测量时每个 block 高度单独测量正常,但拼接后的 HTML 重新渲染时 margin/padding 累积,导致实际高度大于测量高度。
排查方法:在 doSplit 函数中添加调试日志,打印每个 block 的 tag 和高度:
function doSplit(blocks, padding, maxContentH) {
const debugLogs = [];
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i];
const bH = block.offsetHeight;
debugLogs.push(`block${i}: tag=${block.tagName}, h=${bH}`);
// ... 分页逻辑
}
console.log('分页调试:', debugLogs.join('\n'), `\n最终分页: ${pages.length}页`);
return pages;
}
解决:添加自动截断逻辑
box-sizing:border-box)overflow:hidden + 强制限制高度// 渲染后检测溢出
requestAnimationFrame(() => {
const actualH = wenyanDiv.offsetHeight;
const BOTTOM_MARGIN = 120;
const maxH = height - Math.round(width * 0.055) * 2 - BOTTOM_MARGIN;
if (actualH > maxH) {
// 内容超限,自动截断
content.style.overflow = 'hidden';
content.style.height = maxH + 'px';
}
});
// htmlToImage 使用实际高度
const actualHeight = parseInt(contentEl.style.height) || dims.height;
await htmlToImage.toPng(contentEl, {
width: dims.width,
height: actualHeight,
// ...
});
/opt/data/workspace/Projects/wenyan-editor/backend/app.py/opt/data/workspace/Projects/wenyan-editor/frontend/index.html/opt/data/workspace/Projects/wenyan-editor/frontend/standalone.html