Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed May 31, 2021
1 parent 3abdf58 commit 57b4a90
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
65 changes: 32 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,80 @@
0.11.0
------
## 1.0.0

- `Format`, `FormatHTML`, `Unformat`, `UnformatHTML` support custom option for addition processes.

Example:

```go
type myFormatter struct {}
func (my myFormatter) Format(text string) string {
return strings.ReplaceAll(text, "ios", "iOS")
}

autocorrect.Format("新版本ios即将发布", myFormatter{})
// "新版本 iOS 即将发布"
```

## 0.11.0

- Fix fullwidth to remove `;` for fix invalid convert with HTML Entity case.

0.10.0
--------
## 0.10.0

- Auto correct punctuation into fullwidth.

0.9.0
--------
## 0.9.0

- Change rule for ignore spacing between `#`, `$` chars.

0.8.2
--------
## 0.8.2

- Fix some break line miss bug.

0.8.0
--------
## 0.8.0

- Add `Unformat` / `UnformatHTML` method for remove spacings.

0.7.0
--------
## 0.7.0

- Use new HTML parser to format HTML for performance up.
- Avoid format text with script/style/textarea/pre tags.

0.6.1
--------
## 0.6.1

- Fix halfwidth to correct fullwidth spaces.

0.6.0
--------
## 0.6.0

- Auto correct FullWidth -> halfwidth for Letters, Numbers, and Colon in time.

0.4.1
--------
## 0.4.1

- Avoid create regex on format method call for performance up (~40%).

0.4.0
--------
## 0.4.0

- Add Full CJK (Chinese, Japanese, Korean) support.

0.3.3
--------
## 0.3.3

- Fix space around `-`;

0.3.2
--------
## 0.3.2

- Fix add space round `*`;

0.3.1
--------
## 0.3.1

- Fix HTML replace when content has escapeable `&`, ` ` chars.

0.3.0
--------
## 0.3.0

- Rename package from `autospace` to `autocorrect`.

0.2.0
--------
## 0.2.0

- Add `FormatHTML` method for process HTML contents.

0.1.0
--------
## 0.1.0

- First release.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-wi
- Fullwidth -> halfwidth (only for [a-zA-Z0-9], and `` in time).
- Correct punctuations into Fullwidth near the CJK.
- Cleanup spacings.
- Support options for custom format, unformat.

## Usage

Expand Down Expand Up @@ -60,6 +61,20 @@ func main() {
}
```

With custom formatter:

```go
type myFormatter struct {}
func (my myFormatter) Format(text string) string {
return strings.ReplaceAll(text, "ios", "iOS")
}

autocorrect.Format("新版本ios即将发布", myFormatter{})
// "新版本 iOS 即将发布"
autocorrect.FormatHTML("<p>新版本ios即将发布</p>", myFormatter{})
// "<p>新版本 iOS 即将发布</p>"
```

Use `autocorrect.Unformat` to cleanup spacings in plain text.

```go
Expand Down
2 changes: 2 additions & 0 deletions halfwidth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func Test_halfwidth(t *testing.T) {
assertEqual(t, "他说:我们将在16:32分出发去CBD中心。", halfwidth("他说:我们将在16:32分出发去CBD中心。"))
// Fullwidth space
assert.Equal(t, "ジョイフル-後場売り気配 200 店舗を閉鎖へ 7 月以降、不採算店中心に", halfwidth("ジョイフル-後場売り気配 200 店舗を閉鎖へ 7 月以降、不採算店中心に"))
// Fullwidth Numbers
assert.Equal(t, "0 1 2 3 4 5 6 7 8 9", halfwidth("0 1 2 3 4 5 6 7 8 9"))
}

func Benchmark_halfwidth(b *testing.B) {
Expand Down

0 comments on commit 57b4a90

Please sign in to comment.