Comparing version
@@ -0,1 +1,8 @@ | ||
## 4.1.0 (2023-05-30) | ||
* CI: add Node.js 20 ([5b1c669](https://github.com/lovell/limax/commit/5b1c669)) | ||
* Ensure SPDX header in all source code ([98b0c53](https://github.com/lovell/limax/commit/98b0c53)) | ||
* Make use of capitals in language names consistent (#46) ([95aeb99](https://github.com/lovell/limax/commit/95aeb99)), closes [#46](https://github.com/lovell/limax/issues/46) | ||
* Replace @napi-rs/pinyin by pinyin-pro (#48) ([8848ea0](https://github.com/lovell/limax/commit/8848ea0)), closes [#48](https://github.com/lovell/limax/issues/48) | ||
## 4.0.0 (2023-02-27) | ||
@@ -2,0 +9,0 @@ |
@@ -0,1 +1,4 @@ | ||
// Copyright 2013 Lovell Fuller and others. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
type Options = { | ||
@@ -2,0 +5,0 @@ custom?: string[] | { [key: string]: string; }; |
@@ -0,1 +1,4 @@ | ||
// Copyright 2013 Lovell Fuller and others. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
'use strict'; | ||
@@ -6,6 +9,3 @@ | ||
const deburr = require('lodash.deburr'); | ||
let pinyin, PINYIN_STYLE; | ||
try { | ||
({ pinyin, PINYIN_STYLE } = require('@napi-rs/pinyin')); | ||
} catch (err) {} | ||
const { pinyin } = require('pinyin-pro'); | ||
@@ -46,5 +46,10 @@ function customCharsAsArray (custom) { | ||
mergeDigitSuffixes = tone; | ||
text = pinyin(text, { | ||
style: tone ? PINYIN_STYLE.WithToneNumEnd : PINYIN_STYLE.Plain | ||
}).join(' '); | ||
const data = pinyin(text, { type: 'all', toneType: 'none', nonZh: 'consecutive' }).map(item => { | ||
if (item.isZh) { | ||
return tone ? `${item.pinyin}${item.num || ''}` : item.pinyin; | ||
} else { | ||
return item.origin; | ||
} | ||
}); | ||
text = data.join(' '); | ||
// Remove punctuation symbols | ||
@@ -51,0 +56,0 @@ const customNonPunctuation = customCharsAsArray(options.custom).map(function (c) { return `\\${c}`; }).join(''); |
{ | ||
"name": "limax", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"main": "./lib/limax", | ||
@@ -52,7 +52,5 @@ "types": "index.d.ts", | ||
"lodash.deburr": "^4.1.0", | ||
"speakingurl": "^14.0.1" | ||
"speakingurl": "^14.0.1", | ||
"pinyin-pro": "^3.14.0" | ||
}, | ||
"optionalDependencies": { | ||
"@napi-rs/pinyin": "^1.7.1" | ||
}, | ||
"devDependencies": { | ||
@@ -59,0 +57,0 @@ "ava": "^5.2.0", |
@@ -20,3 +20,3 @@ # limax | ||
* Latin: e.g. English, français, Deutsch, español, português | ||
* Cyrillic: e.g. Русский язык, български език, українська мова | ||
* Cyrillic: e.g. русский язык, български език, українська мова | ||
* Chinese: e.g. 官话, 吴语 (converts to Latin script using Pinyin with optional tone number) | ||
@@ -108,3 +108,3 @@ * Japanese: e.g. ひらがな, カタカナ (converts to Romaji using Hepburn) | ||
Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2023 Lovell Fuller and contributors. | ||
Copyright 2013 Lovell Fuller and others. | ||
@@ -111,0 +111,0 @@ Licensed under the Apache License, Version 2.0 (the "License"); |
23587
3.14%79
8.22%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed