|
11 | 11 | 中原音韻: ['i楊耐思', 'i寧繼福', 'i薛鳳生{音位形式}', 'iunt{音位形式}', 'iunt'], |
12 | 12 | 東干語: ['c拼寫', 'i音標'], |
13 | 13 | }; |
14 | | - const romanizationDialects = ['普通話', '香港', '臺灣', '越南', '朝鮮', '日語吳音', '日語漢音']; |
| 14 | + const dialectsOfRomanization = ['普通話', '香港', '臺灣', '越南', '朝鮮', '日語吳音', '日語漢音', '日語其他']; |
| 15 | + const dialectsWithBold = ['中原音韻', '日語吳音', '日語漢音', '日語其他']; |
15 | 16 | function wrapIPA(字音: string) { |
16 | 17 | return `<span lang="zh-Latn-fonipa">${字音}</span>`; |
17 | 18 | } |
|
23 | 24 | .split('\t') |
24 | 25 | .map(s => { |
25 | 26 | let [音標, 解釋] = s.replace('}', '').split('{'); |
| 27 | + let isBold = dialectsWithBold.includes(簡稱) && 音標.includes('*'); |
26 | 28 | if (headers[簡稱]) { |
27 | | - let isBold = false; |
28 | | - if (音標.includes('*')) { |
29 | | - isBold = true; |
30 | | - 音標 = 音標.replace(/\*/g, ''); |
31 | | - } |
| 29 | + if (isBold) 音標 = 音標.replace(/\*/g, ''); |
32 | 30 | 音標 = 音標 |
33 | 31 | .split('/') |
34 | 32 | .map((s, i) => { |
|
45 | 43 | }) |
46 | 44 | .filter(Boolean) |
47 | 45 | .join('<br>'); |
48 | | - } else if (romanizationDialects.includes(簡稱)) { |
| 46 | + } else if (dialectsOfRomanization.includes(簡稱)) { |
49 | 47 | 音標 = wrapRomanization(音標); |
50 | 48 | } else { |
51 | 49 | 音標 = wrapIPA(音標); |
52 | 50 | } |
| 51 | + if (isBold) 音標 = 音標.replace(/\*(.*?)\*/g, '<strong>$1</strong>'); |
| 52 | + 音標 = 音標.replace(/\|(.*?)\|/g, '<span style="opacity: 0.5;">$1</span>'); |
53 | 53 | 解釋 = 解釋?.replace(/ /g, ''); |
54 | 54 | if (解釋) { |
55 | 55 | if (headers[簡稱]) 音標 += '<br>'; |
|
58 | 58 | return 音標; |
59 | 59 | }) |
60 | 60 | .join(headers[簡稱] ? '<br><br>' : ' ') |
61 | | - .replace(/\*(.*?)\*/g, '<strong>$1</strong>') |
62 | | - .replace(/\|(.*?)\|/g, '<span style="opacity: 0.5;">$1</span>') |
63 | 61 | .replace(/\{(.*?)\}/g, '<span class="desc">$1</span>'); |
64 | 62 | } |
65 | 63 | </script> |
|
0 commit comments