summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2021-02-15 10:20:22 +0000
committerVincent Sanders <vince@kyllikki.org>2021-02-15 10:20:22 +0000
commit0504194e51a35a88ceba06288a6a2d8243b27516 (patch)
tree34ae0bd0744febfa7154d054ba4d6bcb8cd2ece9
parentdbccd7cceb79d0fabebe5e183d85f750c058cd7e (diff)
downloadlibcss-0504194e51a35a88ceba06288a6a2d8243b27516.tar.gz
libcss-0504194e51a35a88ceba06288a6a2d8243b27516.tar.bz2
add css 3.1 complex predefined counter styles for addative systems
-rw-r--r--include/libcss/properties.h7
-rw-r--r--src/bytecode/opcodes.h7
-rw-r--r--src/parse/properties/utils.c9
-rw-r--r--src/parse/propstrings.c5
-rw-r--r--src/parse/propstrings.h3
-rw-r--r--src/select/format_list_style.c115
-rw-r--r--src/select/properties/list_style_type.c15
7 files changed, 155 insertions, 6 deletions
diff --git a/include/libcss/properties.h b/include/libcss/properties.h
index a5569d0..ae00551 100644
--- a/include/libcss/properties.h
+++ b/include/libcss/properties.h
@@ -638,7 +638,12 @@ enum css_list_style_type_e {
CSS_LIST_STYLE_TYPE_HIAGANA = 0x2c,
CSS_LIST_STYLE_TYPE_HIAGANA_IROHA = 0x2d,
CSS_LIST_STYLE_TYPE_KATAKANA = 0x2e,
- CSS_LIST_STYLE_TYPE_KATAKANA_IROHA = 0x2f
+ CSS_LIST_STYLE_TYPE_KATAKANA_IROHA = 0x2f,
+ CSS_LIST_STYLE_TYPE_JAPANESE_INFORMAL = 0x30,
+ CSS_LIST_STYLE_TYPE_JAPANESE_FORMAL = 0x31,
+ CSS_LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL = 0x32,
+ CSS_LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL = 0x33,
+ CSS_LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL = 0x34
};
enum css_margin_e {
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 1e561e5..01ea25a 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -523,7 +523,12 @@ enum op_list_style_type {
LIST_STYLE_TYPE_HIAGANA = 0x002b,
LIST_STYLE_TYPE_HIAGANA_IROHA = 0x002c,
LIST_STYLE_TYPE_KATAKANA = 0x002d,
- LIST_STYLE_TYPE_KATAKANA_IROHA = 0x002e
+ LIST_STYLE_TYPE_KATAKANA_IROHA = 0x002e,
+ LIST_STYLE_TYPE_JAPANESE_INFORMAL = 0x002f,
+ LIST_STYLE_TYPE_JAPANESE_FORMAL = 0x0030,
+ LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL = 0x0031,
+ LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL = 0x0032,
+ LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL = 0x0033
};
enum op_margin {
diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c
index c82c88f..707a22b 100644
--- a/src/parse/properties/utils.c
+++ b/src/parse/properties/utils.c
@@ -34,7 +34,7 @@ css_error css__parse_list_style_type_value(css_language *c, const css_token *ide
* upper-latin, armenian, georgian, lower-alpha, upper-alpha,
* none)
*/
- #define MAP_ENTRIES 47
+ #define MAP_ENTRIES 52
bool match;
int midx;
const struct {
@@ -87,7 +87,12 @@ css_error css__parse_list_style_type_value(css_language *c, const css_token *ide
{ HIAGANA, LIST_STYLE_TYPE_HIAGANA },
{ HIAGANA_IROHA, LIST_STYLE_TYPE_HIAGANA_IROHA },
{ KATAKANA, LIST_STYLE_TYPE_KATAKANA },
- { KATAKANA_IROHA, LIST_STYLE_TYPE_KATAKANA_IROHA }
+ { KATAKANA_IROHA, LIST_STYLE_TYPE_KATAKANA_IROHA },
+ { JAPANESE_INFORMAL, LIST_STYLE_TYPE_JAPANESE_INFORMAL },
+ { JAPANESE_FORMAL, LIST_STYLE_TYPE_JAPANESE_FORMAL },
+ { KOREAN_HANGUL_FORMAL, LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL },
+ { KOREAN_HANJA_INFORMAL, LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL },
+ { KOREAN_HANJA_FORMAL, LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL }
};
for (midx = 0; midx < MAP_ENTRIES; midx++) {
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index a2d9175..7d723e1 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -345,6 +345,11 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
SMAP("hiragana-iroha"),
SMAP("katakana"),
SMAP("katakana-iroha"),
+ SMAP("japanese-informal"),
+ SMAP("japanese-formal"),
+ SMAP("korean-hangul-formal"),
+ SMAP("korean-hanja-informal"),
+ SMAP("korean-hanja-formal"),
SMAP("invert"),
SMAP("visible"),
SMAP("always"),
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index f011231..fd24a47 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -88,7 +88,8 @@ enum {
DEVANAGARI, GUJARATI, GURMUKHI, HEBREW, KANNADA, LAO, MALAYALAM,
MONGOLIAN, MYANMAR, ORIYA, PERSIAN, TAMIL, TELUGU, THAI, TIBETAN,
CJK_EARTHLY_BRANCH, CJK_HEAVENLY_STEM, HIAGANA, HIAGANA_IROHA,
- KATAKANA, KATAKANA_IROHA,
+ KATAKANA, KATAKANA_IROHA, JAPANESE_INFORMAL, JAPANESE_FORMAL,
+ KOREAN_HANGUL_FORMAL, KOREAN_HANJA_INFORMAL, KOREAN_HANJA_FORMAL,
INVERT, VISIBLE, ALWAYS, AVOID, X_LOW, LOW, HIGH, X_HIGH, LIBCSS_STATIC,
RELATIVE, ABSOLUTE, ONCE, DIGITS, CONTINUOUS, CODE, SPELL_OUT, X_SLOW,
SLOW, FAST, X_FAST, FASTER, SLOWER, CENTER, JUSTIFY, CAPITALIZE,
diff --git a/src/select/format_list_style.c b/src/select/format_list_style.c
index 9cc5de7..0e3a39e 100644
--- a/src/select/format_list_style.c
+++ b/src/select/format_list_style.c
@@ -8,7 +8,7 @@
#include "select/propget.h"
#include "utils/utils.h"
-#define SYMBOL_SIZE 5
+#define SYMBOL_SIZE 8
typedef char symbol_t[SYMBOL_SIZE];
/**
@@ -330,6 +330,9 @@ calc_additive_system(int value,
/* iterate over the available weights */
for (widx = 0; widx < cstyle->items; widx++) {
+ if (cstyle->weights[widx] == 0) {
+ break;
+ }
times = value / cstyle->weights[widx];
if (times > 0) {
for (idx = 0;idx < times;idx++) {
@@ -975,6 +978,106 @@ static struct list_counter_style lcs_katakana_iroha = {
.suffix = "、",
};
+/**
+ * weights suitable for the five complex addative styles
+ */
+static const int complex_counter_weights[] = {
+ 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000,
+ 900, 800, 700, 600, 500, 400, 300, 200, 100,
+ 90, 80, 70, 60, 50, 40, 30, 20, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
+};
+static const symbol_t japanese_informal_symbols[] = {
+ "九千", "八千", "七千", "六千", "五千", "四千", "三千", "二千", "千",
+ "九百", "八百", "七百", "六百", "五百", "四百", "三百", "二百", "百",
+ "九十", "八十", "七十", "六十", "五十", "四十", "三十", "二十", "十",
+ "九", "八", "七", "六", "五", "四", "三", "二", "一", "〇",
+};
+static const struct list_counter_style lcs_japanese_informal = {
+ .name = "japanese-informal",
+ .system = calc_additive_system,
+ .fallback = &lcs_cjk_decimal,
+ .symbols = japanese_informal_symbols,
+ .weights = complex_counter_weights,
+ .items = (sizeof(japanese_informal_symbols) / SYMBOL_SIZE),
+ .range = { .start = -9999, .end = 9999 },
+ .negative = { .pre = "マイナス" },
+ .suffix = "\xE3\x80\x81",
+};
+
+static const symbol_t japanese_formal_symbols[] = {
+ "九阡", "八阡", "七阡", "六阡", "伍阡", "四阡", "参阡", "弐阡", "壱阡",
+ "九百", "八百", "七百", "六百", "伍百", "四百", "参百", "弐百", "壱百",
+ "九拾", "八拾", "七拾", "六拾", "伍拾", "四拾", "参拾", "弐拾", "壱拾",
+ "九", "八", "七", "六", "伍", "四", "参", "弐", "壱", "零",
+};
+static const struct list_counter_style lcs_japanese_formal = {
+ .name = "japanese-formal",
+ .system = calc_additive_system,
+ .fallback = &lcs_cjk_decimal,
+ .symbols = japanese_formal_symbols,
+ .weights = complex_counter_weights,
+ .items = (sizeof(japanese_formal_symbols) / SYMBOL_SIZE),
+ .range = { .start = -9999, .end = 9999 },
+ .negative = { .pre = "マイナス" },
+ .suffix = "\xE3\x80\x81",
+};
+
+static const symbol_t korean_hangul_formal_symbols[] = {
+ "구천", "팔천", "칠천", "육천", "오천", "사천", "삼천", "이천", "일천",
+ "구백", "팔백", "칠백", "육백", "오백", "사백", "삼백", "이백", "일백",
+ "구십", "팔십", "칠십", "육십", "오십", "사십", "삼십", "이십", "일십",
+ "구", "팔", "칠", "육", "오", "사", "삼", "이", "일", "영"
+};
+static const struct list_counter_style lcs_korean_hangul_formal = {
+ .name = "korean-hangul-formal",
+ .system = calc_additive_system,
+ .fallback = &lcs_cjk_decimal,
+ .symbols = korean_hangul_formal_symbols,
+ .weights = complex_counter_weights,
+ .items = (sizeof(korean_hangul_formal_symbols) / SYMBOL_SIZE),
+ .range = { .start = -9999, .end = 9999 },
+ .negative = { .pre = "\xEB\xA7\x88\xEC\x9D\xB4\xEB\x84\x88\xEC\x8A\xA4 " },
+ .suffix = ", ",
+};
+
+static const symbol_t korean_hanja_informal_symbols[] = {
+ "九千", "八千", "七千", "六千", "五千", "四千", "三千", "二千", "千",
+ "九百", "八百", "七百", "六百", "五百", "四百", "三百", "二百", "百",
+ "九十", "八十", "七十", "六十", "五十", "四十", "三十", "二十", "十",
+ "九", "八", "七", "六", "五", "四", "三", "二", "一", "零"
+};
+static const struct list_counter_style lcs_korean_hanja_informal = {
+ .name = "korean-hanja-informal",
+ .system = calc_additive_system,
+ .fallback = &lcs_cjk_decimal,
+ .symbols = korean_hanja_informal_symbols,
+ .weights = complex_counter_weights,
+ .items = (sizeof(korean_hanja_informal_symbols) / SYMBOL_SIZE),
+ .range = { .start = -9999, .end = 9999 },
+ .negative = { .pre = "\xEB\xA7\x88\xEC\x9D\xB4\xEB\x84\x88\xEC\x8A\xA4 " },
+ .suffix = ", ",
+};
+
+static const symbol_t korean_hanja_formal_symbols[] = {
+ "九仟", "八仟", "七仟", "六仟", "五仟", "四仟", "參仟", "貳仟", "壹仟",
+ "九百", "八百", "七百", "六百", "五百", "四百", "參百", "貳百", "壹百",
+ "九拾", "八拾", "七拾", "六拾", "五拾", "四拾", "參拾", "貳拾", "壹拾",
+ "九", "八", "七", "六", "五", "四", "參", "貳", "壹", "零"
+};
+static const struct list_counter_style lcs_korean_hanja_formal = {
+ .name = "korean-hanja-formal",
+ .system = calc_additive_system,
+ .fallback = &lcs_cjk_decimal,
+ .symbols = korean_hanja_formal_symbols,
+ .weights = complex_counter_weights,
+ .items = (sizeof(korean_hanja_formal_symbols) / SYMBOL_SIZE),
+ .range = { .start = -9999, .end = 9999 },
+ .negative = { .pre = "\xEB\xA7\x88\xEC\x9D\xB4\xEB\x84\x88\xEC\x8A\xA4 " },
+ .suffix = ", ",
+};
+
+
static const struct list_counter_style *
counter_style_from_computed_style(const css_computed_style *style)
@@ -1070,6 +1173,16 @@ counter_style_from_computed_style(const css_computed_style *style)
return &lcs_katakana;
case CSS_LIST_STYLE_TYPE_KATAKANA_IROHA:
return &lcs_katakana_iroha;
+ case CSS_LIST_STYLE_TYPE_JAPANESE_INFORMAL:
+ return &lcs_japanese_informal;
+ case CSS_LIST_STYLE_TYPE_JAPANESE_FORMAL:
+ return &lcs_japanese_formal;
+ case CSS_LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL:
+ return &lcs_korean_hangul_formal;
+ case CSS_LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL:
+ return &lcs_korean_hanja_informal;
+ case CSS_LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL:
+ return &lcs_korean_hanja_formal;
}
return NULL;
}
diff --git a/src/select/properties/list_style_type.c b/src/select/properties/list_style_type.c
index 7560c3b..e32d1b1 100644
--- a/src/select/properties/list_style_type.c
+++ b/src/select/properties/list_style_type.c
@@ -164,6 +164,21 @@ css_error css__cascade_list_style_type(uint32_t opv, css_style *style,
case LIST_STYLE_TYPE_KATAKANA_IROHA:
value = CSS_LIST_STYLE_TYPE_KATAKANA_IROHA;
break;
+ case LIST_STYLE_TYPE_JAPANESE_INFORMAL:
+ value = CSS_LIST_STYLE_TYPE_JAPANESE_INFORMAL;
+ break;
+ case LIST_STYLE_TYPE_JAPANESE_FORMAL:
+ value = CSS_LIST_STYLE_TYPE_JAPANESE_FORMAL;
+ break;
+ case LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL:
+ value = CSS_LIST_STYLE_TYPE_KOREAN_HANGUL_FORMAL;
+ break;
+ case LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL:
+ value = CSS_LIST_STYLE_TYPE_KOREAN_HANJA_INFORMAL;
+ break;
+ case LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL:
+ value = CSS_LIST_STYLE_TYPE_KOREAN_HANJA_FORMAL;
+ break;
}
}