Skip to content

Commit 1e54903

Browse files
committed
Fix unexpected *...* conversions in 白-沙
1 parent e362ca2 commit 1e54903

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/routes/DataTable.svelte

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
中原音韻: ['i楊耐思', 'i寧繼福', 'i薛鳳生{音位形式}', 'iunt{音位形式}', 'iunt'],
1212
東干語: ['c拼寫', 'i音標'],
1313
};
14-
const romanizationDialects = ['普通話', '香港', '臺灣', '越南', '朝鮮', '日語吳音', '日語漢音'];
14+
const dialectsOfRomanization = ['普通話', '香港', '臺灣', '越南', '朝鮮', '日語吳音', '日語漢音', '日語其他'];
15+
const dialectsWithBold = ['中原音韻', '日語吳音', '日語漢音', '日語其他'];
1516
function wrapIPA(字音: string) {
1617
return `<span lang="zh-Latn-fonipa">${字音}</span>`;
1718
}
@@ -23,12 +24,9 @@
2324
.split('\t')
2425
.map(s => {
2526
let [音標, 解釋] = s.replace('}', '').split('{');
27+
let isBold = dialectsWithBold.includes(簡稱) && 音標.includes('*');
2628
if (headers[簡稱]) {
27-
let isBold = false;
28-
if (音標.includes('*')) {
29-
isBold = true;
30-
音標 = 音標.replace(/\*/g, '');
31-
}
29+
if (isBold) 音標 = 音標.replace(/\*/g, '');
3230
音標 = 音標
3331
.split('/')
3432
.map((s, i) => {
@@ -45,11 +43,13 @@
4543
})
4644
.filter(Boolean)
4745
.join('<br>');
48-
} else if (romanizationDialects.includes(簡稱)) {
46+
} else if (dialectsOfRomanization.includes(簡稱)) {
4947
音標 = wrapRomanization(音標);
5048
} else {
5149
音標 = wrapIPA(音標);
5250
}
51+
if (isBold) 音標 = 音標.replace(/\*(.*?)\*/g, '<strong>$1</strong>');
52+
音標 = 音標.replace(/\|(.*?)\|/g, '<span style="opacity: 0.5;">$1</span>');
5353
解釋 = 解釋?.replace(/ /g, '');
5454
if (解釋) {
5555
if (headers[簡稱]) 音標 += '<br>';
@@ -58,8 +58,6 @@
5858
return 音標;
5959
})
6060
.join(headers[簡稱] ? '<br><br>' : ' ')
61-
.replace(/\*(.*?)\*/g, '<strong>$1</strong>')
62-
.replace(/\|(.*?)\|/g, '<span style="opacity: 0.5;">$1</span>')
6361
.replace(/\{(.*?)\}/g, '<span class="desc">$1</span>');
6462
}
6563
</script>

0 commit comments

Comments
 (0)