Contemporary Japanese numbering (#3012)

This commit is contained in:
k-84mo10 2023-12-26 06:28:00 +09:00 committed by GitHub
parent b1256283da
commit 9741885aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 3 deletions

View File

@ -39,7 +39,7 @@ pub fn numbering(
engine: &mut Engine,
/// Defines how the numbering works.
///
/// **Counting symbols** are `1`, `a`, `A`, `i`, `I`, `い`, `イ`, `א`, `가`,
/// **Counting symbols** are `1`, `a`, `A`, `i`, `I`, `あ`, ``, `ア`, `イ`, `א`, `가`,
/// `ㄱ`, and `*`. They are replaced by the number in the sequence, in the
/// given case.
///
@ -160,7 +160,7 @@ cast! {
/// 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)`
@ -292,7 +292,9 @@ pub enum NumberingKind {
// character.
#[allow(unused)]
TraditionalChinese,
HiraganaAiueo,
HiraganaIroha,
KatakanaAiueo,
KatakanaIroha,
KoreanJamo,
KoreanSyllable,
@ -308,7 +310,9 @@ impl NumberingKind {
'*' => NumberingKind::Symbol,
'א' => NumberingKind::Hebrew,
'一' | '壹' => NumberingKind::SimplifiedChinese,
'あ' => NumberingKind::HiraganaAiueo,
'い' => NumberingKind::HiraganaIroha,
'ア' => NumberingKind::KatakanaAiueo,
'イ' => NumberingKind::KatakanaIroha,
'ㄱ' => NumberingKind::KoreanJamo,
'가' => NumberingKind::KoreanSyllable,
@ -326,7 +330,9 @@ impl NumberingKind {
Self::Hebrew => 'א',
Self::SimplifiedChinese => '一',
Self::TraditionalChinese => '一',
Self::HiraganaAiueo => 'あ',
Self::HiraganaIroha => 'い',
Self::KatakanaAiueo => 'ア',
Self::KatakanaIroha => 'イ',
Self::KoreanJamo => 'ㄱ',
Self::KoreanSyllable => '가',
@ -346,6 +352,18 @@ impl NumberingKind {
},
n,
),
Self::HiraganaAiueo => zeroless::<46>(
|x| {
[
'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ',
'し', 'す', 'せ', 'そ', 'た', 'ち', 'つ', 'て', 'と', 'な', 'に',
'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま', 'み', 'む',
'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ',
'を', 'ん',
][x]
},
n,
),
Self::HiraganaIroha => zeroless::<47>(
|x| {
[
@ -358,6 +376,18 @@ impl NumberingKind {
},
n,
),
Self::KatakanaAiueo => zeroless::<46>(
|x| {
[
'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ',
'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ',
'ヌ', 'ネ', '', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム',
'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ',
'ヲ', 'ン',
][x]
},
n,
),
Self::KatakanaIroha => zeroless::<47>(
|x| {
[

View File

@ -82,6 +82,22 @@
[ for #i \ ]
}
---
#set text(lang: "jp", font: ("Linux Libertine", "Noto Serif CJK JP"))
#for i in range(0, 9) {
numbering("あ", i)
[ and ]
numbering("I.あ", i, i)
[ for #i \ ]
}
#for i in range(0, 9) {
numbering("ア", i)
[ and ]
numbering("I.ア", i, i)
[ for #i \ ]
}
---
// Error: 17-19 number must be at least zero
#numbering("1", -1)