用於檢查中文 markdown 編寫格式規範的命令行工具,基於 AST 開發,且方便集成 ci。Cli tool to lint your markdown file for Chinese.
npm i -g lint-md
Usage: <lint-md> <files...> [options] lint your markdown files Options: -v, --version output the version number -c, --config [configure-file] use the configure file, default .lintmdrc -h, --help output usage information
Example:node
lint-md README.md Document.md
檢查規則來源於 chinese-document-style-guide.
規則 | 詳細描述 | 解決辦法 |
---|---|---|
space-round-alphabet | 中文與英文之間須要增長空格 | 對應提示的位置增長空格 |
space-round-number | 中文與數字之間須要增長空格 | 對應提示的位置增長空格 |
no-empty-code-lang | 代碼語言不能爲空 | 在代碼塊語法上增長語言 |
no-empty-url | 連接和圖片地址不能爲空 | 填寫完整的 url,或者不使用連接和圖片語法 |
no-empty-list | List 內容不能爲空 | List 語法中,填寫內容 |
no-empty-code | 代碼塊內容不能爲空 | 刪除空的代碼塊,或者填充代碼內容 |
no-empty-blockquote | blockquote 內容不能爲空 | 刪除空的 blockquote,或者填充內容 |
no-special-characters | 文本中不能有特殊字符 | 多是複製出來的特殊字符,刪除特殊字符便可 |
use-standard-ellipsis | 使用標準規範的省略號 | 使用標準規範的省略號‘……’ / ‘...’ |
no-fullwidth-number | 不能用全角數字 | 注意輸入法切換爲半角輸入 |
no-space-in-emphasis | emphasis 內容先後不能有空格 | 刪除 emphasis 內容中的先後空格便可 |
no-space-in-link | link 內容先後不能有空格 | 刪除 link 內容中的先後空格便可 |
no-multiple-space-blockquote | blockquote 語法不能包含有多個空格 | 刪除 blockquote 內容中多餘的空格 |
no-trailing-punctuation | 標題不能以標點符號結尾 | 刪除標題最後的標點符號 |
目前僅僅檢查了比較通用的類型,
歡迎 pull request,在
rules
中增長本身的規則,開發約束:
默認全部的規則都是 error
類型,可是能夠經過配置來指定規則類型。示例 .lintmdrc
:git
{ "excludeFiles": [], "rules": { "no-empty-code": 1 } }
經過 rules 來配置規則的等級。github
經過 excludeFiles 來忽略文件和目錄,glob 語法。npm
在
.travis.yml
文件中配置如下內容。
language: node_js node_js: - "10" before_install: - npm i -g lint-md script: lint-md README.md
在
package.json
中增長如下配置。
"lint-staged": { "src/**/*.{md,markdown}": [ "lind-md" ] }
MIT@hustcc.json