{"id":13527027,"url":"https://github.com/lint-md/lint-md","last_synced_at":"2025-05-16T12:04:20.862Z","repository":{"id":40413839,"uuid":"156473632","full_name":"lint-md/lint-md","owner":"lint-md","description":":books: 检查中文 markdown 编写格式规范的命令行工具，基于 AST，方便集成 CI，写博客 / 文档必备。支持 API 调用！","archived":false,"fork":false,"pushed_at":"2024-04-30T14:28:44.000Z","size":295,"stargazers_count":939,"open_issues_count":13,"forks_count":55,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-23T07:34:02.544Z","etag":null,"topics":["lint","lint-markdown","lint-md","lint-md-cli","markdown"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lint-md.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/hustcc","https://atool.vip"]}},"created_at":"2018-11-07T01:38:30.000Z","updated_at":"2025-03-21T03:27:31.000Z","dependencies_parsed_at":"2024-01-13T20:13:43.161Z","dependency_job_id":"e31b9c4d-9ab9-4eae-9744-9df7b9609e0d","html_url":"https://github.com/lint-md/lint-md","commit_stats":null,"previous_names":["hustcc/lint-md"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lint-md%2Flint-md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lint-md%2Flint-md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lint-md%2Flint-md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lint-md%2Flint-md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lint-md","download_url":"https://codeload.github.com/lint-md/lint-md/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lint","lint-markdown","lint-md","lint-md-cli","markdown"],"created_at":"2024-08-01T06:01:39.546Z","updated_at":"2025-04-12T06:11:20.404Z","avatar_url":"https://github.com/lint-md.png","language":"TypeScript","funding_links":["https://paypal.me/hustcc","https://atool.vip"],"categories":["Repository","Cross-Platform","Tools","TypeScript"],"sub_categories":["Linter \u0026 Formatter","JavaScript","English"],"readme":"# Lint Markdown 2.0\n\n\u003e ⚠️ 提示：你现在看到的是 2.0 版本，如果要查看 1.x 版本请切换到 **[1.x](https://github.com/lint-md/lint-md/tree/1.x)** 分支。\n\nLint Markdown 是检查中文 Markdown 编写格式的工具，让你的文档更加优雅规范。\n\n[![npm](https://img.shields.io/npm/v/@lint-md/core.svg)](https://www.npmjs.com/package/@lint-md/core)\n[![npm](https://img.shields.io/npm/dm/@lint-md/core.svg)](https://www.npmjs.com/package/@lint-md/core)\n\n## 新版特点\n\n重构文本修复算法，fix 能力性能提升上百倍。\n\n底层 Markdown 解析库 remark 迁移至最新版。\n\n支持多线程 lint \u0026 fix。\n\n体验更好的命令行输出提示。\n\n项目架构完全重构，代码质量大幅提升，更方便 contribute 😄。\n\n## 快速开始\n\n我们提供了两种使用的方式，命令行和 Node.js API，前者适合大部分用户使用（推荐），后者适合更加定制化的 Lint 需求。\n\n### 使用命令行（CLI）\n\n#### 安装依赖\n\n```shell\nnpm install -g @lint-md/cli\n```\n\n#### 命令示例\n\n```shell\n# 校验当前目录下的 test.md 文件\nlint-md test.md\n\n# 校验当前目录下的 test.md 文件，并修复之\nlint-md test.md --fix\n\n# 校验 examples 目录下所有的 Markdown 文件，并修复之\nlint-md examples/**/* --fix\n\n# 校验 examples 目录下所有的 Markdown 文件，指定 config.json 为配置文件（配置文件语法见下文）\nlint-md examples/**/* --config=config.json\n\n# 校验 examples 目录下所有的 Markdown 文件，仅存在 warning 时程序正常退出（warning 不会阻断 CI）\nlint-md examples/**/* --suppress-warnings\n\n# 校验 examples 目录下所有的 Markdown 文件，并开启多线程模式（线程数 === CPU 核心数）\nlint-md examples/**/* --threads\n\n# 校验 examples 目录下所有的 Markdown 文件，并开启多线程模式（线程数 === 8）\nlint-md examples/**/* --threads=8\n```\n\n#### 配置文件\n\n默认情况下重新会读取根目录下的 `.lintmdrc` JSON 文件（如果有的话），下面是一个案例，表示将 `no-empty-code` 这条规则的等级设置为 warning，同时为 `no-long-code` 这条规则配置了自定义的选项：\n\n```json\n{\n  \"rules\":{\n    \"no-empty-code\": 1,\n    \"no-long-code\": [2, {\n      \"length\": 100,\n      \"exclude\": [\"dot\"]\n    }]\n  }\n}\n```\n\n其中 `key` 为对应规则的名称，`value` 是一个数字或者对象。\n\n如果是一个数字，那么表示规则的等级：\n\n- **0**：忽略（off），不检查该规则\n- **1**：警告（warning），仅出现警告，程序正常退出，不会阻断 CI\n- **2**：错误（error），出现错误，程序异常退出，会阻断 CI\n\n如果是一个数组，那么数组的第一项为数字，表示该规则的等级；第二个为规则的配置参数。\n\n#### API 一览\n\n```shell\nOptions:\n  -v, --version                  output the version number（查看当前版本）\n  -c, --config [configure-file]  use the configure file, default .lintmdrc（使用配置文件，默认为 .lintmdrc）\n  -f, --fix                      fix the errors automatically（开启修复模式）\n  -d, --dev                      open dev mode（开启开发者模式）\n  -t, --threads [thread-count]   The number of threads. The default is based on the number of available CPUs.（执行 Lint / Fix 的线程数，默认为 CPU 核心数）\n  -s, --suppress-warnings        suppress all warnings, that means warnings will not block CI（抑制所有警告，这意味着警告不会阻止 CI）\n  -h, --help                     display help for command（查看帮助）\n```\n\n### 使用 Node.js API\n\nTODO\n\n## 规则概述\n\n\u003e 检查规则来源于 [chinese-document-style-guide](https://github.com/ruanyf/document-style-guide).\n\n\n| 规则                                | 详细描述                      | 解决办法                | 可自动修复     |\n|------------------------------------|------------------------------|------------------------|------------|\n| space-around-alphabet              | 中文与英文之间需要增加空格        | 对应提示的位置增加空格   | ✅    |\n| space-around-number                | 中文与数字之间需要增加空格        | 对应提示的位置增加空格   | ✅    | \n| no-empty-code-lang                 | 代码语言不能为空                | 在代码块语法上增加语言     | ✅    |\n| no-empty-url                       | 链接和图片地址不能为空            | 填写完整的 url，或者不使用链接和图片语法 | ✅    | \n| no-empty-list                      | list 内容不能为空               | 删除空的 list 或者补充内容   | ✅    | \n| no-empty-code                      | 代码块内容不能为空               | 删除空的代码块，或者填充代码内容   | ✅    | \n| no-empty-inline-code                | 行内代码块内容不能为空            | 删除空的行内代码块，或者填充代码内容     | ✅    | \n| no-empty-blockquote                | 引用块内容不能为空               | 删除空的引用块，或者填充内容 | ✅    |\n| no-special-characters              | 文本中不能有特殊字符             | 可能是复制出来的特殊字符，删除特殊字符即可  | ✅    |\n| use-standard-ellipsis              | 使用标准规范的省略号             | 使用标准规范的省略号‘……’ / ‘...’ | ✅    | \n| no-fullwidth-number                | 不能用全角数字                  | 注意输入法切换为半角输入           | ✅    |\n| no-space-in-link                   | 链接前后不能有空格            | 删除链接内容的前后空格     | ✅    |\n| no-multiple-space-blockquote       | 引用块头部和内容间只能有一个空格    | 删除多余的空格 | ✅    |\n| correct-title-trailing-punctuation | 标题末尾只能使用合适的标点符号（允许问号、叹号、省略号） | 删除标题最后不合法的标点符号   | ✅    |\n| no-space-in-inline-code            | 行内代码内容前后不能有空格        | 删除行内代码中的前后空格          | ✅    |\n| no-long-code                       | 代码块不能有过长的代码（代码长度可配置，见下文）  | 对展示代码做格式上的修改        | x    |\n\n**可配置的规则**\n\n`no-long-code` 接受两个可配置参数：\n\n+ `length`: 每行代码接受的最大长度，数字，默认值为 `100`\n+ `exclude`: 可以配置部分代码类型不做长度检查，字符串数组，默认值为 `[]`\n\n### 贡献代码\n\n\u003e 目前仅仅检查了比较通用的类型，**欢迎 Pull Request**，在 `rules` 中增加自己的规则，注意：\n\n- 规则主要针对于中文 Markdown 的编写规范\n- 规则名称对应和插件文件名保持一致\n- 先提 [issue](https://github.com/lint-md/lint-md/issues) 进行讨论\n- 开发 rule 时可以使用 [AST 工具](https://astexplorer.net/) 来辅助开发\n\n\n## License\n\nMIT@[hustcc](https://github.com/hustcc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flint-md%2Flint-md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flint-md%2Flint-md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flint-md%2Flint-md/lists"}