-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* docs: add English readme.md, fixes #54 * chore: rewording
- Loading branch information
Showing
3 changed files
with
170 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Markdown Padding | ||
[](https://www.npmjs.org/package/md-padding) | ||
[](https://www.npmjs.org/package/md-padding) | ||
[](https://github.com/harttle/md-padding/actions/workflows/check.yml) | ||
[](https://github.com/harttle/md-padding/actions/workflows/release.yml) | ||
[](https://coveralls.io/github/harttle/md-padding?branch=master) | ||
[](https://github.com/harttle/md-padding) | ||
[](https://github.com/harttle/md-padding/issues) | ||
[](https://github.com/harttle/md-padding/blob/master/LICENSE) | ||
[](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) | ||
|
||
**排版中只有空格不能忍**,修复你 Markdown 中缺少的空格: | ||
|
||
* 中英文混排时,*中文* 与 *英文* 之间,*中文* 与 *数字* 之间添加空格。 | ||
* *特定英文标点* 后面添加空格,但 *全角标点* 前后不加空格。 | ||
* 文字和 *行内代码* 之间、文字与 *链接* 之间、文字与 *加粗*、*强调*、*删除线* 之间添加空格。 | ||
* 会解析生成 Markdown + 自然语言构成的 AST,最大限度解决问题同时避免误处理。 | ||
|
||
[这里](https://github.com/harttle/md-padding/tree/master/demo) 有个例子: | ||
|
||
 | ||
|
||
## 使用说明 | ||
### 在命令行使用 | ||
|
||
可以 `npm i -g md-padding` 后使用,也可以用 `npx md-padding`: | ||
|
||
```bash | ||
# 输出 README.md 格式化后的内容 | ||
npx md-padding README.md | ||
``` | ||
|
||
还可以接受标准输入(用在管道中),也可以原址(in-place)更改文件。详见 `md-padding --help`。 | ||
|
||
```none | ||
> npx md-padding --help | ||
md-padding [OPTION]... <FILE> | ||
Options: | ||
--help, -h Show help [boolean] | ||
--version Show version number [boolean] | ||
--in-place, -i Edit file in place [boolean] | ||
--ignore-words, -I Ignore padding within/before/after these words [string] | ||
--ignore-patterns, -P Ignore by a list of regexp [string] | ||
--read-files, -r Read a file list containing one file per line, use empty value to read from STDIN [string] | ||
Examples: | ||
stdout md-padding README.md | ||
in-place md-padding -i README.md | ||
pipe cat README.md | md-padding | ||
ignore-words cat README.md | md-padding -I '=' '::' | ||
ignore-patterns cat README.md | md-padding -P '=' ':+' | ||
batch format cat list.txt | md-padding -r -i | ||
equivalent w/ md-padding -r list.txt -i | ||
``` | ||
|
||
### 在 Vim 中使用 | ||
|
||
可以绑定一个快捷键 `F6` 来修复当前文件: | ||
|
||
```vim | ||
" 绑一个 Vim Filter | ||
noremap <buffer> <F6> <Esc>:%!npx md-padding<CR> | ||
``` | ||
|
||
### 在 VS Code 中使用 | ||
|
||
从 Marketplace 安装 [Markdown Padding](https://marketplace.visualstudio.com/items?itemName=harttle.md-padding-vscode)。 | ||
打开一个 Markdown 文件后,支持这些操作: | ||
|
||
- Command。打开 *命令面板*,输入 Markdown Padding 并回车。*命令面板* 快捷键: | ||
- Windows:Ctrl + Shift + P | ||
- Mac:Command + Shift + P | ||
- Linux:Ctrl + Shift + P | ||
- Formatting。在编辑器里右键点格式化,或者: | ||
- Windows:Shift + Alt + F | ||
- Mac:Shift + Option + F | ||
- Linux:Ctrl + Shift + I | ||
|
||
参数 | 类型 | 描述 | ||
--- | --- | --- | ||
`mdpadding.ignoreWords` | `Array<string>` | 这些字词内部和前后禁止加空格 | ||
`mdpadding.ignorePatterns` | `Array<string>` | 这些正则内部和前后禁止加空格 | ||
|
||
## 功能说明 | ||
|
||
### 中英混排 | ||
中英混排的正文内容,会确保中英之间的空格。 | ||
|
||
### 标点符号 | ||
需要空格的标点(比如半角逗号),会在适当的位置追加空格。 | ||
|
||
### 代码注释 | ||
代码格式化不是本仓库的功能之一,请使用对应语言的 prettifier。但代码中的注释会被当做 Markdown 正文来格式化,目前支持这些语言的注释: | ||
|
||
- cpp, c, java, javascript, typescript, csharp, go | ||
- sql | ||
- bash, python, ruby | ||
|
||
### 忽略片段 | ||
|
||
有些片段希望保持原状,这时可以用 `md-padding-ignore` 来包裹起来。 | ||
|
||
```markdown | ||
下面是一段不需要格式化的文本 | ||
<!--md-padding-ignore-begin--> | ||
a*b=c, b>1 => a<c | ||
<!--md-padding-ignore-end--> | ||
现在开始又可以格式化了。 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters