For AI agents: the complete documentation index is available at https://lazygophers.github.io/pamphlet/llms.txt, the full documentation bundle is available at https://lazygophers.github.io/pamphlet/llms-full.txt, and this page is available as Markdown at https://lazygophers.github.io/pamphlet/reference/cli/index.md.
  • 简体中文
  • 命令行

    pamphlet build   <路径...> [选项]   编译成单文件 HTML
    pamphlet serve   <路径>    [选项]   本地预览,源文档改了就重新加载
    pamphlet lint    <路径...> [选项]   检查语法并报诊断
    pamphlet ast     <路径>    [选项]   输出 AST JSON
    pamphlet extract <产物.html>        从产物反解出源文档
    pamphlet doctor                     各图表引擎装了没有

    没装的话前面加 npx @nekoleapuki/pamphlet-cli,例如 npx @nekoleapuki/pamphlet-cli build 方案.md。

    退出码

    码含义
    0成功
    1编译错误
    2参数或用法错误
    3环境缺失(doctor 发现引擎没装)

    CI 里直接用退出码判断即可,不必解析输出。

    不带任何参数跑 pamphlet 会打印说明并退出 2 —— 因为「没说要做什么」是一种用法错误,不是成功。

    选项

    选项对哪些命令有效说明
    -o <路径>、--out <路径>build产物写到哪。只在编译单份时可用;配多份会报错退出 2
    --theme <名字>build serve换一套主题,压过 frontmatter 里的 theme。六套见内置主题
    --font <字体文件>build内嵌这个字体,只留文档用到的字
    --verbosebuild编译后打印体积归因
    --no-embed-sourcebuild产物里不内嵌源文档(extract 就用不了了)
    --port <端口>serve缺省 4321
    --format json只有 lint结构化输出,给 CI 和编辑器用
    --fail-on-warnbuild lint把警告也当成失败
    --continue-on-errorbuild lint某份文档出错后继续处理剩下的
    --no-color全部不上色
    -h、--help全部说明
    Warning

    --format json 不是全局选项 只有 lint 真的按它切换输出格式。

    build 忽略它,永远打印人类可读的诊断;ast 本来就往标准输出写 JSON,这个开关只是让它不再往 stderr 打人类可读的诊断。

    同理 --fail-on-warn 和 --continue-on-error 对 ast 无效。

    环境变量

    变量作用
    NO_COLOR设了就不上色,等同于 --no-color。这是跨工具的通行约定(https://no-color.org/)