mr-li-writer
Verified面向中文内容创作的编辑判断、研究、策划、写作与平台原生交付工作流。根据标题、素材、参考资料、核心想法或模糊灵感,先识别读者任务、材料条件和创新必要性,再按需完成语境扫描、可写性判断与方向校准,并区分发布平台与内容目标,进行事实检索、观点设计、平台原生正文写作、标题策划和对应交付。适用于公众号文章、知乎回答、小红书原生笔记、官网/网页、个人博客、行业解读、实用指南和基于素材的扩展研究写作。
scripts/wrap_gzh_preview.py
View on GitHub#!/usr/bin/env python3
"""把已校验的公众号正文片段(纯 <section>)包成带「复制」按钮的浏览器预览页。
用户打开预览页 → 点右上角「复制到公众号」→ 按钮选中并复制里面渲染后的富文本
(等价手动 Ctrl+A/Ctrl+C,样式全保留)→ 到公众号编辑器 Ctrl+V 粘贴即可。
按钮和 JS 只存在于预览外壳里,**不在被复制的 section 内**,所以粘进公众号的
仍是干净合规的正文,不含 <script>/<button>。校验请对原始 section 文件跑
validate_gzh_html.py(本预览页含 script/style,不参与校验)。
用法:
wrap_gzh_preview.py <section.html> [output.html] --task-state <任务状态.json>
默认输出 <section去扩展名>-preview.html
"""
import argparse
import hashlib
import html
import os
import re
import subprocess
import sys
def require_task_state(task_state):
if not task_state:
print("[错误] 生成公众号复制预览前必须传入 --task-state,并通过 scripts/validate_task_intake.py 确认必问项。", file=sys.stderr)
return 2
checker = os.path.join(os.path.dirname(os.path.abspath(__file__)), "validate_task_intake.py")
return subprocess.call([sys.executable, checker, task_state, "--phase", "layout", "--platform", "公众号"])
def parse_args():
parser = argparse.ArgumentParser(description="把公众号正文片段包成带复制按钮的浏览器预览页")
parser.add_argument("section", help="已校验的公众号正文片段 HTML")
parser.add_argument("output", nargs="?", help="输出预览页路径,默认 <section>-preview.html")
parser.add_argument("--task-state", required=True, help="任务状态 JSON;必须已确认必问项")
return parser.parse_args()
def main():
args = parse_args()
src = args.section
intake_rc = require_task_state(args.task_state)
if intake_rc != 0:
sys.exit(intake_rc)
if not os.path.isfile(src):
print(f"✗ 找不到文件: {src}")
sys.exit(1)
content = open(src, encoding="utf-8").read().replace("\r\n", "\n").replace("\r", "\n").strip()
if 'data-mr-li-writer-renderer="component-library-v1"' not in content:
print("✗ 正文不是完整组件库正式产物;请先使用 build_gzh_html.py 生成并校验", file=sys.stderr)
sys.exit(1)
root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
candidates = [
os.path.join(root, "assets", "gzh-design", "assets", "preview-template.html"),
os.path.join(root, "assets", "preview-template.html"),
]
tpl_path = next((p for p in candidates if os.path.isfile(p)), candidates[0])
tpl = open(tpl_path, encoding="utf-8").read()
title = os.path.splitext(os.path.basename(src))[0]
theme_match = re.search(r'data-mr-li-writer-theme=["\']([^"\']+)', content)
if not theme_match:
print("✗ 正文缺少公众号主题标识,不能生成正式复制预览", file=sys.stderr)
sys.exit(1)
theme = theme_match.group(1)
digest = hashlib.sha256(content.encode("utf-8")).hexdigest()
out_html = (
tpl.replace("{{TITLE}}", html.escape(title))
.replace("{{THEME}}", html.escape(theme, quote=True))
.replace("{{CONTENT_SHA256}}", digest)
.replace("<!--GZH_CONTENT-->", content)
)
out = args.output if args.output else os.path.splitext(src)[0] + "-preview.html"
open(out, "w", encoding="utf-8").write(out_html)
print(f"✓ 已生成带「复制」按钮的预览页: {out}")
print(" 用浏览器打开它,点右上角「复制到公众号」,再去公众号编辑器 Ctrl/⌘+V 粘贴。")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |