Skip to content

Commit

Permalink
Replaced ifs with switch, included website in READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreihar committed May 24, 2024
1 parent d592d44 commit 0dcbb4d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br />
<div align="center">
<a href="https://github.com/andreihar/taibun.js">
<img src="readme/logo.png" alt="Logo" width="90" height="80">
<img src="https://github.com/andreihar/taibun/raw/main/readme/logo.png" alt="Logo" width="90" height="80">
</a>

# Taibun.js
Expand All @@ -15,6 +15,7 @@

<!-- PROJECT SHIELDS -->
[![Contributions][contributions-badge]][contributions]
[![Live Demo][demo-badge]][demo]
[![Tests][tests-badge]][tests]
[![Release][release-badge]][release]
[![Licence][licence-badge]][licence]
Expand Down Expand Up @@ -413,6 +414,8 @@ The data is licensed under [CC BY-SA 4.0][data-cc]
<!-- MARKDOWN LINKS -->
[contributions]: https://github.com/andreihar/taibun.js/issues
[contributions-badge]: https://img.shields.io/badge/Contributions-Welcomed-be132d?style=for-the-badge&logo=github
[demo]: https://taibun.andreihar.com/
[demo-badge]: https://img.shields.io/badge/Live_Demo-222222?style=for-the-badge&logo=homeadvisor&logoColor=white
[tests]: https://github.com/andreihar/taibun.js/actions
[tests-badge]: https://img.shields.io/github/actions/workflow/status/andreihar/taibun.js/ci.yaml?style=for-the-badge&logo=github-actions&logoColor=ffffff
[release-badge]: https://img.shields.io/github/v/release/andreihar/taibun.js?color=38618c&style=for-the-badge
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taibun",
"version": "1.0.4",
"version": "1.0.5",
"description": "Taiwanese Hokkien Transliterator and Tokeniser",
"main": "taibun/index.js",
"types": "taibun/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion readme/README-cmn.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br />
<div align="center">
<a href="https://github.com/andreihar/taibun.js">
<img src="logo.png" alt="Logo" width="90" height="80">
<img src="https://github.com/andreihar/taibun/raw/main/readme/logo.png" alt="Logo" width="90" height="80">
</a>

# Taibun.js
Expand All @@ -15,6 +15,7 @@

<!-- PROJECT SHIELDS -->
[![Contributions][contributions-badge]][contributions]
[![Live Demo][demo-badge]][demo]
[![Tests][tests-badge]][tests]
[![Release][release-badge]][release]
[![Licence][licence-badge]][licence]
Expand Down Expand Up @@ -413,6 +414,8 @@ isCjk('我食pháng');
<!-- MARKDOWN LINKS -->
[contributions]: https://github.com/andreihar/taibun.js/issues
[contributions-badge]: https://img.shields.io/badge/歡迎-貢獻協助-be132d?style=for-the-badge&logo=github
[demo]: https://taibun.andreihar.com/
[demo-badge]: https://img.shields.io/badge/現場演示-222222?style=for-the-badge&logo=homeadvisor&logoColor=white
[tests]: https://github.com/andreihar/taibun.js/actions
[tests-badge]: https://img.shields.io/github/actions/workflow/status/andreihar/taibun.js/ci.yaml?style=for-the-badge&logo=github-actions&logoColor=ffffff&label=構建
[release-badge]: https://img.shields.io/github/v/release/andreihar/taibun.js?color=38618c&style=for-the-badge&label=發布
Expand Down
5 changes: 4 additions & 1 deletion readme/README-oan.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br />
<div align="center">
<a href="https://github.com/andreihar/taibun.js">
<img src="logo.png" alt="Logo" width="90" height="80">
<img src="https://github.com/andreihar/taibun/raw/main/readme/logo.png" alt="Logo" width="90" height="80">
</a>

# Taibun.js
Expand All @@ -15,6 +15,7 @@

<!-- PROJECT SHIELDS -->
[![Contributions][contributions-badge]][contributions]
[![Live Demo][demo-badge]][demo]
[![Tests][tests-badge]][tests]
[![Release][release-badge]][release]
[![Licence][licence-badge]][licence]
Expand Down Expand Up @@ -413,6 +414,8 @@ isCjk('我食pháng');
<!-- MARKDOWN LINKS -->
[contributions]: https://github.com/andreihar/taibun.js/issues
[contributions-badge]: https://img.shields.io/badge/歡迎-貢獻協助-be132d?style=for-the-badge&logo=github
[demo]: https://taibun.andreihar.com/
[demo-badge]: https://img.shields.io/badge/現場演示-222222?style=for-the-badge&logo=homeadvisor&logoColor=white
[tests]: https://github.com/andreihar/taibun.js/actions
[tests-badge]: https://img.shields.io/github/actions/workflow/status/andreihar/taibun.js/ci.yaml?style=for-the-badge&logo=github-actions&logoColor=ffffff&label=構建
[release-badge]: https://img.shields.io/github/v/release/andreihar/taibun.js?color=38618c&style=for-the-badge&label=發布
Expand Down
Binary file removed readme/logo.png
Binary file not shown.
21 changes: 6 additions & 15 deletions taibun/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,11 @@ class Converter {
word = this.markToNumber(word);
}
if (this.format === 'strip') {
if (this.system === 'tlpa') {
word = word.replace(/[1234578]/g, '');
}
if (this.system === 'zhuyin') {
word = word.replace(/[ˋ˪ˊ˫˙]/g, '');
}
if (this.system === 'ipa') {
word = word.replace(/[¹²³]/g, '');
} else {
word = word.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
switch (this.system) {
case 'tlpa': word = word.replace(/[1234578]/g, ''); break;
case 'zhuyin': word = word.replace(/[ˋ˪ˊ˫˙]/g, ''); break;
case 'ipa': word = word.replace(/[¹²³]/g, ''); break;
default: word = word.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); break;
}
}
return word.replace(/--/g, Converter.suffixToken).replace(/-/g, this.delimiter).replace(new RegExp(Converter.suffixToken.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), '--');
Expand Down Expand Up @@ -585,9 +580,5 @@ class Tokeniser {
}

module.exports = {
Converter,
Tokeniser,
isCjk,
toTraditional,
toSimplified
Converter, Tokeniser, isCjk, toTraditional, toSimplified
};

0 comments on commit 0dcbb4d

Please sign in to comment.