这是Headingæ ‡é¢˜
ä½ å¥½Rust世界Bold文本
这是第二行pæ ‡ç¾
The CLI tool based on Rust is used to automatically correct, for add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).
It also supports programming source code correcting, based on Parser, can recognize the file name, and can find the strings and the comment part to correct.
基于 Rust 编写的 CLI å·¥å…·ï¼Œç”¨äºŽè‡ªåŠ¨çº æ£æ–‡æ¡ˆï¼Œç»™ CJK(ä¸æ–‡ã€æ—¥è¯ã€éŸ©è¯ï¼‰ä¸Žè‹±æ–‡æ··å†™çš„场景,补充æ£ç¡®çš„ç©ºæ ¼ï¼ŒåŒæ—¶å°è¯•ä»¥å®‰å…¨çš„æ–¹å¼è‡ªåŠ¨çº æ£æ ‡ç‚¹ç¬¦å·ç‰ç‰ã€‚
é™¤äº†çº¯æ–‡æœ¬çš„è‡ªåŠ¨çº æ£ä»¥å¤–,AutoCorrect 基于 Parser çš„æ–¹å¼å¯¹å„ç§ç±»åž‹æºä»£ç 文件支æŒï¼Œèƒ½è‡ªåŠ¨è¯†åˆ«æ–‡ä»¶å,并准确找到å—符串ã€æ³¨é‡Šåšè‡ªåŠ¨çº æ£ã€‚
æ¤æ–¹æ¡ˆæœ€æ—©äºŽ 2013 å¹´ 出现于 Ruby China 的项目,并é€æ¥å®Œå–„规则细节,当å‰å‡†ç¡®çŽ‡è¾ƒé«˜ï¼ˆçº§å°‘æ•°å¼‚å¸¸æƒ…å†µï¼‰ï¼Œä½ å¯ä»¥æ”¾å¿ƒç”¨æ¥è¾…åŠ©ä½ å®Œæ•´è‡ªåŠ¨çº æ£åŠ¨ä½œã€‚
https://marketplace.visualstudio.com/items?itemName=huacnlee.auto-correct
:
in time).bash
$ curl -sSL https://git.io/JcGER | bash
after that, you will get /usr/local/bin/autocorrect
command.
```bash
AutoCorrect 1.0.0
Jason Lee
USAGE: autocorrect [FLAGS] [OPTIONS] [file]...
FLAGS: --fix Automatically fix problems and rewrite file. -h, --help Prints help information --lint Lint and output problems. -V, --version Prints version information
OPTIONS:
--type
ARGS:
```bash $ autocorrect text.txt ä½ å¥½ Hello 世界
$ autocorrect --fix text.txt $ autocorrect --fix zh-CN.yml $ autocorrect --fix ./ ```
```bash $ autocorrect --lint --format json text.txt
$ autocorrect --lint text.txt ```
diff
--> text.txt:1:3
- ä½ å¥½Hello世界
+ ä½ å¥½ Hello 世界
You also can lint multiple files:
bash
$ autocorrect --lint ./
If you want ignore AutoCorrect for a file, you can put autocorrect: false
.
js
// autocorrect: false
function hello() {
console.log('这整个文件ä¸ä¼šè¢«autocorrect修改');
}
In your Cargo.toml
toml
[dependencies]
autocorrect = "1.0.0"
Use autocorrect::format
to format plain text.
````rust extern crate autocorrect;
fn main() { println!("{}", autocorrect::format("长桥LongBridge App下载")); // => "长桥 LongBridge App 下载"
println!("{}", autocorrect::format("Ruby 2.7版本第1次å‘布"));
// => "Ruby 2.7 版本第 1 次å‘布"
println!("{}", autocorrect::format("于3月10日开始"));
// => "于 3 月 10 日开始"
println!("{}", autocorrect::format("包装日期为2013年3月10日"));
// => "包装日期为 2013 年 3 月 10 日"
println!("{}", autocorrect::format("全世界已有数百家公å¸åœ¨ç”Ÿäº§çŽ¯å¢ƒä¸ä½¿ç”¨Rust,以达到快速ã€è·¨å¹³å°ã€ä½Žèµ„æºå 用的目的。"));
// => "全世界已有数百家公å¸åœ¨ç”Ÿäº§çŽ¯å¢ƒä¸ä½¿ç”¨ Rust,以达到快速ã€è·¨å¹³å°ã€ä½Žèµ„æºå 用的目的。"
println!("{}", autocorrect::format("æ—¢ã«ã€ä¸–ç•Œä¸ã®æ•°ç™¾ã¨ã„ã†ä¼æ¥ãŒRustを採用ã—ã€é«˜é€Ÿã§ä½Žãƒªã‚½ãƒ¼ã‚¹ã®ã‚¯ãƒã‚¹ãƒ—ラットフォームソリューションを実ç¾ã—ã¦ã„ã¾ã™ã€‚"));
// => "æ—¢ã«ã€ä¸–ç•Œä¸ã®æ•°ç™¾ã¨ã„ã†ä¼æ¥ãŒ Rust を採用ã—ã€é«˜é€Ÿã§ä½Žãƒªã‚½ãƒ¼ã‚¹ã®ã‚¯ãƒã‚¹ãƒ—ラットフォームソリューションを実ç¾ã—ã¦ã„ã¾ã™ã€‚"
println!("{}", autocorrect::format("ì „ 세계 수백 ê°œì˜ íšŒì‚¬ê°€ 프로ë•ì…˜ 환경ì—ì„œ Rust를 사용하여 ë¹ ë¥´ê³ , í¬ë¡œìŠ¤ í”Œëž«í¼ ë° ë‚®ì€ ë¦¬ì†ŒìŠ¤ ì‚¬ìš©ëŸ‰ì„ ë‹¬ì„±í–ˆìŠµë‹ˆë‹¤."));
// => "ì „ 세계 수백 ê°œì˜ íšŒì‚¬ê°€ 프로ë•ì…˜ 환경ì—ì„œ Rust 를 사용하여 ë¹ ë¥´ê³ , í¬ë¡œìŠ¤ í”Œëž«í¼ ë° ë‚®ì€ ë¦¬ì†ŒìŠ¤ ì‚¬ìš©ëŸ‰ì„ ë‹¬ì„±í–ˆìŠµë‹ˆë‹¤."
println!("{}", autocorrect::format("需è¦ç¬¦å·?自动转æ¢å…¨è§’å—符ã€æ•°å—:我们将在16:32分出å‘去CBDä¸å¿ƒ.")
// => "需è¦ç¬¦å·ï¼Ÿè‡ªåŠ¨è½¬æ¢å…¨è§’å—符ã€æ•°å—:我们将在 16:32 分出å‘去 CBD ä¸å¿ƒã€‚"
```
Use autocorrect::format_html
to format html content.
```rust extern crate autocorrect;
fn main() { let html = r#"
ä½ å¥½Rust世界Bold文本
这是第二行pæ ‡ç¾
println!("{}", autocorrect::format_html(html));
// <article>
// <h1>这是 Heading æ ‡é¢˜</h1>
// <div class="content">
// <p>ä½ å¥½ Rust 世界<strong>Bold 文本</strong></p>
// <p>这是第二行 p æ ‡ç¾</p>
// </div>
// </article>
} ````
Use cargo bench
to run benchmark tests.
bash
test tests::bench_format_100 ... bench: 19,410 ns/iter (+/- 1,571)
test tests::bench_format_400 ... bench: 45,957 ns/iter (+/- 3,444)
test tests::bench_format_50 ... bench: 14,538 ns/iter (+/- 1,555)
| Total chars | Duration | | ----------- | -------- | | 50 | 0.014 ms | | 100 | 0.019 ms | | 400 | 0.045 ms |
TODO
This project under MIT license.