Add NumberingKind variants for Korean (#1360)

Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
Sung Jeon 2023-05-31 01:42:24 +09:00 committed by GitHub
parent b805c5f100
commit 08b49291bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 10 deletions

Binary file not shown.

View File

@ -38,7 +38,7 @@ pub fn numbering(
/// Defines how the numbering works.
///
/// **Counting symbols** are `1`, `a`, `A`, `i`, `I`, `い`, `イ`,
/// `א`, and `*`. They are replaced by the number in the sequence,
/// `א`, `가`, `ㄱ`, and `*`. They are replaced by the number in the sequence,
/// in the given case.
///
/// The `*` character means that symbols should be used to count, in the
@ -132,7 +132,7 @@ cast_to_value! {
/// How to turn a number into text.
///
/// A pattern consists of a prefix, followed by one of `1`, `a`, `A`, `i`,
/// `I`, `い`, `イ`, `א`, or `*`, and then a suffix.
/// `I`, `い`, `イ`, `א`, `가`, `ㄱ`, or `*`, and then a suffix.
///
/// Examples of valid patterns:
/// - `1)`
@ -269,6 +269,8 @@ enum NumberingKind {
TraditionalChinese,
HiraganaIroha,
KatakanaIroha,
KoreanJamo,
KoreanSyllable,
}
impl NumberingKind {
@ -283,6 +285,8 @@ impl NumberingKind {
'一' | '壹' => NumberingKind::SimplifiedChinese,
'い' => NumberingKind::HiraganaIroha,
'イ' => NumberingKind::KatakanaIroha,
'ㄱ' => NumberingKind::KoreanJamo,
'가' => NumberingKind::KoreanSyllable,
_ => return None,
})
}
@ -299,6 +303,8 @@ impl NumberingKind {
Self::TraditionalChinese => '一',
Self::HiraganaIroha => 'い',
Self::KatakanaIroha => 'イ',
Self::KoreanJamo => 'ㄱ',
Self::KoreanSyllable => '가',
}
}
@ -464,6 +470,24 @@ impl NumberingKind {
Err(_) => '-'.into(),
}
}
Self::KoreanJamo => zeroless::<14>(
|x| {
[
'ㄱ', 'ㄴ', 'ㄷ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅅ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ',
'ㅌ', 'ㅍ', 'ㅎ',
][x]
},
n,
),
Self::KoreanSyllable => zeroless::<14>(
|x| {
[
'가', '나', '다', '라', '마', '바', '사', '아', '자', '차', '카',
'타', '파', '하',
][x]
},
n,
),
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -5,7 +5,7 @@
// Most Chinese publications do not use hanging punctuation at line end.
#set page(width: auto)
#set par(justify: true)
#set text(font: "Noto Serif CJK SC", lang: "zh")
#set text(lang: "zh", font: "Noto Serif CJK SC")
#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[
中文维基百科使用汉字书写汉字是汉族或华人的共同文字是中国大陆、新加坡、马来西亚、台湾、香港、澳门的唯一官方文字或官方文字之一。25.9%而美国和荷兰则分別占13.7%及8.2%。近年來,中国大陆地区的维基百科编辑者正在迅速增加;
@ -15,7 +15,7 @@
// Japanese typography is more complex, make sure it is at least a bit sensible.
#set page(width: auto)
#set par(justify: true)
#set text(lang: "jp")
#set text(lang: "jp", font: ("Linux Libertine", "Noto Serif CJK JP"))
#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[
ウィキペディア(英: Wikipediaは、世界中のボランティアの共同作業によって執筆及び作成されるフリーの多言語インターネット百科事典である。主に寄付に依って活動している非営利団体「ウィキメディア財団」が所有・運営している。
@ -40,10 +40,10 @@
// 17 characters a line.
#set page(width: 170pt + 10pt, margin: (x: 5pt))
#set text(font: "Noto Serif CJK SC", lang: "zh")
#set text(lang: "zh", font: "Noto Serif CJK SC")
#set par(justify: true)
孔雀最早见于《山海经》中的《海内经》:“有孔雀。”东汉杨孚著《异物志》记载,岭南:“孔雀,其大如大雁而足高,毛皆有斑纹彩,捕而蓄之,拍手即舞。”
#set text(font: "Noto Serif CJK TC", lang: "zh", region: "hk")
#set text(lang: "zh", region: "hk", font: "Noto Serif CJK TC")
孔雀最早见于《山海经》中的《海内经》:「有孔雀。」东汉杨孚著《异物志》记载,岭南:「孔雀,其大如大雁而足高,毛皆有斑纹彩,捕而蓄之,拍手即舞。」

View File

@ -32,7 +32,7 @@
}
---
#set text(lang: "zh")
#set text(lang: "zh", font: ("Linux Libertine", "Noto Serif CJK SC"))
#for i in range(9,21, step: 2){
numbering("一", i)
[ and ]
@ -41,6 +41,7 @@
}
---
#set text(lang: "jp", font: ("Linux Libertine", "Noto Serif CJK JP"))
#for i in range(0, 4) {
numbering("イ", i)
[ (or ]
@ -60,6 +61,27 @@
[ for #i \ ]
}
---
#set text(lang: "ko", font: ("Linux Libertine", "Noto Serif CJK KR"))
#for i in range(0, 4) {
numbering("가", i)
[ (or ]
numbering("ㄱ", i)
[) for #i \ ]
}
... \
#for i in range(47, 51) {
numbering("가", i)
[ (or ]
numbering("ㄱ", i)
[) for #i \ ]
}
... \
#for i in range(2256, 2260) {
numbering("ㄱ", i)
[ for #i \ ]
}
---
// Error: 17-19 number must be at least zero
#numbering("1", -1)

View File

@ -2,15 +2,15 @@
---
// without any region
#set text(lang: "zh")
#set text(font: "Noto Serif CJK TC", lang: "zh")
#outline()
---
// with unknown region configured
#set text(lang: "zh", region: "XX")
#set text(font: "Noto Serif CJK TC", lang: "zh", region: "XX")
#outline()
---
// with region configured
#set text(lang: "zh", region: "TW")
#set text(font: "Noto Serif CJK TC", lang: "zh", region: "TW")
#outline()