Skip to content

Commit

Permalink
fix: ü display
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 6, 2022
1 parent 0985093 commit 94f31d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/data/idioms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24161,6 +24161,7 @@
雨鬣霜蹄
雪上加霜
雪中送炭
雪中送碳
雪中鸿爪
雪兆丰年
雪北香南
Expand Down Expand Up @@ -26211,4 +26212,4 @@
龟龄鹤算
龟龙片甲
龟龙鳞凤
龟龙麟凤
龟龙麟凤
11 changes: 8 additions & 3 deletions src/logic/idioms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export function getIdiom(word: string): [string, string | undefined] | undefined

export function getPinyin(word: string) {
const data = getIdiom(word)
if (data?.[1])
return data[1].split(/\s+/g)
return Pinyin(data?.[0] || toSimplified(word), { style: Pinyin.STYLE_TONE2 }).map(i => i[0])
const parts = data?.[1]
? data[1].split(/\s+/g)
: Pinyin(data?.[0] || toSimplified(word), { style: Pinyin.STYLE_TONE2 }).map(i => i[0])
// https://baike.baidu.com/item/%E6%B1%89%E8%AF%AD%E6%8B%BC%E9%9F%B3%E6%96%B9%E6%A1%88/1884432
return parts.map(i => i
.replace(/^(y|j|q|x)u([0-9]?)$/g, '$1v$2')
.replace(/^yu(\w+)([0-9]?)$/g, 'yv$1$2'),
)
}

0 comments on commit 94f31d8

Please sign in to comment.