WeChat-safe HTML
Transform the source before touching a live WeChat editor. Preserve the author's content and visual intent; do not rewrite prose or silently approximate figures.
Workflow
- Inspect the source HTML, referenced local assets, stylesheet locations, image count, and SVG count.
- Run
scripts/convert_to_wechat_safe_html.pyto inline supported CSS, convert fragiledivcontainers tosection, and wrap the body styles in a WeChat-safe outer section. - Read the generated JSON report. Resolve every risky SVG and missing/external stylesheet warning before claiming visual fidelity.
- Compare normalized non-SVG text between source and output. The report's
non_svg_text_matchmust be true unless the user explicitly requested content changes. - If the user only wants a file, deliver the converted HTML and the report. If the user asks to write it to the Official Account backend, use the available browser-control skill and obtain any confirmation required at action time.
- Paste through the clipboard as
text/html, not as plain text. Preserve existing title, author, cover, summary, and publication settings unless the user asks to change them. - Save only to the draft box unless the user explicitly requests publication. Verify the saved editor or preview using the checklist in references/wechat-compatibility.md.
Conversion command
python scripts/convert_to_wechat_safe_html.py input.html -o wechat-safe.html --report conversion-report.json
Use --replace-first-svg-url <URL> only when the first SVG has already been uploaded as a pixel-faithful image and its stable WeChat CDN URL is known. Use --fail-on-risky-svg when an unattended workflow must stop rather than produce potentially broken figures.
Non-negotiable compatibility rules
- Do not depend on
<style>, body-level styles, JavaScript, or external web fonts after conversion. - Do not paste the raw document or browser-selected rendering and call it equivalent.
- Do not package SVGs as
data:image/svg+xmlfor direct WeChat paste; this can stall saving. - Treat SVGs using
id,url(#...), markers, masks, clip paths, filters, or gradients as risky. Rasterize them to PNG/WebP with a faithful renderer, replace them with an already uploaded image, or rewrite the affected primitives without ID references. - Preserve ordinary inline SVG only when the report finds no ID-based references and the saved preview renders it correctly.
- Never publish publicly as part of conversion verification.
For detailed failure modes, remediation choices, and the live-editor acceptance checklist, read references/wechat-compatibility.md.