norberttech/md-link-linter

Markdown链接检查器

0.3.0 2024-07-29 10:07 UTC

README

这是一个简单的命令行工具,旨在检测Markdown文件中的无效链接。

目前验证以下类型的链接:

  • 相对链接
  • 锚点链接
  • 提及链接
bin/mdlinklint path --exclude=vendor --exclude=node_modules

使用Docker

docker run -t --rm -v $PWD:/app norberttech/md-link-linter --exclude=vendor --exclude=node_modules .

第一个参数 path 可以省略或被环境变量 MD_LINTER_SCAN_DIR 覆盖

MD_LINTER_SCAN_DIR=path bin/mdlinklint --exclude=vendor --exclude=node_modules

当参数路径和环境变量都存在时,环境变量具有优先权。

./mdlinklint --help

Usage:
  run [options] [--] [<path>]

Arguments:
  path                     Path in which md link linter should validate all markdown files

Options:
      --dry-run               Scan path and output md files
      --exclude=EXCLUDE       Exclude folders with this name (multiple values allowed)
      --mention=MENTION       Mentions whitelist (can include all team members or groups), if empty mentions are not validated (multiple values allowed)
  -h, --help                  Display help for the given command. When no command is given display help for the run command
  -q, --quiet                 Do not output any message
  -V, --version               Display this application version
      --ansi                  Force ANSI output
      --no-ansi               Disable ANSI output
  -n, --no-interaction        Do not ask any interactive question
  -bf, --break-on-failure     Break the inspection on first failure
  -rp, --root-path=ROOT-PATH  Root path used to assert absolute links. Link: [link](/nested/file.php) will check if file /nested/file.php exists from this path
  -v|vv|vvv, --verbose        Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Preview

验证提及

使用 --mention 选项可以设置允许的提及

bin/mdlinklint path --mentions=norberttech --mention=team_name

如果未使用,提及链接断言将始终通过。

安装

Docker

推荐 - md-link-linter 不是一个你想作为依赖项添加到项目中的工具类型,因为它自带了可能与你的重叠的依赖项。

Docker Hub - norberttech/md-link-linter

Composer

composer global require norberttech/md-link-linter

Phive

由于md-link-linter依赖于 \realpath 函数,该函数在Phar环境中不起作用(解释如下),因此目前没有计划通过Phive提供。

realpath() 函数对于位于Phar内部的文件将不起作用,因为此类路径是虚拟路径,而不是真实路径。

php.net realpath 文档

开发

安装依赖项

composer install

运行测试

composer tests

编码标准

此命令可能会更改您的代码!

composer cs:php:fix