mirror of
https://github.com/typst/typst
synced 2025-05-18 02:55:28 +08:00
Contemporary Japanese numbering (#3012)
This commit is contained in:
parent
b1256283da
commit
9741885aaf
@ -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| {
|
||||
[
|
||||
|
@ -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)
|
||||
#numbering("1", -1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user