Skip to content

Commit

Permalink
version 2.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Oct 25, 2022
1 parent 4b23d65 commit 72bf8ae
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 119 deletions.
115 changes: 6 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,14 @@ $ autocorrect update
## Usage

- [Using CLI](#using-cli)
- [Use in CLI](#use-in-cli)
- [Configuration](#configuration)
- [VS Code Extension](#vs-code-extension)
- [Use for JavaScript](#use-for-javascript)
- [Use for Node.js](#use-for-nodejs)
- [Use for Rust](#use-for-rust)
- [GitHub Action](#github-action)
- [GitLab CI](#gitlab-ci)
- [Use for programming](#use-for-programming)

### Using CLI
### Use in CLI

```bash
$ autocorrect text.txt
Expand Down Expand Up @@ -343,118 +341,17 @@ autocorrect:
# allow_failure: true
```

### Use for JavaScript
### Use for programming

AutoCorrect also provide a JavaScript module via WebAssembly, you can use it in your JavaScript project.

```bash
yarn add @huacnlee/autocorrect
```

And then:

```js
const autocorrect = import('@huacnlee/autocorrect');
const raw = `<p>你好Hello世界</p>`;
autocorrect.then((autocorrect) => {
const out = autocorrect.formatHTML(raw);
// "<p>你好 Hello 世界</p>"
});
```

### Use for Node.js

When you want use AutoCorrect in Node.js, you must install `autocorrect-node`.

```bash
yarn add autocorrect-node
```

And then:

```js
const autocorrect = require('autocorrect-node');

autocorrect.format('你好Hello世界');
// "你好 Hello 世界"
```

### Use for Rust

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_for` to format HTML content.

```rust
extern crate autocorrect;

fn main() {
let html = r#"
<article>
<h1>这是Heading标题</h1>
<div class="content">
<p>你好Rust世界<strong>Bold文本</strong></p>
<p>这是第二行p标签</p>
</div>
</article>
"#;

println!("{}", autocorrect::format_for(html, "html"));
// <article>
// <h1>这是 Heading 标题</h1>
// <div class="content">
// <p>你好 Rust 世界<strong>Bold 文本</strong></p>
// <p>这是第二行 p 标签</p>
// </div>
// </article>
}
````

## Other implements for programming
AutoCorrect make for supports use in many programming languages.

- Rust - [autocorrect](https://github.com/huacnlee/autocorrect)
- Ruby - [autocorrect-rb](https://github.com/huacnlee/autocorrect/tree/main/autocorrect-rb)
- Go - [autocorrect-go](https://github.com/longbridgeapp/autocorrect)
- Python - [autocorrect-py](https://github.com/huacnlee/autocorrect/tree/main/autocorrect-py)
- Node.js - [autocorrect-node](https://github.com/huacnlee/autocorrect/tree/main/autocorrect-node)
- JavaScript (Browser) - [autocorrect-wasm](https://github.com/huacnlee/autocorrect/tree/main/autocorrect-wasm)
- Java - [autocorrect-java](https://github.com/huacnlee/autocorrect/tree/main/autocorrect-java)

## Benchmark

Expand Down
2 changes: 1 addition & 1 deletion autocorrect-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
name = "autocorrect-cli"
readme = "../README.md"
repository = "https://github.com/huacnlee/autocorrect"
version = "2.3.1"
version = "2.3.2"

[[bin]]
name = "autocorrect"
Expand Down
22 changes: 21 additions & 1 deletion autocorrect-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,37 @@ Add `io.github.huacnlee:autocorrect-java` to your `pom.xml`:
<dependency>
<groupId>io.github.huacnlee</groupId>
<artifactId>autocorrect-java</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
</dependency>
<!-- NativeLibrary need slf4j, so there need add -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>
```

With Gradle:

```groovy
dependencies {
implementation 'io.github.huacnlee:autocorrect-java:2.3.2'
// NativeLibrary need slf4j, so there need add
implementation 'org.slf4j:slf4j-nop:1.7.36'
}
```

## Usage

```js
import io.github.huacnlee.AutoCorrect;

public static void main(String[] args) {
// Load config from string
String configStr = "{ ... }";
AutoCorrect.loadConfig(configStr);

String output = AutoCorrect.format("Hello你好");
System.out.println(output);
// Hello 你好
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-java/javasrc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.huacnlee</groupId>
<artifactId>autocorrect-java</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<name>autocorrect-java</name>
<description>A linter and formatter to help you to improve copywriting, correct spaces, words, punctuations between
CJK (Chinese, Japanese, Korean).
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "autocorrect-node"
version = "2.3.1"
version = "2.3.2"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autocorrect-node",
"version": "2.3.1",
"version": "2.3.2",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "MIT"
name = "autocorrect-py"
readme = "README.md"
repository = "https://github.com/huacnlee/autocorrect"
version = "2.3.1"
version = "2.3.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-rb/autocorrect-rb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $:.push File.expand_path("lib", __dir__)

Gem::Specification.new do |s|
s.name = "autocorrect-rb"
s.version = "2.3.1"
s.version = "2.3.2"
s.platform = Gem::Platform::RUBY
s.authors = ["Jason Lee"]
s.email = ["[email protected]"]
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-rb/ext/autocorrect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "autocorrect-rb"
version = "2.3.1"
version = "2.3.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
Expand Down
2 changes: 1 addition & 1 deletion autocorrect-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "autocorrect-wasm"
version = "2.3.1"
version = "2.3.2"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
2 changes: 1 addition & 1 deletion autocorrect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"
name = "autocorrect"
readme = "../README.md"
repository = "https://github.com/huacnlee/autocorrect"
version = "2.3.1"
version = "2.3.2"

[lib]
name = "autocorrect"
Expand Down

0 comments on commit 72bf8ae

Please sign in to comment.