Repository: zh-lx/pinyin-pro (ts)

Issue:
特殊拼音的转换
## bug 描述

```ts
import { convert } from "pinyin-pro";

for (const pinyin of ["m̄", "hm", "ê̄", "ế", "ê̌", "ề"]) {
  console.log(convert(pinyin, { format: "symbolToNum" }));
}
```

这些都没有转换

## 你预期的样子是？

正确加上声调数字

## pinyin-pro 版本号

3.20.3

## 引入方式

Node.js

## 最小成本的复现步骤

如上


Pull request description:
feat: 支持特殊拼音字符的转换
close #241 

Patch:
diff --git a/lib/core/convert/index.ts b/lib/core/convert/index.ts
index cc4374a..5292f10 100644
--- a/lib/core/convert/index.ts
+++ b/lib/core/convert/index.ts
@@ -31,8 +31,9 @@ const toneMap = {
   iu: ['iu', 'iū', 'iú', 'iǔ', 'iù'],
   i: ['i', 'ī', 'í', 'ǐ', 'ì'],
   u: ['u', 'ū', 'ú', 'ǔ', 'ù'],
-  n: ['n', 'n', 'ń', 'ň', 'ǹ'],
-  m: ['m', 'm', 'ḿ', 'm', 'm̀'],
+  n: ['n', 'n̄', 'ń', 'ň', 'ǹ'],
+  m: ['m', 'm̄', 'ḿ', 'm̌', 'm̀'],
+  ê: ['ê', 'ê̄', 'ế', 'ê̌', 'ề'],
 };
 
 /**
diff --git a/lib/core/pinyin/handle.ts b/lib/core/pinyin/handle.ts
index 54d3597..65ccfdc 100644
--- a/lib/core/pinyin/handle.ts
+++ b/lib/core/pinyin/handle.ts
@@ -99,8 +99,9 @@ const getPinyinWithoutTone: GetPinyinWithoutTone = (pinyin) => {
     .replace(/(ī|í|ǐ|ì)/g, "i")
     .replace(/(ū|ú|ǔ|ù)/g, "u")
     .replace(/(ǖ|ǘ|ǚ|ǜ)/g, "ü")
-    .replace(/(ń|ň|ǹ)/g, "n")
-    .replace(/ḿ|m̀/g, "m");
+    .replace(/(n̄|ń|ň|ǹ)/g, "n")
+    .replace(/(m̄|ḿ|m̌|m̀)/g, "m")
+    .replace(/(ê̄|ế|ê̌|ề)/g, "ê");
 };
 
 /**
@@ -224,11 +225,12 @@ const getFinalParts: GetFinalParts = (pinyin) => {
  */
 type GetNumOfTone = (pinyin: string) => string;
 const getNumOfTone: GetNumOfTone = (pinyin) => {
-  const reg_tone1 = /(ā|ō|ē|ī|ū|ǖ)/;
-  const reg_tone2 = /(á|ó|é|í|ú|ǘ|ń|ḿ)/;
-  const reg_tone3 = /(ǎ|ǒ|ě|ǐ|ǔ|ǚ|ň)/;
-  const reg_tone4 = /(à|ò|è|ì|ù|ǜ|ǹ|m̀)/;
-  const reg_tone0 = /(a|o|e|i|u|ü|n)/;
+  const reg_tone1 = /(ā|ō|ē|ī|ū|ǖ|n̄|m̄|ê̄)/;
+  const reg_tone2 = /(á|ó|é|í|ú|ǘ|ń|ḿ|ế)/;
+  const reg_tone3 = /(ǎ|ǒ|ě|ǐ|ǔ|ǚ|ň|m̌|ê̌)/;
+  const reg_tone4 = /(à|ò|è|ì|ù|ǜ|ǹ|m̀|ề)/;
+  const reg_tone0 = /(a|o|e|i|u|ü|ê)/;
+  const special_tone = /(n|m)$/;
   const tone_num_arr: string[] = [];
   const pinyin_arr = pinyin.split(" ");
   pinyin_arr.forEach((_pinyin) => {
@@ -242,6 +244,8 @@ const getNumOfTone: GetNumOfTone = (pinyin) => {
       tone_num_arr.push("4");
     } else if (reg_tone0.test(_pinyin)) {
       tone_num_arr.push("0");
+    } else if (special_tone.test(_pinyin)) {
+      tone_num_arr.push("0");
     } else {
       tone_num_arr.push("");
     }


Test patch:
diff --git a/test/convert.test.js b/test/convert.test.js
index 76c56ba..5d0ed7d 100644
--- a/test/convert.test.js
+++ b/test/convert.test.js
@@ -62,4 +62,9 @@ describe('convert', () => {
     const result = convert('liu2', { format: 'numToSymbol' });
     expect(result).to.be.equal('liú');
   });
+
+  it('[convert]special tone', () => {
+    const result = convert('m̄ hm ê̄ ế ê̌ ề', { format: 'symbolToNum' });
+    expect(result).to.be.equal('m1 hm0 ê1 ê2 ê3 ê4');
+  });
 });