Comparing version 0.3.0 to 0.4.0
@@ -13,3 +13,5 @@ #!/usr/bin/env node | ||
const help = () => console.log(` | ||
const help = () => | ||
console.log( | ||
` | ||
This is zhlint! | ||
@@ -39,3 +41,4 @@ | ||
zhlint foo.md --output=dest.md | ||
`.trim()) | ||
`.trim() | ||
) | ||
@@ -57,3 +60,3 @@ if (argv.h || argv.help) { | ||
const files = glob.sync(filePattern) | ||
const resultList = files.map(file => { | ||
const resultList = files.map((file) => { | ||
console.log(`[start] ${file}`) | ||
@@ -76,6 +79,7 @@ const origin = fs.readFileSync(file, { encoding: 'utf8' }) | ||
} else { | ||
console.error(`Sorry. If you use argument '--output' or '-o', you could only pass one file as the input.`) | ||
console.error( | ||
`Sorry. If you use argument '--output' or '-o', you could only pass one file as the input.` | ||
) | ||
} | ||
} | ||
else if (argv.f || argv.fix) { | ||
} else if (argv.f || argv.fix) { | ||
resultList.forEach(({ file, value, result }) => { | ||
@@ -82,0 +86,0 @@ if (value !== result) { |
{ | ||
"name": "zhlint", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A linting tool for Chinese language.", | ||
"bin": { | ||
"zhlint": "bin/index.js" | ||
"zhlint": "./bin/index.js" | ||
}, | ||
"main": "src/index.js", | ||
"types": "types/index.d.ts", | ||
"unpkg": "dist/zhlint.js", | ||
"jsdelivr": "dist/zhlint.js", | ||
"exports": { | ||
"import": "./dist/zhlint.es.js", | ||
"require": "./dist/zhlint.umd.js" | ||
}, | ||
"main": "./dist/zhlint.umd.js", | ||
"module": "./dist/zhlint.es.js", | ||
"unpkg": "./dist/zhlint.umd.js", | ||
"jsdelivr": "./dist/zhlint.umd.js", | ||
"types": "./types/index.d.ts", | ||
"files": [ | ||
"src/*", | ||
"types/*", | ||
"bin/*", | ||
"dist/*", | ||
"tsconfig.json", | ||
"*.png", | ||
"logo.svg", | ||
"README.md" | ||
"./src/*", | ||
"./types/*", | ||
"./tsconfig.json", | ||
"./dist/*", | ||
"./bin/*", | ||
"./docs/*.png", | ||
"./docs/logo.svg", | ||
"./README.md" | ||
], | ||
"scripts": { | ||
"dev": "jest --watchAll", | ||
"test": "jest", | ||
"build": "webpack", | ||
"docs": "vuepress dev", | ||
"docs:build": "rm -Rf docs && vuepress build -d docs" | ||
}, | ||
"repository": { | ||
@@ -45,6 +43,15 @@ "type": "git", | ||
"devDependencies": { | ||
"jest": "^24.8.0", | ||
"vuepress": "^1.4.1", | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11" | ||
"@algolia/client-search": "^4.12.0", | ||
"@types/react": "^17.0.38", | ||
"@typescript-eslint/eslint-plugin": "^5.9.0", | ||
"@typescript-eslint/parser": "^5.9.0", | ||
"@vitest/ui": "^0.0.139", | ||
"eslint": "^8.6.0", | ||
"prettier": "^2.5.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.10", | ||
"vitepress": "^0.21.4", | ||
"vitest": "^0.0.139" | ||
}, | ||
@@ -59,7 +66,16 @@ "dependencies": { | ||
}, | ||
"jest": { | ||
"globals": { | ||
"__DEV__": true | ||
} | ||
} | ||
} | ||
"scripts": { | ||
"dev": "vitest", | ||
"dev:ui": "vitest --ui", | ||
"build": "vite build", | ||
"format": "prettier --write .", | ||
"lint": "eslint {src,test,types}/** --fix", | ||
"test": "vitest run", | ||
"coverage": "vitest --coverage", | ||
"docs": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:serve": "vitepress serve docs", | ||
"docs:deploy": "./deploy.sh" | ||
}, | ||
"readme": "# <img src=\"./docs/logo.svg\" style=\"vertical-align: middle;\"> zhlint\n\nA linting tool for Chinese text content.\n\n## How to install\n\nYou could easily install `zhlint` through `npm` or `yarn`:\n\n```bash\n# install through npm\nnpm install zhlint -g\n\n# or through yarn\nyarn global add zhlint\n```\n\n## Usage\n\n### As CLI\n\n```bash\n# glob files, lint them, and print validation report,\n# and exit with code `1` if there is any error found.\nzhlint <file-pattern>\n\n# glob files and fix their all possilbly found errors.\nzhlint <file-pattern> --fix\n\n# lint the file and output fixed content into another file\nzhlint <input-file-path> --output=<output-file-path>\n\n# print usage info\nzhlint --help\n```\n\nThe validation report might look like this:\n\n![](./docs/screenshot-cli.png)\n\n### As Node.js package\n\n```js\nconst { run, report } = require('zhlint')\n\nconst value = '自动在中文和English之间加入空格'\nconst output = run(value)\n\n// print '自动在中文和 English 之间加入空格''\nconsole.log(output.result)\n\n// print validation report\nreport([output])\n```\n\nAnd the format of validation report is more like this:\n\n```bash\n1:6 - There should be a space between a half-width content and a full-width content\n\n自动在中文和English之间加入空格\n ^\n1:13 - There should be a space between a half-width content and a full-width content\n\n自动在中文和English之间加入空格\n ^\nInvalid files:\n- foo.md\n\nFound 2 errors.\n```\n\n### As a standalone package\n\nYou could find a JavaScript file `dist/zhlint.js` as a standalone version. To use it, for example, you can directly add it into your browser as a `<script>` tag. Then there would be a global variable `zhlint` for you.\n\n![](./docs/screenshot-browser.png)\n\n#### API\n\n- `run(str: string, options?: Options): Result`: Lint a certain file.\n - parameters:\n - `str`: The text content you want to lint.\n - `options`: Some options for advanced usage.\n - returns:\n - The result of a single piece of input string. It contains fixed text content as `value` and the infor of all `validations`.\n- `report(results: Result[], logger?: Console): void`: Print out the validation reports for each file.\n - parameters:\n - `results`: An array for all linted results.\n - `logger`: The logger instance, by default it's `console` in Node.js/browser.\n\n#### Other type defs and advanced usage\n\n- `Result`: `{ file?: string, origin: string, result: string, validations: Validation[] }`\n - `file`: The file name. It's an optional field which is only used in CLI.\n - `origin`: the original text content.\n - `result`: the finally fixed text content.\n - `validations`: All the validation information.\n- `Validation`: `{ index: number, length: number, name: string, target: string, message: string }`\n - `index`: The index of the target token in the input string.\n - `length`: The length of the target token in the input string.\n <!-- - `name`: The name of the rule that the token disobeys to. -->\n <!-- - `target`: The target part of the target token, like the `content` or the `spaceAfter` that, etc. -->\n - `message`: The description of this validation in natural language.\n- `Options`: `{ rules?: string[], hyperParse?: string[], ignoredCases?: IgnoredCase[], logger?: Console }`: Customize your own rules and other advanced options.\n - `rules`: customize the linting rules by their names, could be `undefined` which means just use the default [rules](https://github.com/Jinjiang/zhlint/tree/master/src/rules).\n - `hyperParse`: customize the hyper parser by their names, could be `undefined` which means just use default [ignored cases parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js), [Markdown parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js) and the [Hexo tags parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js).\n - `ignoredCases`: provide exception cases which you would like to skip.\n - `logger`: same to the parameter in `report(...)`.\n- `IgnoredCase`: `{ prefix?, textStart, textEnd?, suffix? }`\n - Just follows a certain format inspired from [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment).\n\n## Features\n\n### Markdown syntax support\n\nWe support lint your text content in Markdown syntax by default. For example:\n\n```js\nrun('自动在_中文_和**English**之间加入空格')\n```\n\nIt 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.\n\n### Hexo tags syntax support\n\nSpecially, 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.\n\nAs a result, we additionally skip the Hexo-style tags by default. For example:\n\n```js\nrun('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。')\n```\n\n### Setup ignored cases\n\nIn 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:\n\n```md\n<!-- the good case -->\n\ntext before (text inside) text after\n\n<!-- the bad case -->\n\nvm.$on( event, callback )\n\n<!-- then we could write this down below to make it work -->\n<!-- zhlint ignore: ( , ) -->\n```\n\nor just pass it through as an option:\n\n```js\nrun(str, { ignoredCases: { textStart: '( ', textEnd: ' )' } })\n```\n\n## Supported preproccessors (hyper parsers)\n\n- `ignore`: find all ignored pieces by the HTML comment `<!-- zhlint ignore: ... -->`\n- `hexo`: find all Hexo tags to avoid them being parsed.\n- `markdown`: parse by markdown syntax and find all block-level texts and inline-level marks.\n\n## Supported rules\n\n_Almost the rules come from the past translation experiences in [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)._\n\n_... 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/jinjiang/zhlint/issues) is always welcome. Then we could discuss about the possible better option or decision._\n\n- `mark-raw`: keep one space out of the inline code in markdown\n - `` text`text`text `` -> `` text `text` text ``\n- `mark-hyper`: move the space outside of the markdown marks\n - `text[ text ](link)text` -> `text [text](link) text`\n- `unify-punctuation`: unify all punctuations with same meaning, as part of the translation conventions, the punctuation should be full-width except brackets.\n - `中文, 中文.` -> `中文,中文。`\n- `case-abbr`: escape cases with half-width dots like `Mr.`, `e.g.`.\n - `Mr.` -> `Mr.`\n- `space-full-width-content`: keep one space between half-width content and full-width content\n - `中文English中文` -> `中文 English 中文`\n- `space-punctuation`: keep no space between full-width punctuation and the content besides, keep one space between half-width punctuation and the content besides\n - `中文 , 中文` -> `中文,中文`\n- `case-math-exp`: overwrite cases with math expressions\n - `1+1=2` -> `1 + 1 = 2`\n- `case-backslash`: deal with the backslash specially to avoid unpredictable result\n - `这实质上和问题 \\#1 是相同的`\n- `space-brackets`: keep one space outside and no space inside a pair of brackets when it's half-width, keep no space inside or outside when it's full-width\n- `space-quotes`: keep one space outside and no space inside a pair of brackets when it's half-width, keep no space inside or outside when it's full-width\n- `case-traditional`: unify all quotes, as part of the translation conventions.\n - `a「b」c` -> `a“b”c`\n- `case-datetime`: deal with the date & time specially to avoid unpredictable result\n - `2020/01/02 01:20:30`\n- `case-datetime-zh`: deal with the Chinese date & time format specially to avoid unpredictable result\n - `中文2020年1月1日0天0号0时0分00秒`\n- `case-ellipsis`: deal with the continuous dots as ellipsis specially to avoid unpredictable result\n - `中文...中文...a...b...中文...中文...a...b...`\n- `case-html-entity`: deal with the HTML entities specially to avoid unpredicutable result\n - `中文< & >中文`\n- `case-raw`: deal with the inline code in markdown specially to avoid unpredictable result\n - `` `Vue.nextTick`/`vm.$nextTick` ``\n- `case-linebreak`: deal with the linebreak (2 spaces at the end of a line) in markdown specially to avoid unpredictable result\n" | ||
} |
@@ -1,2 +0,2 @@ | ||
# <img src="./logo.svg" style="vertical-align: middle;"> zhlint | ||
# <img src="./docs/logo.svg" style="vertical-align: middle;"> zhlint | ||
@@ -23,3 +23,3 @@ A linting tool for Chinese text content. | ||
# glob files, lint them, and print validation report, | ||
# and exit with code `1` if there is any error found. | ||
# and exit with code `1` if there is any error found. | ||
zhlint <file-pattern> | ||
@@ -39,3 +39,3 @@ | ||
![](./screenshot-cli.png) | ||
![](./docs/screenshot-cli.png) | ||
@@ -78,3 +78,3 @@ ### As Node.js package | ||
![](./screenshot-browser.png) | ||
![](./docs/screenshot-browser.png) | ||
@@ -84,11 +84,11 @@ #### API | ||
- `run(str: string, options?: Options): Result`: Lint a certain file. | ||
- parameters: | ||
- `str`: The text content you want to lint. | ||
- `options`: Some options for advanced usage. | ||
- returns: | ||
- The result of a single piece of input string. It contains fixed text content as `value` and the infor of all `validations`. | ||
- parameters: | ||
- `str`: The text content you want to lint. | ||
- `options`: Some options for advanced usage. | ||
- returns: | ||
- The result of a single piece of input string. It contains fixed text content as `value` and the infor of all `validations`. | ||
- `report(results: Result[], logger?: Console): void`: Print out the validation reports for each file. | ||
- parameters: | ||
- `results`: An array for all linted results. | ||
- `logger`: The logger instance, by default it's `console` in Node.js/browser. | ||
- parameters: | ||
- `results`: An array for all linted results. | ||
- `logger`: The logger instance, by default it's `console` in Node.js/browser. | ||
@@ -98,19 +98,19 @@ #### Other type defs and advanced usage | ||
- `Result`: `{ file?: string, origin: string, result: string, validations: Validation[] }` | ||
- `file`: The file name. It's an optional field which is only used in CLI. | ||
- `origin`: the original text content. | ||
- `result`: the finally fixed text content. | ||
- `validations`: All the validation information. | ||
- `file`: The file name. It's an optional field which is only used in CLI. | ||
- `origin`: the original text content. | ||
- `result`: the finally fixed text content. | ||
- `validations`: All the validation information. | ||
- `Validation`: `{ index: number, length: number, name: string, target: string, message: string }` | ||
- `index`: The index of the target token in the input string. | ||
- `length`: The length of the target token in the input string. | ||
<!-- - `name`: The name of the rule that the token disobeys to. --> | ||
<!-- - `target`: The target part of the target token, like the `content` or the `spaceAfter` that, etc. --> | ||
<!-- - `name`: The name of the rule that the token disobeys to. --> | ||
<!-- - `target`: The target part of the target token, like the `content` or the `spaceAfter` that, etc. --> | ||
- `message`: The description of this validation in natural language. | ||
- `Options`: `{ rules?: string[], hyperParse?: string[], ignoredCases?: IgnoredCase[], logger?: Console }`: Customize your own rules and other advanced options. | ||
- `rules`: customize the linting rules by their names, could be `undefined` which means just use the default [rules](https://github.com/Jinjiang/zhlint/tree/master/src/rules). | ||
- `hyperParse`: customize the hyper parser by their names, could be `undefined` which means just use default [ignored cases parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js), [Markdown parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js) and the [Hexo tags parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js). | ||
- `ignoredCases`: provide exception cases which you would like to skip. | ||
- `logger`: same to the parameter in `report(...)`. | ||
- `rules`: customize the linting rules by their names, could be `undefined` which means just use the default [rules](https://github.com/Jinjiang/zhlint/tree/master/src/rules). | ||
- `hyperParse`: customize the hyper parser by their names, could be `undefined` which means just use default [ignored cases parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js), [Markdown parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js) and the [Hexo tags parser](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js). | ||
- `ignoredCases`: provide exception cases which you would like to skip. | ||
- `logger`: same to the parameter in `report(...)`. | ||
- `IgnoredCase`: `{ prefix?, textStart, textEnd?, suffix? }` | ||
- Just follows a certain format inspired from [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment). | ||
- Just follows a certain format inspired from [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment). | ||
@@ -136,4 +136,4 @@ ## Features | ||
```js | ||
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。'); | ||
``` | ||
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。') | ||
``` | ||
@@ -146,5 +146,7 @@ ### Setup ignored cases | ||
<!-- the good case --> | ||
text before (text inside) text after | ||
<!-- the bad case --> | ||
vm.$on( event, callback ) | ||
@@ -159,3 +161,3 @@ | ||
```js | ||
run(str, { ignoredCases: { textStart: '( ', textEnd: ' )' }}) | ||
run(str, { ignoredCases: { textStart: '( ', textEnd: ' )' } }) | ||
``` | ||
@@ -176,31 +178,31 @@ | ||
- `mark-raw`: keep one space out of the inline code in markdown | ||
- ``text`text`text`` -> ``text `text` text`` | ||
- `` text`text`text `` -> `` text `text` text `` | ||
- `mark-hyper`: move the space outside of the markdown marks | ||
- `text[ text ](link)text` -> `text [text](link) text` | ||
- `text[ text ](link)text` -> `text [text](link) text` | ||
- `unify-punctuation`: unify all punctuations with same meaning, as part of the translation conventions, the punctuation should be full-width except brackets. | ||
- `中文, 中文.` -> `中文,中文。` | ||
- `中文, 中文.` -> `中文,中文。` | ||
- `case-abbr`: escape cases with half-width dots like `Mr.`, `e.g.`. | ||
- `Mr.` -> `Mr.` | ||
- `Mr.` -> `Mr.` | ||
- `space-full-width-content`: keep one space between half-width content and full-width content | ||
- `中文English中文` -> `中文 English 中文` | ||
- `中文English中文` -> `中文 English 中文` | ||
- `space-punctuation`: keep no space between full-width punctuation and the content besides, keep one space between half-width punctuation and the content besides | ||
- `中文 , 中文` -> `中文,中文` | ||
- `中文 , 中文` -> `中文,中文` | ||
- `case-math-exp`: overwrite cases with math expressions | ||
- `1+1=2` -> `1 + 1 = 2` | ||
- `1+1=2` -> `1 + 1 = 2` | ||
- `case-backslash`: deal with the backslash specially to avoid unpredictable result | ||
- `这实质上和问题 \#1 是相同的` | ||
- `这实质上和问题 \#1 是相同的` | ||
- `space-brackets`: keep one space outside and no space inside a pair of brackets when it's half-width, keep no space inside or outside when it's full-width | ||
- `space-quotes`: keep one space outside and no space inside a pair of brackets when it's half-width, keep no space inside or outside when it's full-width | ||
- `case-traditional`: unify all quotes, as part of the translation conventions. | ||
- `a「b」c` -> `a“b”c` | ||
- `a「b」c` -> `a“b”c` | ||
- `case-datetime`: deal with the date & time specially to avoid unpredictable result | ||
- `2020/01/02 01:20:30` | ||
- `2020/01/02 01:20:30` | ||
- `case-datetime-zh`: deal with the Chinese date & time format specially to avoid unpredictable result | ||
- `中文2020年1月1日0天0号0时0分00秒` | ||
- `中文2020年1月1日0天0号0时0分00秒` | ||
- `case-ellipsis`: deal with the continuous dots as ellipsis specially to avoid unpredictable result | ||
- `中文...中文...a...b...中文...中文...a...b...` | ||
- `中文...中文...a...b...中文...中文...a...b...` | ||
- `case-html-entity`: deal with the HTML entities specially to avoid unpredicutable result | ||
- `中文< & >中文` | ||
- `中文< & >中文` | ||
- `case-raw`: deal with the inline code in markdown specially to avoid unpredictable result | ||
- `` `Vue.nextTick`/`vm.$nextTick` `` | ||
- `` `Vue.nextTick`/`vm.$nextTick` `` | ||
- `case-linebreak`: deal with the linebreak (2 spaces at the end of a line) in markdown specially to avoid unpredictable result |
@@ -1,2 +0,2 @@ | ||
# <img src="./logo.svg" style="vertical-align: middle;" /> zhlint | ||
# <img src="./docs/logo.svg" style="vertical-align: middle;" /> zhlint | ||
@@ -23,3 +23,3 @@ 一个中文内容的格式化工具。 | ||
# Glob 文件,执行格式化命令,并打印错误报告, | ||
# 如果有任何错误被发现,则会以错误码 `1` 退出。 | ||
# 如果有任何错误被发现,则会以错误码 `1` 退出。 | ||
zhlint <file-pattern> | ||
@@ -39,3 +39,3 @@ | ||
![](./screenshot-cli.png) | ||
![](./docs/screenshot-cli.png) | ||
@@ -78,3 +78,3 @@ ### 作为 Node.js 包 | ||
![](./screenshot-browser.png) | ||
![](./docs/screenshot-browser.png) | ||
@@ -84,11 +84,11 @@ #### API | ||
- `run(str: string, options?: Options): Result`:格式化某个文件。 | ||
- 参数: | ||
- `str`:需要格式化的文本内容。 | ||
- `options`:高阶选项。 | ||
- 返回值: | ||
- 针对输入的单个字符串的处理结果。其包好了修复格式之后的文本内容 `value` 以及所有 `validation` 的校验信息。 | ||
- 参数: | ||
- `str`:需要格式化的文本内容。 | ||
- `options`:高阶选项。 | ||
- 返回值: | ||
- 针对输入的单个字符串的处理结果。其包好了修复格式之后的文本内容 `value` 以及所有 `validation` 的校验信息。 | ||
- `report(results: Result[], logger?: Console): void`:为每个文件打印校验报告。 | ||
- 参数: | ||
- `results`:所有格式化结果的数组。 | ||
- `logger`:日志处理器实例,默认是 Node.js/浏览器中的 `console`。 | ||
- 参数: | ||
- `results`:所有格式化结果的数组。 | ||
- `logger`:日志处理器实例,默认是 Node.js/浏览器中的 `console`。 | ||
@@ -98,19 +98,19 @@ #### 其它类型定义和高阶用法 | ||
- `Result`:`{ file?: string, origin: string, result: string, validations: Validation[] }` | ||
- `file`:文件名。这是一个可选的字段,只在 CLI 中适用。 | ||
- `origin`:原始的文本内容。 | ||
- `result`:最终修复格式的文本内容。 | ||
- `validations`:所有校验信息。 | ||
- `file`:文件名。这是一个可选的字段,只在 CLI 中适用。 | ||
- `origin`:原始的文本内容。 | ||
- `result`:最终修复格式的文本内容。 | ||
- `validations`:所有校验信息。 | ||
- `Validation`:`{ index: number, length: number, name: string, target: string, message: string }` | ||
- `index`:输入的字符串中目标片段所在的索引值。 | ||
- `length`:输入的字符串中目标片段的长度。 | ||
<!-- - `name`: The name of the rule that the token disobeys to. --> | ||
<!-- - `target`: The target part of the target token, like the `content` or the `spaceAfter` that, etc. --> | ||
<!-- - `name`: The name of the rule that the token disobeys to. --> | ||
<!-- - `target`: The target part of the target token, like the `content` or the `spaceAfter` that, etc. --> | ||
- `message`:对该校验信息的自然语言描述。 | ||
- `Options`:`{ rules?: string[], hyperParse?: string[], ignoredCases?: IgnoredCase[], logger?: Console }`:自定义你的规则和其它高阶选项。 | ||
- `rules`:根据规则名自定义格式化规则列表,可以是 `undefined` 以使用默认[规则列表](https://github.com/Jinjiang/zhlint/tree/master/src/rules)。 | ||
- `hyperParse`:根据解析器名自定义超文本解析器列表,可以是 `undefined` 以使用默认的[忽略特例的解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js)、[Markdown 解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js)以及[Hexo tag 解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js)。 | ||
- `ignoredCases`:提供想要忽略的特例。 | ||
- `logger`:和 `report(...)` 中的参数相同。 | ||
- `rules`:根据规则名自定义格式化规则列表,可以是 `undefined` 以使用默认[规则列表](https://github.com/Jinjiang/zhlint/tree/master/src/rules)。 | ||
- `hyperParse`:根据解析器名自定义超文本解析器列表,可以是 `undefined` 以使用默认的[忽略特例的解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/ignore.js)、[Markdown 解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/md.js)以及[Hexo tag 解析器](https://github.com/Jinjiang/zhlint/tree/master/src/parsers/hexo.js)。 | ||
- `ignoredCases`:提供想要忽略的特例。 | ||
- `logger`:和 `report(...)` 中的参数相同。 | ||
- `IgnoredCase`:`{ prefix?, textStart, textEnd?, suffix? }` | ||
- 遵循该特定的格式,灵感来自 [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment)。 | ||
- 遵循该特定的格式,灵感来自 [W3C Scroll To Text Fragment Proposal](https://github.com/WICG/ScrollToTextFragment)。 | ||
@@ -128,3 +128,3 @@ ## 特性 | ||
```js | ||
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。'); | ||
run('现在过滤器只能用在插入文本中 (`{% raw %}{{ }}{% endraw %}` tags)。') | ||
``` | ||
@@ -138,5 +138,7 @@ | ||
<!-- the good case --> | ||
text before (text inside) text after | ||
<!-- the bad case --> | ||
vm.$on( event, callback ) | ||
@@ -151,3 +153,3 @@ | ||
```js | ||
run(str, { ignoredCases: { textStart: '( ', textEnd: ' )' }}) | ||
run(str, { ignoredCases: { textStart: '( ', textEnd: ' )' } }) | ||
``` | ||
@@ -168,31 +170,31 @@ | ||
- `mark-raw`:在 Markdown 内联代码之外保持一个空格的距离。 | ||
- ``text`text`text`` -> ``text `text` text`` | ||
- `` text`text`text `` -> `` text `text` text `` | ||
- `mark-hyper`:把 Markdown 标记内侧的空格移动到外侧。 | ||
- `text[ text ](link)text` -> `text [text](link) text` | ||
- `text[ text ](link)text` -> `text [text](link) text` | ||
- `unify-punctuation`:作为翻译约定的一部分,统一所有同义的标点符号选项。除括号以外的标点符号都应该使用全角符号。 | ||
- `中文, 中文.` -> `中文,中文。` | ||
- `中文, 中文.` -> `中文,中文。` | ||
- `case-abbr`:允许使用半角句号的特例,例如 `Mr.`、`e.g.`。 | ||
- `Mr.` -> `Mr.` | ||
- `Mr.` -> `Mr.` | ||
- `space-full-width-content`:在半角和全角文字之间保持一个空格的距离。 | ||
- `中文English中文` -> `中文 English 中文` | ||
- `中文English中文` -> `中文 English 中文` | ||
- `space-punctuation`:去除全角标点符号和文字之间的空格,同时在半角标点符号和其后面的文本之间保留一个空格。 | ||
- `中文 , 中文` -> `中文,中文` | ||
- `中文 , 中文` -> `中文,中文` | ||
- `case-math-exp`:允许数学运算表达式中的特例。 | ||
- `1+1=2` -> `1 + 1 = 2` | ||
- `1+1=2` -> `1 + 1 = 2` | ||
- `case-backslash`:允许用反斜线避免不符合预期的修改结果。 | ||
- `这实质上和问题 \#1 是相同的` | ||
- `这实质上和问题 \#1 是相同的` | ||
- `space-brackets`:在半角括号外侧保留一个空格的距离,同时去除内侧的空格;在全角括号内侧外侧均去除空格。 | ||
- `space-quotes`:在半角引号外侧保留一个空格的距离,同时去除内侧的空格;在全角引号内侧外侧均去除空格。 | ||
- `case-traditional`:作为翻译约定的一部分,统一所有的引号选项。 | ||
- `a「b」c` -> `a“b”c` | ||
- `a「b」c` -> `a“b”c` | ||
- `case-datetime`:避免因日期和时间导致的不符合预期的修改结果。 | ||
- `2020/01/02 01:20:30` | ||
- `2020/01/02 01:20:30` | ||
- `case-datetime-zh`:避免因中文日期和时间导致的不符合预期的修改结果。 | ||
- `中文2020年1月1日0天0号0时0分00秒` | ||
- `中文2020年1月1日0天0号0时0分00秒` | ||
- `case-ellipsis`:避免因连续多个半角句号以表示省略号导致的不符合预期的修改结果。 | ||
- `中文...中文...a...b...中文...中文...a...b...` | ||
- `中文...中文...a...b...中文...中文...a...b...` | ||
- `case-html-entity`:避免因 HTML entities 导致的不符合预期的修改结果。 | ||
- `中文< & >中文` | ||
- `中文< & >中文` | ||
- `case-raw`:避免 Markdown 内联代码中不符合预期的修改结果。 | ||
- `` `Vue.nextTick`/`vm.$nextTick` `` | ||
- `` `Vue.nextTick`/`vm.$nextTick` `` | ||
- `case-linebreak`:避免因 Markdown 换行 (在行尾放 2 个空格) 导致的不符合预期的修改结果。 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200
1
31144
13
5
88
1