norzechowicz / md-link-linter
0.3.0
2024-07-29 10:07 UTC
Requires
- php: ~8.1.0
- ext-dom: *
- ext-mbstring: *
- cocur/slugify: ^3.2 || ^4.0
- erusev/parsedown: ^1.7
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/console: ^3.4||^4.4||^5.0||^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5 || ^10.0
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
验证提及
使用 --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内部的文件将不起作用,因为这样的路径是虚拟路径,而不是真实路径。
开发
安装依赖项
composer install
运行测试
composer tests
编码规范
此命令可能会更改您的代码!
composer cs:php:fix