Snipgrapher

作者 mcollina72b727514771无许可证收录于 2026年10月8日更新于 2026年10月8日

Configures and uses snipgrapher to generate polished code snippet images, including syntax-highlighted PNGs, SVGs, and WebP exports with custom themes, profiles, and styling options. Use when the user wants to create code screenshots, turn code into shareable images, generate pretty code snippets for docs or social posts, produce syntax-highlighted images from source files, or explicitly mentions snipgrapher. Supports single-file renders, batch jobs, watch mode, and reusable named profiles via the snipgrapher CLI or npx.

AI 生成的概览

配置并使用 snipgrapher 命令行工具,将代码渲染为带语法高亮的 PNG、SVG 或 WebP 代码片段图片。

功能
该技能指导智能体使用 snipgrapher 命令行工具,把源文件转换为精美的代码片段图片。内容包括初始化项目配置、定义可复用的命名配置档,以及以单文件、批量或监听模式渲染 PNG、SVG 或 WebP,并支持自定义主题与样式。它还列出常见渲染失败的排查方法,例如缺少字体、语法不受支持、输出为空以及配置档缺失。
适用场景
当用户需要代码截图或可分享的代码图片时使用,例如为文档、更新日志或社交帖子制作精美代码片段。也适用于批量生成代码片段素材、建立可复用的渲染默认设置,或用户明确提到 snipgrapher 时。
运行要求
需要 Node.js 及 npm/npx,并需要网络访问以从 npm 获取已发布的 snipgrapher 包,或使用本地已安装的 snipgrapher 可执行文件。使用自定义主题时,相关字体需已安装在系统中。该技能不附带脚本,仅为说明文档。

When to use

Use this skill when you need to:

  • Generate image snippets from source code
  • Configure reusable snippet rendering defaults
  • Batch-render snippet assets for docs, social posts, or changelogs
  • Use published snipgrapher from npm to generate snippet images

Quick start

Render a single file to a PNG immediately with no config required:

bash
npx snipgrapher render file.ts -o output.png

For ongoing use, initialise a project config first, then render:

bash
npx snipgrapher init          # creates snipgrapher.config.jsonnpx snipgrapher render file.ts --profile default -o output.png

After rendering, verify the output exists and is non-zero in size before treating the job as successful:

bash
ls -lh output.png   # confirm file exists and size > 0

How to use

Read these rule files in order:

  • rules/setup-and-configuration.md [blocked] - Install, select executable, initialize config, and define profiles
  • rules/rendering-workflows.md [blocked] - Render single snippets, batch jobs, watch mode, and output practices

Core principles

  • Configure first: establish a project config before repeated renders
  • Reproducible output: prefer named profiles and explicit output paths
  • Portable commands: use command patterns that work with installed binaries and npx
  • Automation-friendly: rely on CLI flags/config/env precedence intentionally

Troubleshooting common render failures

If a render fails or produces an unexpected output, check for these common causes:

  • Missing fonts: ensure any custom font specified in the profile or config is installed on the system
  • Unsupported syntax: confirm the language/extension is supported by snipgrapher; fall back to plain text highlighting if not
  • Empty or corrupt output: re-run with --verbose (if supported) to surface error details, and verify the input file is readable and non-empty
  • Profile not found: run npx snipgrapher init to regenerate snipgrapher.config.json if the config file is missing or malformed

来源与署名

来源:mcollina/skills位于skills/snipgrapher提交72b7275

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架