You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-3
Original file line number
Diff line number
Diff line change
@@ -284,7 +284,7 @@ If you want to ignore the whole file, you can also add this HTML comment:
284
284
285
285
*... and this part might be controversial. So if you don't feel well at some point, we definitely would love to know and improve. Opening an [issue](https://github.com/zhlint-project/zhlint/issues) is always welcome. Then we could discuss about the possible better option or decision.*
Copy file name to clipboardExpand all lines: README.zh-CN.md
+107-6
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,48 @@ zhlint --help
40
40
41
41

42
42
43
+
#### Advanced usage
44
+
45
+
zhlint also supports rc and ignore config files for custom rules:
46
+
47
+
```bash
48
+
# .zhlintrc by default
49
+
zhlint --config <filepath>
50
+
51
+
# .zhlintignore by default
52
+
zhlint --ignore <filepath>
53
+
zhlint --file-ignore <filepath>
54
+
55
+
# .zhlintcaseignore by default
56
+
zhlint --case-ignore <filepath>
57
+
58
+
# current directory by default
59
+
zhlint --dir <path>
60
+
```
61
+
62
+
In the config file, you can write a JSON like:
63
+
64
+
```json
65
+
{
66
+
"preset": "default",
67
+
"rules": {
68
+
"adjustedFullWidthPunctuation": ""
69
+
}
70
+
}
71
+
```
72
+
73
+
For more details, see [supported rules](#supported-rules).
74
+
75
+
In the file-ignore file, you can write some lines to ignore files in [.gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format):
76
+
77
+
In the case-ignore file, you can write some lines of ignored cases like:
78
+
79
+
```txt
80
+
( , )
81
+
```
82
+
83
+
For more details, see [setup ignored cases](#setup-ignored-cases).
84
+
43
85
### 作为 Node.js 包
44
86
45
87
```js
@@ -74,6 +116,26 @@ Invalid files:
74
116
Found 2 errors.
75
117
```
76
118
119
+
#### Advanced usage
120
+
121
+
zhlint also supports rc and ignore config files for custom rules:
-`readRc: (dir: string, config: string, ignore: string, logger?: Console) => Config`: Read config from rc file(s). For rc (run command).
158
+
-`runWithConfig(str: string, config: Config): Result`: Lint a certain file with rc config. For rc (run command).
95
159
96
160
### 选项
97
161
@@ -113,20 +177,32 @@ type Options = {
113
177
- 遵循该特定的格式,灵感来自 [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment)。
114
178
- `logger`:和 `report(...)` 中的参数相同。
115
179
180
+
### RC Config
181
+
182
+
- `preset`: `string` (optional)
183
+
- `rules`: `RuleOptions` without the `preset` field. (optional)
184
+
- `hyperParsers`: `string[]` (optional)
185
+
- `caseIgnores`: `string[]` and the priority is lower than `.zhlintcaseignore`. (optional)
186
+
116
187
### 输出格式
117
188
118
189
```ts
119
190
typeResult= {
191
+
// the basic info and availability of the file
120
192
file?:string
193
+
disabled:boolean
194
+
195
+
// the original content of the file
121
196
origin:string
122
-
result:string
197
+
198
+
// all the error messages
123
199
validations:Validation[]
124
200
}
125
201
126
202
typeValidation= {
203
+
message:string
127
204
index:number
128
205
length:number
129
-
message:string
130
206
}
131
207
```
132
208
@@ -140,23 +216,33 @@ type Validation = {
140
216
- `length`:输入的字符串中目标片段的长度。
141
217
- `message`:对该校验信息的自然语言描述。
142
218
219
+
### Advanced usage
220
+
143
221
## 特性
144
222
145
223
### Markdown 语法支持
146
224
225
+
We support lint your text content in Markdown syntax by default. For example:
226
+
147
227
```js
148
228
run('自动在_中文_和**English**之间加入空格')
149
229
```
150
230
231
+
It will analyse the Markdown syntax first and extract the pure text content and do the lint job. After that the fixed pure text content could be replaced back to the raw Markdown string and returned as the output `value` in result.
Specially, we support [Hexo tags syntax](https://hexo.io/docs/tag-plugins) just because when we use Hexo to build Vue.js website, the markdown source files more or less include special tags like that so got the unpredictable result.
236
+
237
+
As a result, we additionally skip the Hexo-style tags by default. For example:
238
+
153
239
```js
154
240
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。')
155
241
```
156
242
157
243
### 设置被忽略的特例
158
244
159
-
通过 HTML 注释:
245
+
In some real cases we have special text contents not follow the rules by reason. So we could ues `ignoredCases` option to config that. For example we'd like to keep the spaces inside a pair of brackets, which is invalid by default. Then we could write one more line of HTML comment anywhere inside the file:
zhlintisnowopensourcedon [GitHub](https://github.com/zhlint-project/zhlint) and [issues](https://github.com/zhlint-project/zhlint/issues) welcome.
Copy file name to clipboardExpand all lines: docs/index.md
+9-4
Original file line number
Diff line number
Diff line change
@@ -294,9 +294,9 @@ If you want to ignore the whole file, you can also add this HTML comment:
294
294
295
295
_Almost the rules come from the past translation experiences in [W3C Requirements for Chinese Text Layout](https://www.w3.org/International/clreq/), [W3C HTML Chinese interest group](https://www.w3.org/html/ig/zh/wiki/Main_Page) and [Vue.js Chinese docsite](https://github.com/vuejs/cn.vuejs.org/wiki)._
296
296
297
-
_... and this part might be controversial. So if you don't feel well at some point, we definitely would love to know and improve. Opening an [issue](https://github.com/zhling-project/zhlint/issues) is always welcome. Then we could discuss about the possible better option or decision._
297
+
_... and this part might be controversial. So if you don't feel well at some point, we definitely would love to know and improve. Opening an [issue](https://github.com/zhlint-project/zhlint/issues) is always welcome. Then we could discuss about the possible better option or decision._
0 commit comments