dsh-markdown-lint
v0.2.0
Published
Markdown linter for DeepSeek Harness: heading hierarchy, list indentation, and relative-link existence checks, with auto-fix for repairable issues.
Maintainers
Readme
dsh-markdown-lint
Markdown 检查插件(v0.1.0):三类规则检查 + 可修复项自动修复。代码块内容全程跳过(围栏内 #、链接都不误报)。
安装
npm install dsh-markdown-lint工具
lint_markdown
| 参数 | 类型 | 说明 |
|------|------|------|
| text / file | string | 源内容二选一(file 须在工作目录内) |
三类规则:
| 规则 | 内容 | 可自动修复 |
|------|------|-----------|
| heading-hierarchy | 标题跳级(H1→H3);多个 H1(文件级) | 跳级可,多 H1 不可 |
| list-indent | 列表缩进用 Tab;嵌套步长不一致(≥2 次出现的宽度中取最小为标准) | 可 |
| link-exists | 相对链接(./x.md、../a.md、sub/x.md)目标文件不存在;file 模式以文件所在目录解析,text 模式以 cwd 解析 | 不可 |
http(s)/mailto/锚点链接不做联网检查。输出每条问题带行号、规则名与可修复标注。
fix_markdown
| 参数 | 类型 | 说明 |
|------|------|------|
| text / file | string | 源内容二选一 |
| write | boolean | file 模式下 true 直接覆盖写回文件(默认 false 仅预览) |
自动修复内容:跳级标题降级补齐、Tab 缩进转 4 空格、嵌套步长统一。修复后残余的不可修复问题(多 H1、死链)会提示用 lint_markdown 查看。
安全与限制
- 文件路径必须在工作目录内;输入上限 1MB
write=true直接覆盖文件,建议先预览(默认行为)- 相对链接检查只验证存在性,不验证指向内容正确性
- 零 npm 依赖
测试
npm test覆盖三类规则的命中与不误报、代码块跳过、file/text 两种解析基准、修复写回、路径越界拒绝等 28 项断言。
版本历史
0.2.0(2026-09-13)
- lint_markdown 新增 check_http_links 参数:http(s) 链接联网检查可用性(HEAD 优先、405 回退 GET、超时 5 秒、单次最多 20 个)
Roadmap(v0.3 候选)
- 多 H1 自动降级为 H2(可配置)
- 表格格式检查(列数不一致/缺分隔行)
- 自定义规则集(按需启停规则)
