Closed faceleg closed 2 months ago
Thanks for PR. It is interesting that I never came across these issues because I have tested this with HSK 3.0.
The result should be lǚ shǔ
. It breaks when there is no dictionary entry, and when pinyin conversion return v3 instead of u:3. So, the desired fix should be this.
diff --git a/src/pages/create.tsx b/src/pages/create.tsx
index 71233e7..ecbbcff 100644
--- a/src/pages/create.tsx
+++ b/src/pages/create.tsx
@@ -210,6 +210,10 @@ export default function CreateDeck(): JSX.Element {
let pin = pinyin(word.trim(), { toneToNumber: true });
pin = pin.replace(/0/g, "5");
+
+ // replace v3 with u:3
+ pin = pin.replace(/v/g, "u:");
+
let pizh = await pinzhu.pinyinAndZhuyin(pin, "", "");
let pinyin1 = [decodeHtmlEntities(pizh[1])];
I have pushed the fix in https://github.com/krmanik/Anki-xiehanzi/commit/251023bfcef558cd9be3bf2e1c68e22f1a631e39
I don't know anything about zhuyin, tried my best to make it work.
Works for Pinyin.