From: konn Date: Wed, 9 Jul 2008 11:41:31 +0000 (+0000) Subject: * Added li tag with CSS for CHTML5.0 converter. X-Git-Tag: v0.13.0~4^2~1484 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1dadf2807f25357821a61c5e72fefa0c3346bf77;p=modchxj%2Fmod_chxj.git * Added li tag with CSS for CHTML5.0 converter. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/sandbox@2856 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- diff --git a/src/chxj_chtml50.c b/src/chxj_chtml50.c index 3ef6bedd..70613b56 100644 --- a/src/chxj_chtml50.c +++ b/src/chxj_chtml50.c @@ -2428,30 +2428,67 @@ s_chtml50_start_li_tag(void *pdoc, Node *node) chtml50_t *chtml50 = GET_CHTML50(pdoc); Doc *doc = chtml50->doc; Attr *attr; + char *attr_type = NULL; + char *attr_value = NULL; + char *attr_style = NULL; - W_L("entryp)) { + css_prop_list_t *style = s_chtml50_push_and_get_now_style(pdoc, node, attr_style); + if (style) { + css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type"); + css_property_t *cur; + for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) { + if (STRCASEEQ('d','D',"decimal", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "1"); + } + else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "A"); + } + else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "a"); + } + else if (STRCASEEQ('d','D',"disc", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "disc"); + } + else if (STRCASEEQ('s','S',"square", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "square"); + } + else if (STRCASEEQ('c','C',"circle", cur->value)) { + attr_type = apr_pstrdup(doc->pool, "circle"); + } + } } } + W_L(""); + return chtml50->out; } @@ -2469,6 +2506,10 @@ s_chtml50_end_li_tag(void *pdoc, Node *UNUSED(child)) { chtml50_t *chtml50 = GET_CHTML50(pdoc); + if (IS_CSS_ON(chtml50->entryp)) { + chxj_css_pop_prop_list(chtml50->css_prop_stack); + } + return chtml50->out; } diff --git a/test/chxj_chtml50/test_chxj_chtml50.c b/test/chxj_chtml50/test_chxj_chtml50.c index 8a93270d..f6dc9a49 100644 --- a/test/chxj_chtml50/test_chxj_chtml50.c +++ b/test/chxj_chtml50/test_chxj_chtml50.c @@ -546,6 +546,19 @@ void test_chtml50_ul_tag_with_css_003(); void test_chtml50_ul_tag_with_css_004(); void test_chtml50_ul_tag_with_css_005(); void test_chtml50_ul_tag_with_css_006(); + +void test_chtml50_li_tag_with_css_001(); +void test_chtml50_li_tag_with_css_002(); +void test_chtml50_li_tag_with_css_003(); +void test_chtml50_li_tag_with_css_004(); +void test_chtml50_li_tag_with_css_005(); +void test_chtml50_li_tag_with_css_006(); +void test_chtml50_li_tag_with_css_007(); +void test_chtml50_li_tag_with_css_008(); +void test_chtml50_li_tag_with_css_009(); +void test_chtml50_li_tag_with_css_010(); +void test_chtml50_li_tag_with_css_011(); +void test_chtml50_li_tag_with_css_012(); /* pend */ int @@ -1053,6 +1066,19 @@ main() CU_add_test(chtml50_suite, "test ul with css 004", test_chtml50_ul_tag_with_css_004); CU_add_test(chtml50_suite, "test ul with css 005", test_chtml50_ul_tag_with_css_005); CU_add_test(chtml50_suite, "test ul with css 006", test_chtml50_ul_tag_with_css_006); + + CU_add_test(chtml50_suite, "test li with css 001", test_chtml50_li_tag_with_css_001); + CU_add_test(chtml50_suite, "test li with css 002", test_chtml50_li_tag_with_css_002); + CU_add_test(chtml50_suite, "test li with css 003", test_chtml50_li_tag_with_css_003); + CU_add_test(chtml50_suite, "test li with css 004", test_chtml50_li_tag_with_css_004); + CU_add_test(chtml50_suite, "test li with css 005", test_chtml50_li_tag_with_css_005); + CU_add_test(chtml50_suite, "test li with css 006", test_chtml50_li_tag_with_css_006); + CU_add_test(chtml50_suite, "test li with css 007", test_chtml50_li_tag_with_css_007); + CU_add_test(chtml50_suite, "test li with css 008", test_chtml50_li_tag_with_css_008); + CU_add_test(chtml50_suite, "test li with css 009", test_chtml50_li_tag_with_css_009); + CU_add_test(chtml50_suite, "test li with css 010", test_chtml50_li_tag_with_css_010); + CU_add_test(chtml50_suite, "test li with css 011", test_chtml50_li_tag_with_css_011); + CU_add_test(chtml50_suite, "test li with css 012", test_chtml50_li_tag_with_css_012); /* aend */ CU_basic_run_tests(); @@ -14700,6 +14726,478 @@ void test_chtml50_ul_tag_with_css_006() #undef TEST_STRING #undef RESULT_STRING } + +/*===========================================================================*/ +/* li tag with CSS */ +/*===========================================================================*/ +char *test_chxj_serf_get017(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: decimal }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_001() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get017; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get018(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: upper-alpha }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_002() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get018; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get019(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: lower-alpha }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_003() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get019; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get020(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: disc }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_004() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get020; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get021(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: circle }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_005() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get021; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get022(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "li { list-style-type: square }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_chtml50_li_tag_with_css_006() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_007() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_008() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_009() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_010() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_011() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_chtml50_li_tag_with_css_012() +{ +#define TEST_STRING "" \ + "
  • あいう
  • かきく
" +#define RESULT_STRING "
  • あいう
  • かきく
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get022; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_chtml50(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} /* * vim:ts=2 et */