web-to-markdown

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

web-to-markdown

web-to-markdown

Convert web pages to clean Markdown by driving a locally installed browser (via
web2md
).
通过驱动本地安装的浏览器(借助
web2md
)将网页转换为整洁的Markdown格式。

Hard trigger gate (must enforce)

严格触发规则(必须执行)

This skill MUST NOT be used unless the user explicitly wrote exactly a phrase like:
  • use the skill web-to-markdown ...
  • use a skill web-to-markdown ...
If the user did not explicitly request this skill by name, stop and ask them to re-issue the request including:
use the skill web-to-markdown
.
除非用户明确写下如下确切表述,否则不得使用此技能:
  • use the skill web-to-markdown ...
  • use a skill web-to-markdown ...
如果用户没有明确通过名称请求此技能,请停止操作并要求他们重新发起包含
use the skill web-to-markdown
的请求。

What this skill does

此技能的功能

  • Handles JS-rendered pages (Puppeteer → user Chrome).
  • Works best with Chromium-family browsers (Chrome/Chromium/Brave/Edge) via
    puppeteer-core
    .
  • Extracts main content (Readability).
  • Converts to Markdown (Turndown) with cleaned links and optional YAML frontmatter.
  • 支持JS渲染的页面(Puppeteer → 用户Chrome浏览器)。
  • 通过
    puppeteer-core
    在Chromium系列浏览器(Chrome/Chromium/Brave/Edge)上表现最佳。
  • 提取主要内容(借助Readability)。
  • 将内容转换为Markdown格式(借助Turndown),包含清理后的链接和可选的YAML前置元数据。

Non-goals

不支持的功能

  • Do not use Playwright or other browser automation stacks; the mechanism is
    web2md
    .
  • 不使用Playwright或其他浏览器自动化工具栈;仅使用
    web2md
    机制。

Inputs you should collect (ask only if missing)

需要收集的输入信息(仅在缺失时询问)

  • url
    (or a list of URLs)
  • Output preference:
    • Print to stdout (
      --print
      ), OR
    • Save to a file (
      --out ./file.md
      ), OR
    • Save to a directory (
      --out ./some-dir/
      to auto-name by page title)
  • Optional rendering controls for tricky pages:
    • --chrome-path <path>
      (if Chrome auto-detection fails)
    • --interactive
      (show Chrome and pause so the user can complete human checks/login, then press Enter)
    • --wait-until load|domcontentloaded|networkidle0|networkidle2
    • --wait-for '<css selector>'
    • --wait-ms <milliseconds>
    • --headful
      (debug)
    • --no-sandbox
      (sometimes required in containers/CI)
    • --user-data-dir <dir>
      (login/session; use a dedicated profile directory)
  • url
    (或URL列表)
  • 输出偏好:
    • 打印到标准输出(
      --print
      ),或
    • 保存到文件(
      --out ./file.md
      ),或
    • 保存到目录(
      --out ./some-dir/
      ,按页面标题自动命名)
  • 针对复杂页面的可选渲染控制参数:
    • --chrome-path <path>
      (当Chrome自动检测失败时使用)
    • --interactive
      (显示Chrome浏览器并暂停,以便用户完成人工验证/登录,然后按Enter继续)
    • --wait-until load|domcontentloaded|networkidle0|networkidle2
    • --wait-for '<css selector>'
    • --wait-ms <milliseconds>
    • --headful
      (调试模式)
    • --no-sandbox
      (有时在容器/CI环境中需要)
    • --user-data-dir <dir>
      (登录/会话;使用专用配置文件目录)

Workflow

工作流程

  1. Confirm the user explicitly invoked the skill (
    use the skill web-to-markdown
    ).
  2. Validate URL(s) start with
    http://
    or
    https://
    .
  3. Ensure
    web2md
    is installed:
    • Run:
      command -v web2md
    • If missing, instruct the user to install it:
      • If available via npm:
        npm install -g web2md
      • If from source: Clone the repository, then run
        npm install && npm run build && npm link
  4. Convert:
    • Single URL → file:
      • web2md '<url>' --out ./page.md
    • Single URL → auto-named file in directory:
      • mkdir -p ./out && web2md '<url>' --out ./out/
    • Human verification / login walls (interactive):
      • mkdir -p ./out && web2md '<url>' --interactive --user-data-dir ./tmp/web2md-profile --out ./out/
      • Then: complete the check in the browser window and press Enter in the terminal to continue.
    • Print to stdout:
      • web2md '<url>' --print
    • Multiple URLs (batch):
      • Create output dir (e.g.
        ./out/
        ) then run one
        web2md
        command per URL using
        --out ./out/
  5. Validate output:
    • If writing files, verify they exist and are non-empty (e.g.
      ls -la <path>
      and
      wc -c <path>
      ).
  6. Return:
    • The saved file path(s), or the Markdown (stdout mode).
  1. 确认用户明确调用了此技能(即使用
    use the skill web-to-markdown
    表述)。
  2. 验证URL是否以
    http://
    https://
    开头。
  3. 确保
    web2md
    已安装:
    • 运行:
      command -v web2md
    • 如果未安装,指导用户进行安装:
      • 若可通过npm获取:
        npm install -g web2md
      • 若从源码安装:克隆仓库,然后运行
        npm install && npm run build && npm link
  4. 执行转换:
    • 单个URL → 文件:
      • web2md '<url>' --out ./page.md
    • 单个URL → 目录下自动命名的文件:
      • mkdir -p ./out && web2md '<url>' --out ./out/
    • 人工验证/登录墙(交互模式):
      • mkdir -p ./out && web2md '<url>' --interactive --user-data-dir ./tmp/web2md-profile --out ./out/
      • 然后:在浏览器窗口完成验证,再在终端按Enter继续。
    • 打印到标准输出:
      • web2md '<url>' --print
    • 多个URL(批量处理):
      • 创建输出目录(如
        ./out/
        ),然后对每个URL分别运行一次带
        --out ./out/
        参数的
        web2md
        命令
  5. 验证输出:
    • 如果是写入文件,验证文件是否存在且非空(例如使用
      ls -la <path>
      wc -c <path>
      命令)。
  6. 返回结果:
    • 保存的文件路径,或Markdown内容(标准输出模式)。

Defaults (recommended)

默认配置(推荐)

  • For most pages:
    --wait-until networkidle2
  • For heavy apps: start with
    --wait-until domcontentloaded --wait-ms 2000
    , then add
    --wait-for 'main'
    (or another stable selector) if needed.
  • 对于大多数页面:
    --wait-until networkidle2
  • 对于大型应用:先使用
    --wait-until domcontentloaded --wait-ms 2000
    ,如果需要再添加
    --wait-for 'main'
    (或其他稳定选择器)。