AZ Tools

Markdown 链接提取器

文本

解析常见 Markdown 链接形式 — `[text](url 'title')`、`![alt](src)`、引用式 `[text][id]`(带 `[id]: url 'title'`)、autolink `<https://…>` — 每个返回为 `{type, text, url, title}` 行。便于 SEO 审计盘点外链、从博客文章构建站点地图、检查 docs 文件夹的失效 URL,或在迁移到新 CDN 前提取 README 所有图片。

类型文本URL标题
图片alt texthttps://example.com/cat.pngCute cat
链接a regular linkhttps://example.comExample homepage
链接docshttps://docs.example.com
链接helphttps://help.example.comHelp center
链接https://example.orghttps://example.org

输出 (5 项)

type,text,url,title
image,alt text,https://example.com/cat.png,Cute cat
link,a regular link,https://example.com,Example homepage
link,docs,https://docs.example.com,
link,help,https://help.example.com,Help center
link,https://example.org,https://example.org,

引用式链接对照同文档中的 `[id]: url` 定义解析。未用 `<>` 包裹的裸 URL 跳过。

使用方法

  1. 粘贴 Markdown 文档或段落。
  2. 切换是否包含图片(`![…](…)`)。
  3. 选 CSV、JSON 或 Markdown 列表输出;复制供下游工具使用。

常见问题

识别哪些链接语法?
行内 `[text](url)`,可选 `"title"` 或 `'title'`;引用 `[text][id]`,通过 `[id]: url "title"` 定义解析;快捷 `[text][]`;图像等价物(`!` 前缀);以及 HTML 风格 autolink `<https://…>`。未用 `<>` 包裹的裸 URL 在 CommonMark 中歧义,故有意跳过。
为什么输出中缺一个链接?
常见原因:URL 跨多行(Markdown 不允许)、`]` 与 `(` 之间有空格,或是引用链接但定义 ID 不同。识别集遵循 CommonMark 宽松规则,但并非完整解析器。
会抓取 URL 吗?
不 — 仅提取文本中的内容。要验证链接是否存活,请将输出送入 link-checker(`lychee`、`markdown-link-check`,或你常用的 Node 工具)。
代码块内的 Markdown 呢?
解析器不跳过围栏代码块,因此 ``` ``` ``` 内的 `[example](https://x)` 也会被捕获。如果对你的输入是个问题,请先用 `sed` 或 Markdown AST 工具去除代码块。

相关工具