OSDN Git Service

Merge branch 'branch_0.12.0' into branch_0.13.0
[modchxj/mod_chxj.git] / src / chxj_jhtml.c
1 /*
2  * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "chxj_jhtml.h"
18 #include "chxj_hdml.h"
19 #include "chxj_dump.h"
20 #include "chxj_img_conv.h"
21 #include "chxj_qr_code.h"
22 #include "chxj_encoding.h"
23 #include "chxj_url_encode.h"
24 #include "chxj_str_util.h"
25 #include "chxj_header_inf.h"
26 #include "chxj_jreserved_tag.h"
27
28
29 #define GET_JHTML(X) ((jhtml_t *)(X))
30 #undef W_L
31 #undef W_V
32 #define W_L(X)          do { jhtml->out = BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, (X)); } while(0)
33 #define W_V(X)          do { jhtml->out = (X) ? BUFFERED_WRITE_VALUE(jhtml->out, &doc->buf, (X))  \
34                                               : BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, ""); } while(0)
35 #undef W_NLCODE
36 #define W_NLCODE()     do { char *nlcode = TO_NLCODE(jhtml->conf); W_V(nlcode); } while (0)
37
38 static char *s_jhtml_start_html_tag     (void *pdoc, Node *node);
39 static char *s_jhtml_end_html_tag       (void *pdoc, Node *node);
40 static char *s_jhtml_start_meta_tag     (void *pdoc, Node *node);
41 static char *s_jhtml_end_meta_tag       (void *pdoc, Node *node);
42 static char *s_jhtml_start_head_tag     (void *pdoc, Node *node);
43 static char *s_jhtml_end_head_tag       (void *pdoc, Node *node);
44 static char *s_jhtml_start_title_tag    (void *pdoc, Node *node);
45 static char *s_jhtml_end_title_tag      (void *pdoc, Node *node);
46 static char *s_jhtml_start_base_tag     (void *pdoc, Node *node);
47 static char *s_jhtml_end_base_tag       (void *pdoc, Node *node);
48 static char *s_jhtml_start_body_tag     (void *pdoc, Node *node);
49 static char *s_jhtml_end_body_tag       (void *pdoc, Node *node);
50 static char *s_jhtml_start_a_tag        (void *pdoc, Node *node);
51 static char *s_jhtml_end_a_tag          (void *pdoc, Node *node);
52 static char *s_jhtml_start_pre_tag      (void *pdoc, Node *node);
53 static char *s_jhtml_end_pre_tag        (void *pdoc, Node *node);
54 static char *s_jhtml_start_p_tag        (void *pdoc, Node *node);
55 static char *s_jhtml_end_p_tag          (void *pdoc, Node *node);
56 static char *s_jhtml_start_ul_tag       (void *pdoc, Node *node);
57 static char *s_jhtml_end_ul_tag         (void *pdoc, Node *node);
58 static char *s_jhtml_start_ol_tag       (void *pdoc, Node *node);
59 static char *s_jhtml_end_ol_tag         (void *pdoc, Node *node);
60 static char *s_jhtml_start_li_tag       (void *pdoc, Node *node);
61 static char *s_jhtml_end_li_tag         (void *pdoc, Node *node);
62 static char *s_jhtml_start_br_tag       (void *pdoc, Node *node);
63 static char *s_jhtml_end_br_tag         (void *pdoc, Node *node);
64 static char *s_jhtml_start_tr_tag       (void *pdoc, Node *node);
65 static char *s_jhtml_end_tr_tag         (void *pdoc, Node *node);
66 static char *s_jhtml_start_font_tag     (void *pdoc, Node *node);
67 static char *s_jhtml_end_font_tag       (void *pdoc, Node *node);
68 static char *s_jhtml_start_form_tag     (void *pdoc, Node *node);
69 static char *s_jhtml_end_form_tag       (void *pdoc, Node *node);
70 static char *s_jhtml_start_input_tag    (void *pdoc, Node *node);
71 static char *s_jhtml_end_input_tag      (void *pdoc, Node *node);
72 static char *s_jhtml_start_center_tag   (void *pdoc, Node *node);
73 static char *s_jhtml_end_center_tag     (void *pdoc, Node *node);
74 static char *s_jhtml_start_hr_tag       (void *pdoc, Node *node);
75 static char *s_jhtml_end_hr_tag         (void *pdoc, Node *node);
76 static char *s_jhtml_start_img_tag      (void *pdoc, Node *node);
77 static char *s_jhtml_end_img_tag        (void *pdoc, Node *node);
78 static char *s_jhtml_start_select_tag   (void *pdoc, Node *node);
79 static char *s_jhtml_end_select_tag     (void *pdoc, Node *node);
80 static char *s_jhtml_start_option_tag   (void *pdoc, Node *node);
81 static char *s_jhtml_end_option_tag     (void *pdoc, Node *node);
82 static char *s_jhtml_start_div_tag      (void *pdoc, Node *node);
83 static char *s_jhtml_end_div_tag        (void *pdoc, Node *node);
84 static char *s_jhtml_start_textarea_tag (void *pdoc, Node *node);
85 static char *s_jhtml_end_textarea_tag   (void *pdoc, Node *node);
86 static char *s_jhtml_start_b_tag        (void *pdoc, Node *node);
87 static char *s_jhtml_end_b_tag          (void *pdoc, Node *node);
88 static char *s_jhtml_chxjif_tag         (void *pdoc, Node *node); 
89 static char *s_jhtml_text_tag           (void *pdoc, Node *node);
90 static char *s_jhtml_start_blockquote_tag (void *pdoc, Node *node);
91 static char *s_jhtml_end_blockquote_tag  (void *pdoc, Node *node);
92 static char *s_jhtml_start_dir_tag      (void *pdoc, Node *node);
93 static char *s_jhtml_end_dir_tag        (void *pdoc, Node *node);
94 static char *s_jhtml_start_dl_tag       (void *pdoc, Node *node);
95 static char *s_jhtml_end_dl_tag         (void *pdoc, Node *node);
96 static char *s_jhtml_start_dt_tag       (void *pdoc, Node *node);
97 static char *s_jhtml_end_dt_tag         (void *pdoc, Node *node);
98 static char *s_jhtml_start_dd_tag       (void *pdoc, Node *node);
99 static char *s_jhtml_end_dd_tag         (void *pdoc, Node *node);
100 static char *s_jhtml_start_h1_tag       (void *pdoc, Node *node);
101 static char *s_jhtml_end_h1_tag         (void *pdoc, Node *node);
102 static char *s_jhtml_start_h2_tag       (void *pdoc, Node *node);
103 static char *s_jhtml_end_h2_tag         (void *pdoc, Node *node);
104 static char *s_jhtml_start_h3_tag       (void *pdoc, Node *node);
105 static char *s_jhtml_end_h3_tag         (void *pdoc, Node *node);
106 static char *s_jhtml_start_h4_tag       (void *pdoc, Node *node);
107 static char *s_jhtml_end_h4_tag         (void *pdoc, Node *node);
108 static char *s_jhtml_start_h5_tag       (void *pdoc, Node *node);
109 static char *s_jhtml_end_h5_tag         (void *pdoc, Node *node);
110 static char *s_jhtml_start_h6_tag       (void *pdoc, Node *node);
111 static char *s_jhtml_end_h6_tag         (void *pdoc, Node *node);
112 static char *s_jhtml_start_menu_tag     (void *pdoc, Node *node);
113 static char *s_jhtml_end_menu_tag       (void *pdoc, Node *node);
114 static char *s_jhtml_start_plaintext_tag       (void *pdoc, Node *node);
115 static char *s_jhtml_start_plaintext_tag_inner (void *pdoc, Node *node);
116 static char *s_jhtml_end_plaintext_tag         (void *pdoc, Node *node);
117 static char *s_jhtml_start_blink_tag  (void *pdoc, Node *node);
118 static char *s_jhtml_end_blink_tag    (void *pdoc, Node *node);
119 static char *s_jhtml_start_marquee_tag (void *pdoc, Node *node);
120 static char *s_jhtml_end_marquee_tag  (void *pdoc, Node *node);
121 static char *s_jhtml_newline_mark       (void *pdoc, Node *node);
122 static char *s_jhtml_link_tag           (void *pdoc, Node *node);
123 static char *s_jhtml_start_span_tag     (void *pdoc, Node *node);
124 static char *s_jhtml_end_span_tag       (void *pdoc, Node *node);
125 static char *s_jhtml_style_tag       (void *pdoc, Node *node);
126
127 static void  s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec);
128
129 static int   s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt);
130
131 static char *chxj_istyle_to_mode(apr_pool_t *p, const char *s);
132 static css_prop_list_t *s_jhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
133 static css_prop_list_t *s_jhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
134
135
136
137 tag_handler jhtml_handler[] = {
138   /* tagHTML */
139   {
140     s_jhtml_start_html_tag,
141     s_jhtml_end_html_tag,
142   },
143   /* tagMETA */
144   {
145     s_jhtml_start_meta_tag,
146     s_jhtml_end_meta_tag,
147   },
148   /* tagTEXTAREA */
149   {
150     s_jhtml_start_textarea_tag,
151     s_jhtml_end_textarea_tag,
152   },
153   /* tagP */
154   {
155     s_jhtml_start_p_tag,
156     s_jhtml_end_p_tag,
157   },
158   /* tagPRE */
159   {
160     s_jhtml_start_pre_tag,
161     s_jhtml_end_pre_tag,
162   },
163   /* tagUL */
164   {
165     s_jhtml_start_ul_tag,
166     s_jhtml_end_ul_tag,
167   },
168   /* tagLI */
169   {
170     s_jhtml_start_li_tag,
171     s_jhtml_end_li_tag,
172   },
173   /* tagOL */
174   {
175     s_jhtml_start_ol_tag,
176     s_jhtml_end_ol_tag,
177   },
178   /* tagH1 */
179   {
180     s_jhtml_start_h1_tag,
181     s_jhtml_end_h1_tag,
182   },
183   /* tagH2 */
184   {
185     s_jhtml_start_h2_tag,
186     s_jhtml_end_h2_tag,
187   },
188   /* tagH3 */
189   {
190     s_jhtml_start_h3_tag,
191     s_jhtml_end_h3_tag,
192   },
193   /* tagH4 */
194   {
195     s_jhtml_start_h4_tag,
196     s_jhtml_end_h4_tag,
197   },
198   /* tagH5 */
199   {
200     s_jhtml_start_h5_tag,
201     s_jhtml_end_h5_tag,
202   },
203   /* tagH6 */
204   {
205     s_jhtml_start_h6_tag,
206     s_jhtml_end_h6_tag,
207   },
208   /* tagHEAD */
209   {
210     s_jhtml_start_head_tag,
211     s_jhtml_end_head_tag,
212   },
213   /* tagTITLE */
214   {
215     s_jhtml_start_title_tag,
216     s_jhtml_end_title_tag,
217   },
218   /* tagBASE */
219   {
220     s_jhtml_start_base_tag,
221     s_jhtml_end_base_tag,
222   },
223   /* tagBODY */
224   {
225     s_jhtml_start_body_tag,
226     s_jhtml_end_body_tag,
227   },
228   /* tagA */
229   {
230     s_jhtml_start_a_tag,
231     s_jhtml_end_a_tag,
232   },
233   /* tagBR */
234   {
235     s_jhtml_start_br_tag,
236     s_jhtml_end_br_tag,
237   },
238   /* tagTABLE */
239   {
240     NULL,
241     NULL,
242   },
243   /* tagTR */
244   {
245     s_jhtml_start_tr_tag,
246     s_jhtml_end_tr_tag,
247   },
248   /* tagTD */
249   {
250     NULL,
251     NULL,
252   },
253   /* tagTBODY */
254   {
255     NULL,
256     NULL,
257   },
258   /* tagFONT */
259   {
260     s_jhtml_start_font_tag,
261     s_jhtml_end_font_tag,
262   },
263   /* tagFORM */
264   {
265     s_jhtml_start_form_tag,
266     s_jhtml_end_form_tag,
267   },
268   /* tagINPUT */
269   {
270     s_jhtml_start_input_tag,
271     s_jhtml_end_input_tag,
272   },
273   /* tagCENTER */
274   {
275     s_jhtml_start_center_tag,
276     s_jhtml_end_center_tag,
277   },
278   /* tagHR */
279   {
280     s_jhtml_start_hr_tag,
281     s_jhtml_end_hr_tag,
282   },
283   /* tagIMG */
284   {
285     s_jhtml_start_img_tag,
286     s_jhtml_end_img_tag,
287   },
288   /* tagSELECT */
289   {
290     s_jhtml_start_select_tag,
291     s_jhtml_end_select_tag,
292   },
293   /* tagOPTION */
294   {
295     s_jhtml_start_option_tag,
296     s_jhtml_end_option_tag,
297   },
298   /* tagDIV */
299   {
300     s_jhtml_start_div_tag,
301     s_jhtml_end_div_tag,
302   },
303   /* tagCHXJIF */
304   {
305     s_jhtml_chxjif_tag,
306     NULL,
307   },
308   /* tagNOBR */
309   {
310     NULL,
311     NULL,
312   },
313   /* tagSMALL */
314   {
315     NULL,
316     NULL,
317   },
318   /* tagSTYLE */
319   {
320     s_jhtml_style_tag,
321     NULL,
322   },
323   /* tagSPAN */
324   {
325     s_jhtml_start_span_tag,
326     s_jhtml_end_span_tag,
327   },
328   /* tagTEXT */
329   {
330     s_jhtml_text_tag,
331     NULL,
332   },
333   /* tagTH */
334   {
335     NULL,
336     NULL,
337   },
338   /* tagB */
339   {
340     s_jhtml_start_b_tag,
341     s_jhtml_end_b_tag,
342   },
343   /* tagFIELDSET */
344   {
345     NULL,
346     NULL,
347   },
348   /* tagDT */
349   {
350     s_jhtml_start_dt_tag,
351     s_jhtml_end_dt_tag,
352   },
353   /* tagLEGEND */
354   {
355     NULL,
356     NULL,
357   },
358   /* tagLABEL */
359   {
360     NULL,
361     NULL,
362   },
363   /* tagBLOCKQUOTE */
364   {
365     s_jhtml_start_blockquote_tag,
366     s_jhtml_end_blockquote_tag,
367   },
368   /* tagDIR */
369   {
370     s_jhtml_start_dir_tag,
371     s_jhtml_end_dir_tag,
372   },
373   /* tagDL */
374   {
375     s_jhtml_start_dl_tag,
376     s_jhtml_end_dl_tag,
377   },
378   /* tagDD */
379   {
380     s_jhtml_start_dd_tag,
381     s_jhtml_end_dd_tag,
382   },
383   /* tagMENU */
384   {
385     s_jhtml_start_menu_tag,
386     s_jhtml_end_menu_tag,
387   },
388   /* tagPLAINTEXT */
389   {
390     s_jhtml_start_plaintext_tag,
391     s_jhtml_end_plaintext_tag,
392   },
393   /* tagBLINK */
394   {
395     s_jhtml_start_blink_tag,
396     s_jhtml_end_blink_tag,
397   },
398   /* tagMARQUEE */
399   {
400     s_jhtml_start_marquee_tag,
401     s_jhtml_end_marquee_tag,
402   },
403   /* tagLINK */
404   {
405     s_jhtml_link_tag,
406     NULL,
407   },
408   /* tagNLMARK */
409   {
410     s_jhtml_newline_mark,
411     NULL,
412   },
413 };
414
415
416 /**
417  * converts from CHTML5.0 to JHTML.
418  *
419  * @param r     [i]   Requet_rec is appointed.
420  * @param spec  [i]   The result of the device specification processing which 
421  *                    was done in advance is appointed.
422  * @param src   [i]   The character string before the converting is appointed.
423  * @return The character string after the converting is returned.
424  */
425 char *
426 chxj_convert_jhtml(
427   request_rec         *r,
428   device_table        *spec,
429   const char          *src,
430   apr_size_t          srclen,
431   apr_size_t          *dstlen,
432   chxjconvrule_entry  *entryp,
433   cookie_t            *cookie
434 )
435 {
436   char      *dst;
437   char      *ss;
438   jhtml_t   jhtml;
439   Doc       doc;
440   apr_pool_t *pool;
441
442   dst = NULL;
443
444   /*--------------------------------------------------------------------------*/
445   /* If qrcode xml                                                            */
446   /*--------------------------------------------------------------------------*/
447   *dstlen = srclen;
448   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
449   if (dst) {
450     DBG(r,"I found qrcode xml");
451     return dst;
452   }
453   DBG(r,"not found qrcode xml");
454
455   /*--------------------------------------------------------------------------*/
456   /* The CHTML structure is initialized.                                      */
457   /*--------------------------------------------------------------------------*/
458   s_init_jhtml(&jhtml, &doc, r, spec);
459
460   jhtml.entryp = entryp;
461   jhtml.cookie = cookie;
462
463   chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
464
465   /*--------------------------------------------------------------------------*/
466   /* The character string of the input is analyzed.                           */
467   /*--------------------------------------------------------------------------*/
468   qs_init_malloc(&doc);
469   qs_init_root_node(&doc);
470
471   apr_pool_create(&pool, r->pool);
472   ss = apr_pcalloc(pool, srclen + 1);
473
474   memset(ss,   0, srclen + 1);
475   memcpy(ss, src, srclen);
476
477 #ifdef DUMP_LOG
478   chxj_dump_out("[src] CHTML -> JHTML", ss, srclen);
479 #endif
480   if (IS_CSS_ON(jhtml.entryp)) {
481     /* current property list */
482     jhtml.css_prop_stack = chxj_new_prop_list_stack(&doc);
483   }
484
485   qs_parse_string(&doc,ss,strlen(ss));
486
487   chxj_buffered_write_init(r->pool, &doc.buf);
488   /*--------------------------------------------------------------------------*/
489   /* It converts it from CHTML to JHTML.                                      */
490   /*--------------------------------------------------------------------------*/
491   chxj_node_convert(spec,r,(void*)&jhtml, &doc, qs_get_root(&doc), 0);
492   jhtml.out = chxj_buffered_write_flush(jhtml.out, &doc.buf);
493   dst = apr_pstrdup(pool, jhtml.out);
494   chxj_buffered_write_terminate(&doc.buf);
495
496
497   qs_all_free(&doc,QX_LOGMARK);
498
499   if (! dst) 
500     return apr_pstrdup(pool,ss);
501
502   if (! strlen(dst)) 
503     dst = apr_psprintf(pool, "\n");
504
505   *dstlen = strlen(dst);
506
507 #ifdef DUMP_LOG
508   chxj_dump_out("[dst] CHTML -> JHTML", dst, *dstlen);
509 #endif
510
511   return dst;
512 }
513
514
515 /**
516  * The CHTML structure is initialized.
517  *
518  * @param jhtml [i/o] The pointer to the JHTML structure that wants to be
519  *                   initialized is specified.
520  * @param doc   [i]   The Doc structure that should be set to the initialized
521  *                   JHTML structure is specified.
522  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
523  * @param spec  [i]   The pointer to the device_table
524  */
525 static void
526 s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec)
527 {
528   memset(doc,   0, sizeof(Doc));
529   memset(jhtml, 0, sizeof(jhtml_t));
530
531   doc->r      = r;
532   jhtml->doc  = doc;
533   jhtml->spec = spec;
534   jhtml->out  = qs_alloc_zero_byte_string(r->pool);
535   jhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
536   jhtml->doc->parse_mode = PARSE_MODE_CHTML;
537 }
538
539
540 /**
541  * Corresponding EMOJI to a current character-code is retrieved. 
542  * The substitution character string is stored in the rslt pointer if agreeing.
543  *
544  * @param jhtml   [i]   The pointer to the CHTML structure is specified. 
545  * @param txt     [i]   The character string to want to examine whether it is 
546  *                      EMOJI is specified. 
547  * @param rslt    [o]   The pointer to the pointer that stores the result is 
548  *                      specified. 
549  * @return When corresponding EMOJI exists, it returns it excluding 0. 
550  */
551 static int
552 s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt)
553 {
554   emoji_t       *ee;
555   request_rec   *r;
556   device_table  *spec;
557   int           len;
558
559   spec = jhtml->spec;
560
561   len = strlen(txt);
562   r = jhtml->doc->r;
563
564   if (! spec) DBG(r,"spec is NULL");
565
566   for (ee = jhtml->conf->emoji;
567        ee;
568        ee = ee->next) {
569
570     unsigned char hex1byte;
571     unsigned char hex2byte;
572
573     if (! ee->imode) { 
574       DBG(r,"emoji->imode is NULL");
575       continue;
576     }
577
578     hex1byte = ee->imode->hex1byte & 0xff;
579     hex2byte = ee->imode->hex2byte & 0xff;
580
581     if (ee->imode->string
582     &&  strlen(ee->imode->string) > 0
583     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
584       if (spec == NULL || spec->emoji_type == NULL) {
585         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
586         return strlen(ee->imode->string);
587       }
588
589       return 0;
590     }
591
592     if (len >= 2
593     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
594     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
595       if (spec == NULL || spec->emoji_type == NULL) {
596         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
597         return 2;
598       }
599
600       return 0;
601     }
602   }
603
604   return 0;
605 }
606
607
608 char *
609 chxj_jhtml_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
610 {
611   apr_size_t ii;
612   Doc __doc;
613   Doc *doc;
614   jhtml_t __jhtml;
615   jhtml_t *jhtml;
616   char one_byte[2];
617   char two_byte[3];
618   apr_pool_t *pool;
619
620   jhtml = &__jhtml;
621   doc   = &__doc;
622
623   DBG(r, "REQ[%X] start chxj_jhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
624   memset(doc,   0, sizeof(Doc));
625   memset(jhtml, 0, sizeof(jhtml_t));
626
627   doc->r      = r;
628   jhtml->doc  = doc;
629   jhtml->spec = spec;
630   jhtml->out  = qs_alloc_zero_byte_string(r->pool);
631   jhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
632   jhtml->doc->parse_mode = PARSE_MODE_CHTML;
633
634   apr_pool_create(&pool, r->pool);
635
636   chxj_buffered_write_init(pool, &doc->buf);
637
638   for (ii=0; ii<len; ii++) {
639     char *out;
640     int   rtn;
641
642     rtn = s_jhtml_search_emoji(jhtml, (char *)&src[ii], &out);
643     if (rtn) {
644       W_V(out);
645       ii+=(rtn - 1);
646       continue;
647     }
648
649     if (is_sjis_kanji(src[ii])) {
650       two_byte[0] = src[ii+0];
651       two_byte[1] = src[ii+1];
652       two_byte[2] = 0;
653       W_V(two_byte);
654       ii++;
655     }
656     else {
657       one_byte[0] = src[ii+0];
658       one_byte[1] = 0;
659       W_V(one_byte);
660     }
661   }
662   jhtml->out = chxj_buffered_write_flush(jhtml->out, &doc->buf);
663
664   DBG(r, "REQ[%X] end chxj_jhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
665   return jhtml->out;
666 }
667
668
669 /**
670  * It is a handler who processes the HTML tag.
671  *
672  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
673  *                     destination is specified.
674  * @param node   [i]   The HTML tag node is specified.
675  * @return The conversion result is returned.
676  */
677 static char *
678 s_jhtml_start_html_tag(void *pdoc, Node *UNUSED(node)) 
679 {
680   jhtml_t       *jhtml;
681   Doc           *doc;
682   request_rec   *r;
683
684
685   jhtml  = GET_JHTML(pdoc);
686   doc    = jhtml->doc;
687   r      = doc->r;
688   DBG(r, "start s_jhtml_start_html_tag()");
689
690   /*--------------------------------------------------------------------------*/
691   /* start HTML tag                                                           */
692   /*--------------------------------------------------------------------------*/
693   W_L("<html>");
694
695   DBG(r, "end s_jhtml_start_html_tag()");
696
697   return jhtml->out;
698 }
699
700
701 /**
702  * It is a handler who processes the HTML tag.
703  *
704  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
705  *                     destination is specified.
706  * @param node   [i]   The HTML tag node is specified.
707  * @return The conversion result is returned.
708  */
709 static char *
710 s_jhtml_end_html_tag(void *pdoc, Node *UNUSED(child)) 
711 {
712   jhtml_t       *jhtml = GET_JHTML(pdoc);
713   Doc           *doc = jhtml->doc;
714
715   W_L("</html>");
716
717   return jhtml->out;
718 }
719
720
721 /**
722  * It is a handler who processes the META tag.
723  *
724  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
725  *                     destination is specified.
726  * @param node   [i]   The META tag node is specified.
727  * @return The conversion result is returned.
728  */
729 static char *
730 s_jhtml_start_meta_tag(void *pdoc, Node *node) 
731 {
732   jhtml_t      *jhtml;
733   Doc          *doc;
734   request_rec  *r;
735   Attr         *attr;
736   int          content_type_flag;
737   int          refresh_flag;
738
739   jhtml             = GET_JHTML(pdoc);
740   doc               = jhtml->doc;
741   r                 = doc->r;
742   refresh_flag      = 0;
743   content_type_flag = 0;
744
745   W_L("<meta");
746   /*--------------------------------------------------------------------------*/
747   /* Get Attributes                                                           */
748   /*--------------------------------------------------------------------------*/
749   for (attr = qs_get_attr(doc,node);
750        attr;
751        attr = qs_get_next_attr(doc,attr)) {
752     char *name   = qs_get_attr_name(doc,attr);
753     char *value  = qs_get_attr_value(doc,attr);
754     switch(*name) {
755     case 'h':
756     case 'H':
757       if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
758         /*----------------------------------------------------------------------*/
759         /* CHTML 2.0                                                            */
760         /*----------------------------------------------------------------------*/
761         W_L(" http-equiv=\"");
762         W_V(value);
763         W_L("\"");
764         if (STRCASEEQ('c','C',"content-type",value)) {
765           content_type_flag = 1;
766         }
767         if (STRCASEEQ('r','R',"refresh",value)) {
768           refresh_flag = 1;
769         }
770       }
771       break;
772
773     case 'c':
774     case 'C':
775       if (strcasecmp(name, "content") == 0 && value && *value) {
776         /*----------------------------------------------------------------------*/
777         /* CHTML 2.0                                                            */
778         /*----------------------------------------------------------------------*/
779         if (content_type_flag)  {
780           W_L(" ");
781           W_V(name);
782           W_L("=\"");
783           W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
784           W_L("\"");
785         }
786         else
787         if (refresh_flag) {
788           char *buf;
789           char *sec;
790           char *url;
791   
792           buf = apr_pstrdup(r->pool, value);
793   
794           url = strchr(buf, ';');
795           if (url) {
796             sec = apr_pstrdup(r->pool, buf);
797             sec[url-buf] = 0;
798             url++;
799             url = chxj_encoding_parameter(r, url, 0);
800             url = chxj_add_cookie_parameter(r, url, jhtml->cookie);
801             W_L(" ");
802             W_V(name);
803             W_L("=\"");
804             W_V(sec);
805             W_L(";");
806             W_V(url);
807             W_L("\"");
808           }
809         }
810         else {
811           W_L(" ");
812           W_V(name);
813           W_L("=\"");
814           W_V(value);
815           W_L("\"");
816         }
817       }
818       break;
819     
820     default:
821       break;
822     }
823   }
824   W_L(">");
825   return jhtml->out;
826 }
827
828
829 /**
830  * It is a handler who processes the META tag.
831  *
832  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
833  *                     destination is specified.
834  * @param node   [i]   The META tag node is specified.
835  * @return The conversion result is returned.
836  */
837 static char *
838 s_jhtml_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
839 {
840   jhtml_t *jhtml = GET_JHTML(pdoc);
841
842   return jhtml->out;
843 }
844
845
846 /**
847  * It is a handler who processes the HEAD tag.
848  *
849  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
850  *                     destination is specified.
851  * @param node   [i]   The HEAD tag node is specified.
852  * @return The conversion result is returned.
853  */
854 static char *
855 s_jhtml_start_head_tag(void *pdoc, Node *UNUSED(node)) 
856 {
857   jhtml_t       *jhtml;
858   Doc           *doc;
859   request_rec   *r;
860
861   jhtml = GET_JHTML(pdoc);
862   doc   = jhtml->doc;
863   r     = doc->r;
864
865   W_L("<head>");
866   return jhtml->out;
867 }
868
869
870 /**
871  * It is a handler who processes the HEAD tag.
872  *
873  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
874  *                     destination is specified.
875  * @param node   [i]   The HEAD tag node is specified.
876  * @return The conversion result is returned.
877  */
878 static char *
879 s_jhtml_end_head_tag(void *pdoc, Node *UNUSED(child)) 
880 {
881   jhtml_t       *jhtml;
882   Doc           *doc;
883   request_rec   *r;
884
885   jhtml = GET_JHTML(pdoc);
886   doc   = jhtml->doc;
887   r     = doc->r;
888
889   W_L("</head>");
890   return jhtml->out;
891 }
892
893
894 /**
895  * It is a handler who processes the TITLE tag.
896  *
897  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
898  *                     destination is specified.
899  * @param node   [i]   The TITLE tag node is specified.
900  * @return The conversion result is returned.
901  */
902 static char *
903 s_jhtml_start_title_tag(void *pdoc, Node *UNUSED(node)) 
904 {
905   jhtml_t      *jhtml;
906   Doc          *doc;
907   request_rec  *r;
908
909   jhtml = GET_JHTML(pdoc);
910   doc   = jhtml->doc;
911   r     = doc->r;
912
913   W_L("<title>");
914   return jhtml->out;
915 }
916
917
918 /**
919  * It is a handler who processes the TITLE tag.
920  *
921  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
922  *                     destination is specified.
923  * @param node   [i]   The TITLE tag node is specified.
924  * @return The conversion result is returned.
925  */
926 static char *
927 s_jhtml_end_title_tag(void *pdoc, Node *UNUSED(child)) 
928 {
929   jhtml_t       *jhtml;
930   Doc           *doc;
931   request_rec   *r;
932
933   jhtml = GET_JHTML(pdoc);
934   doc   = jhtml->doc;
935   r     = doc->r;
936
937   W_L("</title>");
938   return jhtml->out;
939 }
940
941
942 /**
943  * It is a handler who processes the BASE tag.
944  *
945  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
946  *                     destination is specified.
947  * @param node   [i]   The BASE tag node is specified.
948  * @return The conversion result is returned.
949  */
950 static char *
951 s_jhtml_start_base_tag(void *pdoc, Node *node) 
952 {
953   jhtml_t       *jhtml;
954   Attr          *attr;
955   Doc           *doc;
956   request_rec   *r;
957
958   jhtml = GET_JHTML(pdoc);
959   doc   = jhtml->doc;
960   r     = doc->r;
961
962   W_L("<base");
963   /*--------------------------------------------------------------------------*/
964   /* Get Attributes                                                           */
965   /*--------------------------------------------------------------------------*/
966   for (attr = qs_get_attr(doc,node);
967        attr;
968        attr = qs_get_next_attr(doc,attr)) {
969     char *name  = qs_get_attr_name(doc,attr);
970     char *value = qs_get_attr_value(doc,attr);
971     if (STRCASEEQ('h','H',"href",name)) {
972       W_L(" href=\"");
973       W_V(value);
974       W_L("\"");
975     }
976   }
977   W_L(">");
978   return jhtml->out;
979 }
980
981
982 /**
983  * It is a handler who processes the BASE tag.
984  *
985  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
986  *                     destination is specified.
987  * @param node   [i]   The BASE tag node is specified.
988  * @return The conversion result is returned.
989  */
990 static char *
991 s_jhtml_end_base_tag(void *pdoc, Node *UNUSED(child)) 
992 {
993   jhtml_t *jhtml = GET_JHTML(pdoc);
994   return jhtml->out;
995 }
996
997
998 /**
999  * It is a handler who processes the BODY tag.
1000  *
1001  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1002  *                     destination is specified.
1003  * @param node   [i]   The BODY tag node is specified.
1004  * @return The conversion result is returned.
1005  */
1006 static char *
1007 s_jhtml_start_body_tag(void *pdoc, Node *node) 
1008 {
1009   jhtml_t     *jhtml;
1010   Doc         *doc;
1011   request_rec *r;
1012   Attr        *attr;
1013   char        *attr_bgcolor = NULL;
1014   char        *attr_text    = NULL;
1015   char        *attr_link    = NULL;
1016   char        *attr_style   = NULL;
1017   char        *attr_vlink   = NULL;
1018
1019   jhtml = GET_JHTML(pdoc);
1020   doc   = jhtml->doc;
1021   r     = doc->r;
1022
1023   /*--------------------------------------------------------------------------*/
1024   /* Get Attributes                                                           */
1025   /*--------------------------------------------------------------------------*/
1026   for (attr = qs_get_attr(doc,node);
1027        attr;
1028        attr = qs_get_next_attr(doc,attr)) {
1029     char *name   = qs_get_attr_name(doc,attr);
1030     char *value  = qs_get_attr_value(doc,attr);
1031     if (STRCASEEQ('b','B',"bgcolor",name) && value && *value) {
1032       /*----------------------------------------------------------------------*/
1033       /* CHTML 2.0                                                            */
1034       /*----------------------------------------------------------------------*/
1035       attr_bgcolor = value;
1036     }
1037     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
1038       /*----------------------------------------------------------------------*/
1039       /* CHTML 2.0                                                            */
1040       /*----------------------------------------------------------------------*/
1041       attr_text = value;
1042     }
1043     else if (STRCASEEQ('l','L',"link",name) && value && *value) {
1044       /*----------------------------------------------------------------------*/
1045       /* CHTML 2.0                                                            */
1046       /*----------------------------------------------------------------------*/
1047       attr_link = value;
1048     }
1049     else if (STRCASEEQ('a','A',"alink",name)) {
1050       /*----------------------------------------------------------------------*/
1051       /* CHTML 4.0                                                            */
1052       /*----------------------------------------------------------------------*/
1053       /* ignore */
1054     }
1055     else if (STRCASEEQ('v','V',"vlink",name) && value && *value) {
1056       /*----------------------------------------------------------------------*/
1057       /* CHTML 4.0                                                            */
1058       /*----------------------------------------------------------------------*/
1059       attr_vlink = value;
1060     }
1061     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1062       /*----------------------------------------------------------------------*/
1063       /* CHTML 4.0                                                            */
1064       /*----------------------------------------------------------------------*/
1065       attr_style = value;
1066     }
1067   }
1068
1069   if (IS_CSS_ON(jhtml->entryp)) {
1070     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
1071     if (style) {
1072       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1073       css_property_t *bgcolor_prop    = chxj_css_get_property_value(doc, style, "background-color");
1074       css_property_t *cur;
1075       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1076         if (cur->value && *cur->value) {
1077           attr_text = apr_pstrdup(doc->pool, cur->value);
1078         }
1079       }
1080       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1081         if (cur->value && *cur->value) {
1082           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1083         }
1084       }
1085     }
1086     if (jhtml->style) {
1087       css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, jhtml->style);
1088       css_selector_t *cur_sel;
1089       for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1090         if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1091           css_property_t *cur;
1092           for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1093             if (cur->name && strcasecmp(cur->name, "color") == 0) {
1094               attr_link = apr_pstrdup(doc->pool, cur->value);
1095             }
1096           }
1097         }
1098         else if (cur_sel->name && strcasecmp(cur_sel->name, "a:visited") == 0) {
1099           css_property_t *cur;
1100           for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1101             if (cur->name && strcasecmp(cur->name, "color") == 0) {
1102               attr_vlink = apr_pstrdup(doc->pool, cur->value);
1103             }
1104           }
1105         }
1106       }
1107     }
1108   }
1109
1110   W_L("<body");
1111   if (attr_bgcolor) {
1112     attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1113     W_L(" bgcolor=\"");
1114     W_V(attr_bgcolor);
1115     W_L("\"");
1116   }
1117   if (attr_text) {
1118     attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1119     W_L(" text=\"");
1120     W_V(attr_text);
1121     W_L("\"");
1122   }
1123   if (attr_link) {
1124     attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1125     W_L(" link=\"");
1126     W_V(attr_link);
1127     W_L("\"");
1128   }
1129   if (attr_vlink) {
1130     attr_vlink = chxj_css_rgb_func_to_value(doc->pool, attr_vlink);
1131     W_L(" vlink=\"");
1132     W_V(attr_vlink);
1133     W_L("\"");
1134   }
1135   W_L(">");
1136
1137   return jhtml->out;
1138 }
1139
1140
1141 /**
1142  * It is a handler who processes the BODY tag.
1143  *
1144  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1145  *                     destination is specified.
1146  * @param node   [i]   The BODY tag node is specified.
1147  * @return The conversion result is returned.
1148  */
1149 static char *
1150 s_jhtml_end_body_tag(void *pdoc, Node *UNUSED(child)) 
1151 {
1152   jhtml_t       *jhtml;
1153   Doc           *doc;
1154   request_rec   *r;
1155
1156   jhtml = GET_JHTML(pdoc);
1157   doc   = jhtml->doc;
1158   r     = doc->r;
1159
1160   W_L("</body>");
1161   if (IS_CSS_ON(jhtml->entryp)) {
1162     chxj_css_pop_prop_list(jhtml->css_prop_stack);
1163   }
1164
1165   return jhtml->out;
1166 }
1167
1168
1169 /**
1170  * It is a handler who processes the A tag.
1171  *
1172  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1173  *                     destination is specified.
1174  * @param node   [i]   The A tag node is specified.
1175  * @return The conversion result is returned.
1176  */
1177 static char *
1178 s_jhtml_start_a_tag(void *pdoc, Node *node) 
1179 {
1180   jhtml_t     *jhtml;
1181   Doc         *doc;
1182   request_rec *r;
1183   Attr        *attr;
1184   char        *attr_style = NULL;
1185
1186   jhtml = GET_JHTML(pdoc);
1187   doc   = jhtml->doc;
1188   r     = doc->r;
1189
1190   W_L("<a");
1191   /*--------------------------------------------------------------------------*/
1192   /* Get Attributes                                                           */
1193   /*--------------------------------------------------------------------------*/
1194   for (attr = qs_get_attr(doc,node);
1195        attr; 
1196        attr = qs_get_next_attr(doc,attr)) {
1197     char *name  = qs_get_attr_name(doc,attr);
1198     char *value = qs_get_attr_value(doc,attr);
1199     if (STRCASEEQ('n','N',"name",name)) {
1200       /*----------------------------------------------------------------------*/
1201       /* CHTML1.0                                                             */
1202       /*----------------------------------------------------------------------*/
1203       W_L(" name=\"");
1204       W_V(value);
1205       W_L("\"");
1206     }
1207     else if (STRCASEEQ('h','H',"href",name)) {
1208       /*----------------------------------------------------------------------*/
1209       /* CHTML1.0                                                             */
1210       /*----------------------------------------------------------------------*/
1211       value = chxj_encoding_parameter(r, value, 0);
1212       if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1213         value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1214         value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jhtml->entryp, 0);
1215       }
1216       W_L(" href=\"");
1217       W_V(value);
1218       W_L("\"");
1219     }
1220     else if (STRCASEEQ('a','A',"accesskey",name)) {
1221       /*----------------------------------------------------------------------*/
1222       /* CHTML1.0                                                             */
1223       /*----------------------------------------------------------------------*/
1224       W_L(" accesskey=\"");
1225       W_V(value);
1226       W_L("\"");
1227     }
1228     else if (STRCASEEQ('c','C',"cti",name)) {
1229       /*----------------------------------------------------------------------*/
1230       /* CHTML 2.0                                                            */
1231       /*----------------------------------------------------------------------*/
1232       W_L(" cti=\"");
1233       W_V(value);
1234       W_L("\"");
1235     }
1236     else if (STRCASEEQ('i','I',"ijam",name)) {
1237       /*----------------------------------------------------------------------*/
1238       /* CHTML 3.0                                                            */
1239       /*----------------------------------------------------------------------*/
1240       /* ignore */
1241     }
1242     else if (STRCASEEQ('u','U',"utn",name)) {
1243       /*----------------------------------------------------------------------*/
1244       /* CHTML 3.0                                                            */
1245       /* It is special only for CHTML.                                        */
1246       /*----------------------------------------------------------------------*/
1247     }
1248     else if (STRCASEEQ('t','T',"telbook",name)) {
1249       /*----------------------------------------------------------------------*/
1250       /* CHTML 3.0                                                            */
1251       /*----------------------------------------------------------------------*/
1252       /* not support */
1253     }
1254     else if (STRCASEEQ('k','K',"kana",name)) {
1255       /*----------------------------------------------------------------------*/
1256       /* CHTML 3.0                                                            */
1257       /*----------------------------------------------------------------------*/
1258       /* not support */
1259     }
1260     else if (STRCASEEQ('e','E',"email",name)) {
1261       /*----------------------------------------------------------------------*/
1262       /* CHTML 3.0                                                            */
1263       /*----------------------------------------------------------------------*/
1264       /* not support */
1265     }
1266     else if (STRCASEEQ('i','I',"ista",name)) {
1267       /*----------------------------------------------------------------------*/
1268       /* CHTML 4.0                                                            */
1269       /*----------------------------------------------------------------------*/
1270       /* ignore */
1271     }
1272     else if (STRCASEEQ('i','I',"ilet",name)) {
1273       /*----------------------------------------------------------------------*/
1274       /* CHTML 5.0                                                            */
1275       /*----------------------------------------------------------------------*/
1276       /* ignore */
1277     }
1278     else if (STRCASEEQ('i','I',"iswf",name)) {
1279       /*----------------------------------------------------------------------*/
1280       /* CHTML 5.0                                                            */
1281       /*----------------------------------------------------------------------*/
1282       /* ignore */
1283     }
1284     else if (STRCASEEQ('i','I',"irst",name)) {
1285       /*----------------------------------------------------------------------*/
1286       /* CHTML 5.0                                                            */
1287       /*----------------------------------------------------------------------*/
1288       /* ignore */
1289     }
1290     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1291       attr_style = value;
1292     }
1293   }
1294   W_L(">");
1295
1296   if (IS_CSS_ON(jhtml->entryp)) {
1297     s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
1298   }
1299
1300   return jhtml->out;
1301 }
1302
1303
1304 /**
1305  * It is a handler who processes the A tag.
1306  *
1307  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1308  *                     destination is specified.
1309  * @param node   [i]   The A tag node is specified.
1310  * @return The conversion result is returned.
1311  */
1312 static char *
1313 s_jhtml_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1314 {
1315   jhtml_t      *jhtml;
1316   Doc          *doc;
1317   request_rec  *r;
1318
1319   jhtml = GET_JHTML(pdoc);
1320   doc   = jhtml->doc;
1321   r     = doc->r;
1322
1323   W_L("</a>");
1324
1325   if (IS_CSS_ON(jhtml->entryp)) {
1326     chxj_css_pop_prop_list(jhtml->css_prop_stack);
1327   }
1328
1329   return jhtml->out;
1330 }
1331
1332
1333 /**
1334  * It is a handler who processes the BR tag.
1335  *
1336  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1337  *                     destination is specified.
1338  * @param node   [i]   The BR tag node is specified.
1339  * @return The conversion result is returned.
1340  */
1341 static char *
1342 s_jhtml_start_br_tag(void *pdoc, Node *node)
1343 {
1344   jhtml_t      *jhtml;
1345   Doc          *doc;
1346   request_rec  *r;
1347   Attr         *attr;
1348
1349   jhtml = GET_JHTML(pdoc);
1350   doc   = jhtml->doc;
1351   r     = doc->r;
1352
1353   W_L("<br");
1354   /*--------------------------------------------------------------------------*/
1355   /* Get Attributes                                                           */
1356   /*--------------------------------------------------------------------------*/
1357   for (attr = qs_get_attr(doc,node);
1358        attr;
1359        attr = qs_get_next_attr(doc,attr)) {
1360     char *name  = qs_get_attr_name(doc,attr);
1361     char *value = qs_get_attr_value(doc,attr);
1362     if (STRCASEEQ('c','C',"clear",name)) {
1363       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1364         W_L(" clear=\"");
1365         W_V(value);
1366         W_L("\"");
1367       }
1368     }
1369   }
1370   W_L(">");
1371   return jhtml->out;
1372 }
1373
1374
1375 /**
1376  * It is a handler who processes the BR tag.
1377  *
1378  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1379  *                     destination is specified.
1380  * @param node   [i]   The BR tag node is specified.
1381  * @return The conversion result is returned.
1382  */
1383 static char *
1384 s_jhtml_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1385 {
1386   jhtml_t *jhtml = GET_JHTML(pdoc);
1387   return jhtml->out;
1388 }
1389
1390
1391 /**
1392  * It is a handler who processes the TR tag.
1393  *
1394  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1395  *                     destination is specified.
1396  * @param node   [i]   The TR tag node is specified.
1397  * @return The conversion result is returned.
1398  */
1399 static char *
1400 s_jhtml_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1401 {
1402   jhtml_t      *jhtml;
1403   Doc          *doc;
1404   request_rec  *r;
1405
1406   jhtml = GET_JHTML(pdoc);
1407   doc   = jhtml->doc;
1408   r     = doc->r;
1409
1410   W_L("<br>");
1411   return jhtml->out;
1412 }
1413
1414
1415 /**
1416  * It is a handler who processes the TR tag.
1417  *
1418  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1419  *                     destination is specified.
1420  * @param node   [i]   The TR tag node is specified.
1421  * @return The conversion result is returned.
1422  */
1423 static char *
1424 s_jhtml_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1425 {
1426   jhtml_t *jhtml = GET_JHTML(pdoc);
1427   return jhtml->out;
1428 }
1429
1430
1431 /**
1432  * It is a handler who processes the FONT tag.
1433  *
1434  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1435  *                     destination is specified.
1436  * @param node   [i]   The FONT tag node is specified.
1437  * @return The conversion result is returned.
1438  */
1439 static char *
1440 s_jhtml_start_font_tag(void *pdoc, Node *node) 
1441 {
1442   jhtml_t       *jhtml;
1443   Doc           *doc;
1444   request_rec   *r;
1445   Attr          *attr;
1446   char          *attr_color = NULL;
1447   char          *attr_style = NULL;
1448
1449   jhtml = GET_JHTML(pdoc);
1450   doc   = jhtml->doc;
1451   r     = doc->r;
1452
1453   /*--------------------------------------------------------------------------*/
1454   /* Get Attributes                                                           */
1455   /*--------------------------------------------------------------------------*/
1456   for (attr = qs_get_attr(doc,node);
1457        attr; 
1458        attr = qs_get_next_attr(doc,attr)) {
1459     char *name  = qs_get_attr_name(doc,attr);
1460     char *value = qs_get_attr_value(doc,attr);
1461     if (STRCASEEQ('c','C',"color",name) && value && *value) {
1462       attr_color = apr_pstrdup(doc->buf.pool, value);
1463       break;
1464     }
1465     else if (STRCASEEQ('s','S',"size",name)) {
1466       /*----------------------------------------------------------------------*/
1467       /* CHTML 5.0                                                            */
1468       /*----------------------------------------------------------------------*/
1469       /* ignore */
1470     }
1471     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
1472       attr_style = apr_pstrdup(doc->buf.pool, value);
1473     }
1474   }
1475   if (IS_CSS_ON(jhtml->entryp)) {
1476     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
1477     if (style) {
1478       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1479       css_property_t *cur;
1480       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1481         if (cur->value && *cur->value) {
1482           attr_color = apr_pstrdup(doc->pool, cur->value);
1483         }
1484       }
1485     }
1486   }
1487   if (attr_color) {
1488     attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1489     W_L("<font color=\"");
1490     W_V(attr_color);
1491     W_L("\">");
1492
1493     jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1494     flg->with_font_flag = 1;
1495     node->userData = flg;
1496   }
1497   else {
1498     node->userData = NULL;
1499   }
1500
1501   return jhtml->out;
1502 }
1503
1504
1505 /**
1506  * It is a handler who processes the FONT tag.
1507  *
1508  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1509  *                     destination is specified.
1510  * @param node   [i]   The FONT tag node is specified.
1511  * @return The conversion result is returned.
1512  */
1513 static char *
1514 s_jhtml_end_font_tag(void *pdoc, Node *node)
1515 {
1516   jhtml_t      *jhtml;
1517   request_rec  *r;
1518   Doc          *doc;
1519
1520   jhtml = GET_JHTML(pdoc);
1521   doc   = jhtml->doc;
1522   r     = jhtml->doc->r;
1523
1524   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
1525   if (flg && flg->with_font_flag) {
1526     W_L("</font>");
1527   }
1528   if (IS_CSS_ON(jhtml->entryp)) {
1529     chxj_css_pop_prop_list(jhtml->css_prop_stack);
1530   }
1531
1532   return jhtml->out;
1533 }
1534
1535
1536 /**
1537  * It is a handler who processes the FORM tag.
1538  *
1539  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1540  *                     destination is specified.
1541  * @param node   [i]   The FORM tag node is specified.
1542  * @return The conversion result is returned.
1543  */
1544 static char *
1545 s_jhtml_start_form_tag(void *pdoc, Node *node) 
1546 {
1547   jhtml_t     *jhtml;
1548   Doc         *doc;
1549   request_rec *r;
1550   Attr        *attr;
1551   char        *attr_action = NULL;
1552   char        *attr_method = NULL;
1553   char        *attr_style  = NULL;
1554   char        *attr_color  = NULL;
1555   char        *attr_align  = NULL;
1556   char        *new_hidden_tag = NULL;
1557
1558   jhtml = GET_JHTML(pdoc);
1559   doc     = jhtml->doc;
1560   r       = doc->r;
1561
1562   /*--------------------------------------------------------------------------*/
1563   /* Get Attributes                                                           */
1564   /*--------------------------------------------------------------------------*/
1565   for (attr = qs_get_attr(doc,node);
1566        attr;
1567        attr = qs_get_next_attr(doc,attr)) {
1568     char *name  = qs_get_attr_name(doc,attr);
1569     char *value = qs_get_attr_value(doc,attr);
1570     switch(*name) {
1571     case 'a':
1572     case 'A':
1573       if (strcasecmp(name, "action") == 0) {
1574         /*--------------------------------------------------------------------*/
1575         /* CHTML 1.0                                                          */
1576         /*--------------------------------------------------------------------*/
1577         attr_action = value;
1578       }
1579       break;
1580
1581     case 'm':
1582     case 'M':
1583       if (strcasecmp(name, "method") == 0) {
1584         /*--------------------------------------------------------------------*/
1585         /* CHTML 1.0                                                          */
1586         /*--------------------------------------------------------------------*/
1587         attr_method = value;
1588       }
1589       break;
1590
1591     case 's':
1592     case 'S':
1593       if (strcasecmp(name, "style") == 0) {
1594         attr_style = value;
1595       }
1596       break;
1597
1598     default:
1599       break;
1600     }
1601   }
1602   if (IS_CSS_ON(jhtml->entryp)) {
1603     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
1604     if (style) {
1605       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1606       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1607       css_property_t *cur;
1608       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1609         if (STRCASEEQ('l','L',"left", cur->value)) {
1610           attr_align = apr_pstrdup(doc->pool, "left");
1611         }
1612         else if (STRCASEEQ('c','C',"center",cur->value)) {
1613           attr_align = apr_pstrdup(doc->pool, "center");
1614         }
1615         else if (STRCASEEQ('r','R',"right",cur->value)) {
1616           attr_align = apr_pstrdup(doc->pool, "right");
1617         }
1618       }
1619       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1620         attr_color = apr_pstrdup(doc->pool, cur->value);
1621       }
1622     }
1623   }
1624
1625   int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1626
1627   W_L("<form");
1628   if (attr_action) {
1629     attr_action = chxj_encoding_parameter(r, attr_action, 0);
1630     attr_action = chxj_add_cookie_parameter(r, attr_action, jhtml->cookie);
1631     char *q;
1632     char *old_qs = NULL;
1633     q = strchr(attr_action, '?');
1634     if (q) {
1635       new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &old_qs, CHXJ_FALSE, CHXJ_TRUE, jhtml->entryp);
1636       if (new_hidden_tag || old_qs) {
1637         *q = 0;
1638       }
1639     }
1640     W_L(" action=\"");
1641     W_V(attr_action);
1642     if (old_qs) {
1643       W_L("?");
1644       W_V(old_qs);
1645     }
1646     W_L("\"");
1647   }
1648   if (attr_method) {
1649     W_L(" method=\"");
1650     W_V(attr_method);
1651     W_L("\"");
1652   }
1653   W_L(">");
1654
1655   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
1656   memset(flg, 0, sizeof(*flg));
1657   if (attr_color) {
1658     attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1659     W_L("<font color=\"");
1660     W_V(attr_color);
1661     W_L("\">");
1662     flg->with_font_flag = 1;
1663   }
1664   if (attr_align) {
1665     W_L("<div align=\"");
1666     W_V(attr_align);
1667     W_L("\">");
1668     flg->with_div_flag = 1;
1669   }
1670   node->userData = flg;
1671   /*-------------------------------------------------------------------------*/
1672   /* Add cookie parameter                                                    */
1673   /*-------------------------------------------------------------------------*/
1674   if (new_hidden_tag) {
1675     W_V(new_hidden_tag);
1676   }
1677   return jhtml->out;
1678 }
1679
1680
1681 /**
1682  * It is a handler who processes the FORM tag.
1683  *
1684  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1685  *                     destination is specified.
1686  * @param node   [i]   The FORM tag node is specified.
1687  * @return The conversion result is returned.
1688  */
1689 static char *
1690 s_jhtml_end_form_tag(void *pdoc, Node *node)
1691 {
1692   jhtml_t *jhtml = GET_JHTML(pdoc);
1693   Doc     *doc   = jhtml->doc;
1694
1695   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
1696   if (flg && flg->with_div_flag) {
1697     W_L("</div>");
1698   }
1699   if (flg && flg->with_font_flag) {
1700     W_L("</font>");
1701   }
1702   W_L("</form>");
1703   if (IS_CSS_ON(jhtml->entryp)) {
1704     chxj_css_pop_prop_list(jhtml->css_prop_stack);
1705   }
1706
1707   return jhtml->out;
1708 }
1709
1710
1711 /**
1712  * It is a handler who processes the INPUT tag.
1713  *
1714  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1715  *                     destination is specified.
1716  * @param node   [i]   The INPUT tag node is specified.
1717  * @return The conversion result is returned.
1718  */
1719 static char *
1720 s_jhtml_start_input_tag(void *pdoc, Node *node) 
1721 {
1722   jhtml_t     *jhtml;
1723   Doc         *doc;
1724   request_rec *r;
1725   Attr        *attr;
1726   char        *attr_accesskey  = NULL;
1727   char        *attr_max_length = NULL;
1728   char        *attr_type       = NULL;
1729   char        *attr_name       = NULL;
1730   char        *attr_value      = NULL;
1731   char        *attr_istyle     = NULL;
1732   char        *attr_size       = NULL;
1733   char        *attr_checked    = NULL;
1734   char        *attr_style      = NULL;
1735
1736   jhtml = GET_JHTML(pdoc);
1737   doc     = jhtml->doc;
1738   r       = doc->r;
1739
1740   /*--------------------------------------------------------------------------*/
1741   /* Get Attributes                                                           */
1742   /*--------------------------------------------------------------------------*/
1743   for (attr = qs_get_attr(doc,node);
1744        attr;
1745        attr = qs_get_next_attr(doc,attr)) {
1746     char *name  = qs_get_attr_name(doc,attr);
1747     char *value = qs_get_attr_value(doc,attr);
1748     if (STRCASEEQ('t','T',"type",name) && value && *value) {
1749       char *tmp_type = qs_trim_string(doc->buf.pool, value);
1750       if (tmp_type && (STRCASEEQ('t','T',"text",    tmp_type) ||
1751                        STRCASEEQ('p','P',"password",tmp_type) ||
1752                        STRCASEEQ('c','C',"checkbox",tmp_type) ||
1753                        STRCASEEQ('r','R',"radio",   tmp_type) ||
1754                        STRCASEEQ('h','H',"hidden",  tmp_type) ||
1755                        STRCASEEQ('s','S',"submit",  tmp_type) ||
1756                        STRCASEEQ('r','R',"reset",   tmp_type))) {
1757         attr_type = tmp_type;
1758       }
1759     }
1760     else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1761       attr_name = value;
1762     }
1763     else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1764       attr_value = value;
1765     }
1766     else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1767       attr_istyle = value;
1768     }
1769     else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1770       attr_max_length = value;
1771     }
1772     else if (STRCASEEQ('c','C',"checked", name)) {
1773       attr_checked = value;
1774     }
1775     else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1776       attr_accesskey = value;
1777     }
1778     else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1779       attr_size = value;
1780     }
1781     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1782       attr_style = value;
1783     }
1784   }
1785
1786   if (IS_CSS_ON(jhtml->entryp)) {
1787     css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
1788     if (style) {
1789       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1790       css_property_t *cur;
1791       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1792         if (strcasestr(cur->value, "<ja:n>")) {
1793           attr_istyle = "4";
1794         }
1795         else if (strcasestr(cur->value, "<ja:en>")) {
1796           attr_istyle = "3";
1797         }
1798         else if (strcasestr(cur->value, "<ja:hk>")) {
1799           attr_istyle = "2";
1800         }
1801         else if (strcasestr(cur->value, "<ja:h>")) {
1802           attr_istyle = "1";
1803         }
1804       }
1805     }
1806   }
1807
1808   W_L("<input");
1809   if (attr_type) {
1810     W_L(" type=\"");
1811     W_V(attr_type);
1812     W_L("\"");
1813   }
1814   if (attr_size) {
1815     W_L(" size=\"");
1816     W_V(attr_size);
1817     W_L("\"");
1818   }
1819   if (attr_name) {
1820     W_L(" name=\"");
1821     W_V(chxj_jreserved_to_safe_tag(r, attr_name, jhtml->entryp));
1822     W_L("\"");
1823   }
1824   if (attr_value) {
1825     W_L(" value=\"");
1826     W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1827     W_L("\"");
1828   }
1829   if (attr_accesskey) {
1830     W_L(" accesskey=\"");
1831     W_V(attr_accesskey);
1832     W_L("\"");
1833   }
1834   if (attr_istyle && (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4')) {
1835     /*------------------------------------------------------------------------*/
1836     /* CHTML 2.0                                                              */
1837     /*------------------------------------------------------------------------*/
1838     if (attr_type && STRCASEEQ('p','P',"password", attr_type) && ! jhtml->entryp->pc_flag ) {
1839       W_L(" mode=\"");
1840       W_L("numeric");
1841       W_L("\"");
1842     }
1843     else {
1844       char *vv = chxj_istyle_to_mode(doc->buf.pool,attr_istyle);
1845       W_L(" mode=\"");
1846       W_V(vv);
1847       W_L("\"");
1848     }
1849   }
1850   else if (attr_type && STRCASEEQ('p','P',"password",attr_type)) {
1851     W_L(" mode=\"");
1852     W_L("numeric");
1853     W_L("\"");
1854   }
1855   /*--------------------------------------------------------------------------*/
1856   /* The figure is default for the password.                                  */
1857   /*--------------------------------------------------------------------------*/
1858   if (attr_max_length && *attr_max_length) {
1859     if (chxj_chk_numeric(attr_max_length) == 0) {
1860       W_L(" maxlength=\"");
1861       W_V(attr_max_length);
1862       W_L("\"");
1863     }
1864   }
1865   if (attr_checked) {
1866     W_L(" checked");
1867   }
1868   W_L(">");
1869
1870   return jhtml->out;
1871 }
1872
1873
1874 /**
1875  * It is a handler who processes the INPUT tag.
1876  *
1877  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1878  *                     destination is specified.
1879  * @param node   [i]   The INPUT tag node is specified.
1880  * @return The conversion result is returned.
1881  */
1882 static char *
1883 s_jhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1884 {
1885   jhtml_t *jhtml = GET_JHTML(pdoc);
1886   return jhtml->out;
1887 }
1888
1889
1890 /**
1891  * It is a handler who processes the CENTER tag.
1892  *
1893  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1894  *                     destination is specified.
1895  * @param node   [i]   The CENTER tag node is specified.
1896  * @return The conversion result is returned.
1897  */
1898 static char *
1899 s_jhtml_start_center_tag(void *pdoc, Node *node)
1900 {
1901   jhtml_t *jhtml;
1902   Doc     *doc;
1903   Attr    *attr;
1904   char    *attr_style = NULL;
1905   char    *attr_color = NULL;
1906   char    *attr_size  = NULL;
1907
1908   jhtml = GET_JHTML(pdoc);
1909   doc     = jhtml->doc;
1910
1911   for (attr = qs_get_attr(doc,node);
1912        attr;
1913        attr = qs_get_next_attr(doc,attr)) {
1914     char *name  = qs_get_attr_name(doc,attr);
1915     char *value = qs_get_attr_value(doc,attr);
1916     if (STRCASEEQ('s','S',"style",name) && value && *value) {
1917       attr_style = value;
1918     }
1919   }
1920   if (IS_CSS_ON(jhtml->entryp)) {
1921     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
1922     if (style) {
1923       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
1924       css_property_t *cur;
1925       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1926         if (cur->value && *cur->value) {
1927           attr_color = apr_pstrdup(doc->pool, cur->value);
1928         }
1929       }
1930     }
1931   }
1932
1933   W_L("<center>");
1934   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
1935   memset(flg, 0, sizeof(*flg));
1936   if (attr_color || attr_size) {
1937     W_L("<font");
1938     if (attr_color) {
1939       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1940       W_L(" color=\"");
1941       W_V(attr_color);
1942       W_L("\"");
1943     }
1944     if (attr_size) {
1945       W_L(" size=\"");
1946       W_V(attr_size);
1947       W_L("\"");
1948     }
1949     flg->with_font_flag = 1;
1950     W_L(">");
1951   }
1952   node->userData = flg;
1953
1954   return jhtml->out;
1955 #if 0
1956   jhtml_t *jhtml = GET_JHTML(pdoc);
1957   Doc     *doc   = jhtml->doc;
1958   W_L("<center>");
1959   return jhtml->out;
1960 #endif
1961 }
1962
1963
1964 /**
1965  * It is a handler who processes the CENTER tag.
1966  *
1967  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1968  *                     destination is specified.
1969  * @param node   [i]   The CENTER tag node is specified.
1970  * @return The conversion result is returned.
1971  */
1972 static char *
1973 s_jhtml_end_center_tag(void *pdoc, Node *node)
1974 {
1975   jhtml_t     *jhtml;
1976   Doc         *doc;
1977   request_rec *r;
1978
1979   jhtml = GET_JHTML(pdoc);
1980   doc   = jhtml->doc;
1981   r     = doc->r;
1982
1983   if (IS_CSS_ON(jhtml->entryp)) {
1984     chxj_css_pop_prop_list(jhtml->css_prop_stack);
1985   }
1986   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
1987   if (flg && flg->with_font_flag) {
1988     W_L("</font>");
1989   }
1990   W_L("</center>");
1991   return jhtml->out;
1992 }
1993
1994
1995 /**
1996  * It is a handler who processes the li tag.
1997  *
1998  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1999  *                     destination is specified.
2000  * @param node   [i]   The li tag node is specified.
2001  * @return The conversion result is returned.
2002  */
2003 static char *
2004 s_jhtml_start_li_tag(void *pdoc, Node *node)
2005 {
2006   jhtml_t     *jhtml;
2007   Doc         *doc;
2008   request_rec *r;
2009   Attr        *attr;
2010   char        *attr_type = NULL;
2011   char        *attr_value = NULL;
2012   char        *attr_style = NULL;
2013
2014   jhtml = GET_JHTML(pdoc);
2015   doc   = jhtml->doc;
2016   r     = doc->r;
2017
2018   for (attr = qs_get_attr(doc,node);
2019        attr;
2020        attr = qs_get_next_attr(doc,attr)) {
2021     char *name = qs_get_attr_name(doc,attr);
2022     char *value = qs_get_attr_value(doc,attr);
2023     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2024       attr_type = value;
2025     }
2026     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2027       attr_value = value;
2028     }
2029     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2030       attr_style = value;
2031     }
2032   }
2033   if (IS_CSS_ON(jhtml->entryp)) {
2034     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2035     if (style) {
2036       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2037       css_property_t *cur;
2038       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2039         if (STRCASEEQ('d','D',"decimal", cur->value)) {
2040           attr_type = apr_pstrdup(doc->pool, "1");
2041         }
2042         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2043           attr_type = apr_pstrdup(doc->pool, "A");
2044         }
2045         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2046           attr_type = apr_pstrdup(doc->pool, "a");
2047         }
2048       }
2049     }
2050   }
2051
2052   W_L("<li");
2053   if (attr_type) {
2054     W_L(" type=\"");
2055     W_V(attr_type);
2056     W_L("\"");
2057   }
2058   if (attr_value) {
2059     W_L(" value=\"");
2060     W_V(attr_value);
2061     W_L("\"");
2062   }
2063   W_L(">");
2064   return jhtml->out;
2065 }
2066
2067
2068 /**
2069  * It is a handler who processes the li tag.
2070  *
2071  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2072  *                     destination is specified.
2073  * @param node   [i]   The li tag node is specified.
2074  * @return The conversion result is returned.
2075  */
2076 static char *
2077 s_jhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2078 {
2079   jhtml_t     *jhtml;
2080   Doc         *doc;
2081   request_rec *r;
2082
2083   jhtml = GET_JHTML(pdoc);
2084   doc   = jhtml->doc;
2085   r     = doc->r;
2086
2087   W_L("</li>");
2088   if (IS_CSS_ON(jhtml->entryp)) {
2089     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2090   }
2091   return jhtml->out;
2092 }
2093
2094
2095 /**
2096  * It is a handler who processes the OL tag.
2097  *
2098  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2099  *                     destination is specified.
2100  * @param node   [i]   The OL tag node is specified.
2101  * @return The conversion result is returned.
2102  */
2103 static char *
2104 s_jhtml_start_ol_tag(void *pdoc, Node *node)
2105 {
2106   jhtml_t     *jhtml;
2107   Doc         *doc;
2108   request_rec *r;
2109   Attr        *attr;
2110   char        *attr_style = NULL;
2111   char        *attr_start = NULL;
2112   char        *attr_type  = NULL;
2113
2114   jhtml = GET_JHTML(pdoc);
2115   doc   = jhtml->doc;
2116   r     = doc->r;
2117
2118   /*--------------------------------------------------------------------------*/
2119   /* Get Attributes                                                           */
2120   /*--------------------------------------------------------------------------*/
2121   for (attr = qs_get_attr(doc,node);
2122        attr;
2123        attr = qs_get_next_attr(doc,attr)) {
2124     char *name = qs_get_attr_name(doc,attr);
2125     char *value = qs_get_attr_value(doc,attr);
2126     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2127       attr_type = value;
2128     }
2129     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2130       attr_start = value;
2131     }
2132     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2133       attr_style = value;
2134     }
2135   }
2136   if (IS_CSS_ON(jhtml->entryp)) {
2137     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2138     if (style) {
2139       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2140       css_property_t *cur;
2141       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2142         if (STRCASEEQ('d','D',"decimal", cur->value)) {
2143           attr_type = apr_pstrdup(doc->pool, "1");
2144         }
2145         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2146           attr_type = apr_pstrdup(doc->pool, "A");
2147         }
2148         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2149           attr_type = apr_pstrdup(doc->pool, "a");
2150         }
2151       }
2152     }
2153   }
2154   W_L("<ol");
2155   if (attr_type) {
2156     W_L(" type=\"");
2157     W_V(attr_type);
2158     W_L("\"");
2159   }
2160   if (attr_start) {
2161     W_L(" start=\"");
2162     W_V(attr_start);
2163     W_L("\"");
2164   }
2165   W_L(">");
2166
2167   return jhtml->out;
2168 }
2169
2170
2171 /**
2172  * It is a handler who processes the OL tag.
2173  *
2174  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2175  *                     destination is specified.
2176  * @param node   [i]   The OL tag node is specified.
2177  * @return The conversion result is returned.
2178  */
2179 static char *
2180 s_jhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
2181 {
2182   jhtml_t     *jhtml;
2183   Doc         *doc;
2184   request_rec *r;
2185
2186   jhtml = GET_JHTML(pdoc);
2187   doc   = jhtml->doc;
2188   r     = doc->r;
2189
2190   W_L("</ol>");
2191   if (IS_CSS_ON(jhtml->entryp)) {
2192     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2193   }
2194   return jhtml->out;
2195 }
2196
2197
2198 /**
2199  * It is a handler who processes the P tag.
2200  *
2201  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2202  *                     destination is specified.
2203  * @param node   [i]   The P tag node is specified.
2204  * @return The conversion result is returned.
2205  */
2206 static char *
2207 s_jhtml_start_p_tag(void *pdoc, Node *node)
2208 {
2209   jhtml_t     *jhtml;
2210   Doc         *doc;
2211   request_rec *r;
2212   Attr        *attr;
2213   char        *attr_align = NULL;
2214   char        *attr_style = NULL;
2215   char        *attr_color = NULL;
2216   char        *attr_blink = NULL;
2217
2218
2219   jhtml = GET_JHTML(pdoc);
2220   doc   = jhtml->doc;
2221   r     = doc->r;
2222
2223   for (attr = qs_get_attr(doc,node);
2224        attr;
2225        attr = qs_get_next_attr(doc,attr)) {
2226     char *nm  = qs_get_attr_name(doc,attr);
2227     char *val = qs_get_attr_value(doc,attr);
2228     if (STRCASEEQ('a','A',"align", nm)) {
2229       /*----------------------------------------------------------------------*/
2230       /* CHTML 1.0 (W3C version 3.2)                                          */
2231       /*----------------------------------------------------------------------*/
2232       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2233         attr_align = apr_pstrdup(doc->buf.pool, val);
2234         break;
2235       }
2236     }
2237     else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2238       attr_style = apr_pstrdup(doc->buf.pool, val);
2239     }
2240   }
2241   if (IS_CSS_ON(jhtml->entryp)) {
2242     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2243     if (style) {
2244       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2245       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2246       css_property_t *text_deco_prop  = chxj_css_get_property_value(doc, style, "text-decoration");
2247       css_property_t *cur;
2248       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2249         if (STRCASEEQ('l','L',"left",cur->value)) {
2250           attr_align = apr_pstrdup(doc->pool, "left");
2251         }
2252         else if (STRCASEEQ('c','C',"center",cur->value)) {
2253           attr_align = apr_pstrdup(doc->pool, "center");
2254         }
2255         else if (STRCASEEQ('r','R',"right",cur->value)) {
2256           attr_align = apr_pstrdup(doc->pool, "right");
2257         }
2258       }
2259       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2260         if (cur->value && *cur->value) {
2261           attr_color = apr_pstrdup(doc->pool, cur->value);
2262         }
2263       }
2264       for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2265         if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2266           attr_blink = apr_pstrdup(doc->pool, cur->value);
2267         }
2268       }
2269     }
2270   }
2271   W_L("<p");
2272   if (attr_align) {
2273     W_L(" align=\"");
2274     W_V(attr_align);
2275     W_L("\"");
2276   }
2277   W_L(">");
2278
2279   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
2280   memset(flg, 0, sizeof(*flg));
2281   if (attr_color) {
2282     attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2283     W_L("<font color=\"");
2284     W_V(attr_color);
2285     W_L("\">");
2286     flg->with_font_flag = 1;
2287   }
2288   if (attr_blink) {
2289     W_L("<blink>");
2290     flg->with_blink_flag = 1;
2291   }
2292   node->userData = (void *)flg;
2293
2294   return jhtml->out;
2295 }
2296
2297
2298 /**
2299  * It is a handler who processes the P tag.
2300  *
2301  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2302  *                     destination is specified.
2303  * @param node   [i]   The P tag node is specified.
2304  * @return The conversion result is returned.
2305  */
2306 static char *
2307 s_jhtml_end_p_tag(void *pdoc, Node *node)
2308 {
2309   jhtml_t   *jhtml = GET_JHTML(pdoc);
2310   Doc       *doc   = jhtml->doc;
2311
2312   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
2313   if (flg->with_font_flag) {
2314     W_L("</font>");
2315   }
2316   if (flg->with_blink_flag) {
2317     W_L("</blink>");
2318   }
2319   W_L("</p>");
2320
2321   if (IS_CSS_ON(jhtml->entryp)) {
2322     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2323   }
2324
2325   return jhtml->out;
2326 }
2327
2328
2329 /**
2330  * It is a handler who processes the PRE tag.
2331  *
2332  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2333  *                     destination is specified.
2334  * @param node   [i]   The PRE tag node is specified.
2335  * @return The conversion result is returned.
2336  */
2337 static char *
2338 s_jhtml_start_pre_tag(void *pdoc, Node *node)
2339 {
2340   jhtml_t  *jhtml = GET_JHTML(pdoc);
2341   Doc      *doc   = jhtml->doc;
2342   Attr      *attr;
2343   char      *attr_style = NULL;
2344
2345   for (attr = qs_get_attr(doc,node);
2346        attr;
2347        attr = qs_get_next_attr(doc,attr)) {
2348     char *nm  = qs_get_attr_name(doc,attr);
2349     char *val = qs_get_attr_value(doc,attr);
2350     if (val && STRCASEEQ('s','S',"style", nm)) {
2351       attr_style = val;
2352     }
2353   }
2354
2355   if (IS_CSS_ON(jhtml->entryp)) {
2356     s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2357   }
2358
2359   jhtml->pre_flag++;
2360   W_L("<pre>");
2361   return jhtml->out;
2362 }
2363
2364
2365 /**
2366  * It is a handler who processes the PRE tag.
2367  *
2368  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2369  *                     destination is specified.
2370  * @param node   [i]   The PRE tag node is specified.
2371  * @return The conversion result is returned.
2372  */
2373 static char *
2374 s_jhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2375 {
2376   jhtml_t *jhtml = GET_JHTML(pdoc);
2377   Doc     *doc   = jhtml->doc;
2378
2379   W_L("</pre>");
2380   jhtml->pre_flag--;
2381   if (IS_CSS_ON(jhtml->entryp)) {
2382     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2383   }
2384
2385   return jhtml->out;
2386 }
2387
2388
2389 /**
2390  * It is a handler who processes the UL tag.
2391  *
2392  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2393  *                     destination is specified.
2394  * @param node   [i]   The UL tag node is specified.
2395  * @return The conversion result is returned.
2396  */
2397 static char *
2398 s_jhtml_start_ul_tag(void *pdoc, Node *node)
2399 {
2400   jhtml_t *jhtml = GET_JHTML(pdoc);
2401   Doc     *doc   = jhtml->doc;
2402   Attr        *attr;
2403   char        *attr_style = NULL;
2404
2405   for (attr = qs_get_attr(doc,node);
2406        attr;
2407        attr = qs_get_next_attr(doc,attr)) {
2408     char *nm  = qs_get_attr_name(doc,attr);
2409     char *val = qs_get_attr_value(doc,attr);
2410     if (val && STRCASEEQ('s','S',"style", nm)) {
2411       attr_style = val;
2412     }
2413   }
2414
2415   if (IS_CSS_ON(jhtml->entryp)) {
2416     s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2417   }
2418
2419   W_L("<ul>");
2420   return jhtml->out;
2421 }
2422
2423
2424 /**
2425  * It is a handler who processes the UL tag.
2426  *
2427  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2428  *                     destination is specified.
2429  * @param node   [i]   The UL tag node is specified.
2430  * @return The conversion result is returned.
2431  */
2432 static char *
2433 s_jhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
2434 {
2435   jhtml_t *jhtml = GET_JHTML(pdoc);
2436   Doc     *doc   = jhtml->doc;
2437
2438   W_L("</ul>");
2439   if (IS_CSS_ON(jhtml->entryp)) {
2440     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2441   }
2442   return jhtml->out;
2443 }
2444
2445
2446 /**
2447  * It is a handler who processes the HR tag.
2448  *
2449  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2450  *                     destination is specified.
2451  * @param node   [i]   The HR tag node is specified.
2452  * @return The conversion result is returned.
2453  */
2454 static char *
2455 s_jhtml_start_hr_tag(void *pdoc, Node *node) 
2456 {
2457   Attr        *attr;
2458   jhtml_t     *jhtml;
2459   Doc         *doc;
2460   request_rec *r;
2461   char        *attr_align   = NULL;
2462   char        *attr_size    = NULL;
2463   char        *attr_width   = NULL;
2464   char        *attr_noshade = NULL;
2465   char        *attr_style   = NULL;
2466   char        *attr_color   = NULL;
2467
2468   jhtml   = GET_JHTML(pdoc);
2469   doc     = jhtml->doc;
2470   r       = doc->r;
2471
2472   for (attr = qs_get_attr(doc,node);
2473        attr; 
2474        attr = qs_get_next_attr(doc,attr)) {
2475     char *name  = qs_get_attr_name (doc,attr);
2476     char *value = qs_get_attr_value(doc,attr);
2477     switch(*name) {
2478     case 'a':
2479     case 'A':
2480       if (strcasecmp(name, "align") == 0) {
2481         /*--------------------------------------------------------------------*/
2482         /* CHTML 1.0                                                          */
2483         /*--------------------------------------------------------------------*/
2484         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2485           attr_align = value;
2486         }
2487       }
2488       break;
2489
2490     case 's':
2491     case 'S':
2492       if (strcasecmp(name, "size") == 0) {
2493         /*--------------------------------------------------------------------*/
2494         /* CHTML 1.0                                                          */
2495         /*--------------------------------------------------------------------*/
2496         if (value && *value) {
2497           attr_size = value;
2498         }
2499       }
2500       else if (strcasecmp(name, "style") == 0) {
2501         if (value && *value) {
2502           attr_style = value;
2503         }
2504       }
2505       break;
2506
2507     case 'w':
2508     case 'W':
2509       if (strcasecmp(name, "width") == 0) {
2510         /*--------------------------------------------------------------------*/
2511         /* CHTML 1.0                                                          */
2512         /*--------------------------------------------------------------------*/
2513         if (value && *value) {
2514           attr_width = value;
2515         }
2516       }
2517       break;
2518
2519     case 'n':
2520     case 'N':
2521       if (strcasecmp(name, "noshade") == 0) {
2522         /*--------------------------------------------------------------------*/
2523         /* CHTML 1.0                                                          */
2524         /*--------------------------------------------------------------------*/
2525         attr_noshade = apr_pstrdup(doc->pool, "noshade");
2526       }
2527       break;
2528
2529     case 'c':
2530     case 'C':
2531       if (strcasecmp(name, "color") == 0 && value && *value) {
2532         /*--------------------------------------------------------------------*/
2533         /* CHTML 4.0                                                          */
2534         /*--------------------------------------------------------------------*/
2535         attr_color = value;
2536       }
2537       break;
2538
2539     default:
2540       break;
2541     }
2542   }
2543   if (IS_CSS_ON(jhtml->entryp)) {
2544     css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
2545     if (style) {
2546       css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2547       css_property_t *height_prop       = chxj_css_get_property_value(doc, style, "height");
2548       css_property_t *width_prop        = chxj_css_get_property_value(doc, style, "width");
2549       css_property_t *cur;
2550       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2551         if (STRCASEEQ('s','S',"solid",cur->value)) {
2552           attr_noshade = "noshade";
2553         }
2554       }
2555       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2556         char *tmp = apr_pstrdup(doc->pool, cur->value);
2557         char *tmpp = strstr(tmp, "px");
2558         if (tmpp) { 
2559           *tmpp = 0;
2560           attr_size = apr_pstrdup(doc->pool, tmp);
2561         }
2562       }
2563       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2564         char *tmp = apr_pstrdup(doc->pool, cur->value);
2565         char *tmpp = strstr(tmp, "px");
2566         if (tmpp) {
2567           *tmpp = 0;
2568           attr_width = apr_pstrdup(doc->pool, tmp);
2569         }
2570         else {
2571           tmpp = strstr(tmp, "%");
2572           if (tmpp) {
2573             attr_width = apr_pstrdup(doc->pool, tmp);
2574           }
2575         }
2576       }
2577     }
2578   }
2579   W_L("<hr");
2580   if (attr_align) {
2581     W_L(" align=\"");
2582     W_V(attr_align);
2583     W_L("\"");
2584   }
2585   if (attr_size) {
2586     W_L(" size=\"");
2587     W_V(attr_size);
2588     W_L("\"");
2589   }
2590   if (attr_width) {
2591     W_L(" width=\"");
2592     W_V(attr_width);
2593     W_L("\"");
2594   }
2595   if (attr_color) {
2596     W_L(" color=\"");
2597     W_V(attr_color);
2598     W_L("\"");
2599   }
2600   if (attr_noshade) {
2601     W_L(" noshade");
2602   }
2603   W_L(">");
2604   return jhtml->out;
2605 }
2606
2607
2608 /**
2609  * It is a handler who processes the HR tag.
2610  *
2611  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
2612  *                     destination is specified.
2613  * @param node   [i]   The HR tag node is specified.
2614  * @return The conversion result is returned.
2615  */
2616 static char *
2617 s_jhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2618 {
2619   jhtml_t *jhtml = GET_JHTML(pdoc);
2620   return jhtml->out;
2621 }
2622
2623
2624 /**
2625  * It is a handler who processes the IMG tag.
2626  *
2627  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2628  *                     destination is specified.
2629  * @param node   [i]   The IMG tag node is specified.
2630  * @return The conversion result is returned.
2631  */
2632 static char *
2633 s_jhtml_start_img_tag(void *pdoc, Node *node) 
2634 {
2635   jhtml_t     *jhtml;
2636   Doc         *doc;
2637   request_rec *r;
2638   Attr        *attr;
2639   char        *attr_src    = NULL;
2640   char        *attr_align  = NULL;
2641   char        *attr_style  = NULL;
2642   char        *attr_alt    = NULL;
2643   char        *attr_width  = NULL;
2644   char        *attr_height = NULL;
2645 #ifndef IMG_NOT_CONVERT_FILENAME
2646   device_table *spec;
2647 #endif
2648
2649   jhtml = GET_JHTML(pdoc);
2650 #ifndef IMG_NOT_CONVERT_FILENAME
2651   spec    = jhtml->spec;
2652 #endif
2653   doc     = jhtml->doc;
2654   r       = doc->r;
2655
2656   /*--------------------------------------------------------------------------*/
2657   /* Get Attributes                                                           */
2658   /*--------------------------------------------------------------------------*/
2659   for (attr = qs_get_attr(doc,node);
2660        attr;
2661        attr = qs_get_next_attr(doc,attr)) {
2662     char *name  = qs_get_attr_name (doc,attr);
2663     char *value = qs_get_attr_value(doc,attr);
2664     switch(*name) {
2665     case 's':
2666     case 'S':
2667       if (strcasecmp(name, "src") == 0) {
2668         /*--------------------------------------------------------------------*/
2669         /* CHTML 1.0                                                          */
2670         /*--------------------------------------------------------------------*/
2671 #ifdef IMG_NOT_CONVERT_FILENAME
2672       value = chxj_encoding_parameter(r, value, 0);
2673       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jhtml->entryp, 0);
2674       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
2675       value = chxj_add_cookie_no_update_parameter(r, value);
2676       attr_src = value;
2677 #else
2678       value = chxj_img_conv(r, spec, value);
2679       value = chxj_encoding_parameter(r, value, 0);
2680       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jhtml->entryp, 0);
2681       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
2682       value = chxj_add_cookie_no_update_parameter(r, value);
2683       attr_src = value;
2684 #endif
2685       }
2686       else if (strcasecmp(name,"style") == 0 && value && *value) {
2687         attr_style = value;
2688       }
2689       break;
2690
2691     case 'a':
2692     case 'A':
2693       if (strcasecmp(name, "align" ) == 0) {
2694         /*--------------------------------------------------------------------*/
2695         /* CHTML 1.0                                                          */
2696         /*--------------------------------------------------------------------*/
2697         /*--------------------------------------------------------------------*/
2698         /* CHTML 4.0                                                          */
2699         /*--------------------------------------------------------------------*/
2700         if (value) {
2701           if (STRCASEEQ('t','T',"top",   value) ||
2702               STRCASEEQ('m','M',"middle",value) ||
2703               STRCASEEQ('b','B',"bottom",value) ||
2704               STRCASEEQ('l','L',"left",  value) ||
2705               STRCASEEQ('r','R',"right", value)) {
2706             attr_align = value;
2707           }
2708           else if (STRCASEEQ('c','C',"center",  value)) {
2709             attr_align = apr_pstrdup(doc->pool, "middle");
2710           }
2711         }
2712       }
2713       else if (strcasecmp(name, "alt"   ) == 0 && value && *value) {
2714         /*--------------------------------------------------------------------*/
2715         /* CHTML 1.0                                                          */
2716         /*--------------------------------------------------------------------*/
2717         attr_alt = value;
2718       }
2719       break;
2720
2721     case 'w':
2722     case 'W':
2723       if (strcasecmp(name, "width" ) == 0 && value && *value) {
2724         /*--------------------------------------------------------------------*/
2725         /* CHTML 1.0                                                          */
2726         /*--------------------------------------------------------------------*/
2727         attr_width = value;
2728       }
2729       break;
2730
2731     case 'h':
2732     case 'H':
2733       if (strcasecmp(name, "height") == 0 && value && *value) {
2734         /*--------------------------------------------------------------------*/
2735         /* CHTML 1.0                                                          */
2736         /*--------------------------------------------------------------------*/
2737         attr_height = value;
2738       }
2739       else
2740       if (strcasecmp(name, "hspace") == 0 && value && *value) {
2741         /*--------------------------------------------------------------------*/
2742         /* CHTML 1.0                                                          */
2743         /*--------------------------------------------------------------------*/
2744       }
2745       break;
2746
2747     case 'v':
2748     case 'V':
2749       if (strcasecmp(name, "vspace") == 0 && value && *value) {
2750         /*--------------------------------------------------------------------*/
2751         /* CHTML 1.0                                                          */
2752         /*--------------------------------------------------------------------*/
2753       }
2754       break;
2755
2756     default:
2757       break;
2758     }
2759   }
2760
2761   if (IS_CSS_ON(jhtml->entryp)) {
2762     css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
2763     if (style) {
2764       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2765       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
2766       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
2767       css_property_t *cur;
2768       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2769         attr_height = apr_pstrdup(doc->pool, cur->value);
2770       }
2771       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2772         attr_width = apr_pstrdup(doc->pool, cur->value);
2773       }
2774       for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
2775         attr_align = apr_pstrdup(doc->pool, cur->value);
2776       }
2777     }
2778   }
2779
2780   W_L("<img");
2781   if (attr_src) {
2782     W_L(" src=\"");
2783     W_V(attr_src);
2784     W_L("\"");
2785   }
2786   if (attr_align) {
2787     W_L(" align=\"");
2788     W_V(attr_align);
2789     W_L("\"");
2790   }
2791   if (attr_alt) {
2792     W_L(" alt=\"");
2793     W_V(attr_alt);
2794     W_L("\"");
2795   }
2796   if (attr_width) {
2797     W_L(" width=\"");
2798     W_V(attr_width);
2799     W_L("\"");
2800   }
2801   if (attr_height) {
2802     W_L(" height=\"");
2803     W_V(attr_height);
2804     W_L("\"");
2805   }
2806   W_L(">");
2807   return jhtml->out;
2808 }
2809
2810
2811 /**
2812  * It is a handler who processes the IMG tag.
2813  *
2814  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2815  *                     destination is specified.
2816  * @param node   [i]   The IMG tag node is specified.
2817  * @return The conversion result is returned.
2818  */
2819 static char *
2820 s_jhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2821 {
2822   jhtml_t *jhtml = GET_JHTML(pdoc);
2823   return jhtml->out;
2824 }
2825
2826
2827 /**
2828  * It is a handler who processes the SELECT tag.
2829  *
2830  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2831  *                     destination is specified.
2832  * @param node   [i]   The SELECT tag node is specified.
2833  * @return The conversion result is returned.
2834  */
2835 static char *
2836 s_jhtml_start_select_tag(void *pdoc, Node *node)
2837 {
2838   jhtml_t *jhtml    = GET_JHTML(pdoc);
2839   Doc     *doc      = jhtml->doc;
2840   Attr    *attr;
2841   char    *size     = NULL;
2842   char    *name     = NULL;
2843   char    *multiple = NULL;
2844   char    *attr_style = NULL;
2845
2846   W_L("<select");
2847   for (attr = qs_get_attr(doc,node);
2848        attr;
2849        attr = qs_get_next_attr(doc,attr)) {
2850     char *nm  = qs_get_attr_name(doc,attr);
2851     char *val = qs_get_attr_value(doc,attr);
2852     if (STRCASEEQ('s','S',"size",nm)) {
2853       /*----------------------------------------------------------------------*/
2854       /* CHTML 1.0 version 2.0                                                */
2855       /*----------------------------------------------------------------------*/
2856       size = apr_pstrdup(doc->buf.pool, val);
2857     }
2858     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
2859       /*----------------------------------------------------------------------*/
2860       /* CHTML 1.0 version 2.0                                                */
2861       /*----------------------------------------------------------------------*/
2862       attr_style = apr_pstrdup(doc->buf.pool, val);
2863     }
2864     else if (STRCASEEQ('n','N',"name",nm)) {
2865       /*----------------------------------------------------------------------*/
2866       /* CHTML 1.0 version 2.0                                                */
2867       /*----------------------------------------------------------------------*/
2868       name = apr_pstrdup(doc->buf.pool, val);
2869     }
2870     else if (STRCASEEQ('m','M',"multiple", nm)) {
2871       /*----------------------------------------------------------------------*/
2872       /* CHTML 1.0 version 2.0                                                */
2873       /*----------------------------------------------------------------------*/
2874       multiple = apr_pstrdup(doc->buf.pool, val);
2875     }
2876   }
2877   if (size && *size) {
2878     W_L(" size=\"");
2879     W_V(size);
2880     W_L("\"");
2881   }
2882   if (name && *name) {
2883     W_L(" name=\"");
2884     W_V(name);
2885     W_L("\"");
2886   }
2887   if (multiple) {
2888     W_L(" multiple");
2889   }
2890   W_L(">");
2891   if (IS_CSS_ON(jhtml->entryp)) {
2892     s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2893   }
2894   return jhtml->out;
2895 }
2896
2897
2898 /**
2899  * It is a handler who processes the SELECT tag.
2900  *
2901  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2902  *                     destination is specified.
2903  * @param node   [i]   The SELECT tag node is specified.
2904  * @return The conversion result is returned.
2905  */
2906 static char *
2907 s_jhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
2908 {
2909   jhtml_t *jhtml = GET_JHTML(pdoc);
2910   Doc     *doc   = jhtml->doc;
2911
2912   W_L("</select>");
2913   if (IS_CSS_ON(jhtml->entryp)) {
2914     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2915   }
2916   return jhtml->out;
2917 }
2918
2919 /**
2920  * It is a handler who processes the OPTION tag.
2921  *
2922  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2923  *                     destination is specified.
2924  * @param node   [i]   The OPTION tag node is specified.
2925  * @return The conversion result is returned.
2926  */
2927 static char *
2928 s_jhtml_start_option_tag(void *pdoc, Node *node)
2929 {
2930   jhtml_t *jhtml = GET_JHTML(pdoc);
2931   Doc     *doc   = jhtml->doc;
2932   Attr    *attr;
2933
2934   char *selected   = NULL;
2935   char *value      = NULL;
2936   char *attr_style = NULL;
2937
2938   W_L("<option");
2939   for (attr = qs_get_attr(doc,node);
2940        attr;
2941        attr = qs_get_next_attr(doc,attr)) {
2942     char *nm  = qs_get_attr_name(doc,attr);
2943     char *val = qs_get_attr_value(doc,attr);
2944     if (STRCASEEQ('s','S',"selected",nm)) {
2945       /*----------------------------------------------------------------------*/
2946       /* CHTML 1.0 version 2.0                                                */
2947       /*----------------------------------------------------------------------*/
2948       selected = apr_pstrdup(doc->buf.pool, val);
2949     }
2950     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
2951       /*----------------------------------------------------------------------*/
2952       /* CHTML 1.0 version 2.0                                                */
2953       /*----------------------------------------------------------------------*/
2954       attr_style = apr_pstrdup(doc->buf.pool, val);
2955     }
2956     else if (STRCASEEQ('v','V',"value",nm)) {
2957       /*----------------------------------------------------------------------*/
2958       /* CHTML 1.0 version 2.0                                                */
2959       /*----------------------------------------------------------------------*/
2960       value = apr_pstrdup(doc->buf.pool, val);
2961     }
2962   }
2963   if (value) {
2964     W_L(" value=\"");
2965     W_V(value);
2966     W_L("\"");
2967   }
2968   if (selected) {
2969     W_L(" selected");
2970   }
2971   W_L(">");
2972
2973   if (IS_CSS_ON(jhtml->entryp)) {
2974     s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
2975   }
2976
2977   return jhtml->out;
2978 }
2979
2980
2981 /**
2982  * It is a handler who processes the OPTION tag.
2983  *
2984  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2985  *                     destination is specified.
2986  * @param node   [i]   The OPTION tag node is specified.
2987  * @return The conversion result is returned.
2988  */
2989 static char *
2990 s_jhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
2991 {
2992   jhtml_t *jhtml = GET_JHTML(pdoc);
2993   /* Don't close */
2994   if (IS_CSS_ON(jhtml->entryp)) {
2995     chxj_css_pop_prop_list(jhtml->css_prop_stack);
2996   }
2997   return jhtml->out;
2998 }
2999
3000
3001 /**
3002  * It is a handler who processes the DIV tag.
3003  *
3004  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3005  *                     destination is specified.
3006  * @param node   [i]   The DIV tag node is specified.
3007  * @return The conversion result is returned.
3008  */
3009 static char *
3010 s_jhtml_start_div_tag(void *pdoc, Node *node)
3011 {
3012   jhtml_t     *jhtml;
3013   Doc         *doc;
3014   request_rec *r;
3015   Attr        *attr;
3016   char        *attr_style             = NULL;
3017   char        *attr_align             = NULL;
3018   char        *attr_display           = NULL;
3019   char        *attr_decoration        = NULL;
3020   char        *attr_wap_marquee_style = NULL;
3021   char        *attr_wap_marquee_dir   = NULL;
3022   char        *attr_wap_marquee_loop  = NULL;
3023   char        *attr_color             = NULL;
3024   char        *attr_bgcolor           = NULL;
3025   char        *attr_font_size         = NULL;
3026
3027   jhtml = GET_JHTML(pdoc);
3028   doc     = jhtml->doc;
3029   r       = doc->r;
3030
3031   for (attr = qs_get_attr(doc,node);
3032        attr;
3033        attr = qs_get_next_attr(doc,attr)) {
3034     char *nm  = qs_get_attr_name(doc,attr);
3035     char *val = qs_get_attr_value(doc,attr);
3036     if (STRCASEEQ('a','A', "align", nm)) {
3037       /*----------------------------------------------------------------------*/
3038       /* CHTML 1.0 (W3C version 3.2)                                          */
3039       /*----------------------------------------------------------------------*/
3040       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3041         attr_align = apr_pstrdup(doc->buf.pool, val);
3042       }
3043     }
3044     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3045       attr_style = apr_pstrdup(doc->buf.pool, val);
3046     }
3047   }
3048
3049   if (IS_CSS_ON(jhtml->entryp)) {
3050     css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3051     if (style) {
3052       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
3053       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
3054       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
3055       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
3056       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
3057       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
3058       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
3059
3060       css_property_t *cur;
3061       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3062         if (strcasecmp("-wap-marquee", cur->value) == 0) {
3063           attr_display = apr_pstrdup(doc->pool, cur->value);
3064         }
3065       }
3066       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
3067         if (STRCASEEQ('b','B',"blink", cur->value)) {
3068           attr_decoration = apr_pstrdup(doc->pool, cur->value);
3069         }
3070       }
3071       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
3072         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3073         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3074       }
3075       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
3076         char *ss = strchr(cur->value, '#');
3077         if (!ss || !*ss) {
3078           ss = strstr(cur->value, "rgb");
3079         }
3080         if (ss && *ss) {
3081           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3082           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3083         }
3084       }
3085       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3086         attr_color = apr_pstrdup(doc->pool, cur->value);
3087       }
3088       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3089         attr_align = apr_pstrdup(doc->pool, cur->value);
3090       }
3091       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3092         attr_font_size = apr_pstrdup(doc->pool, cur->value);
3093         if (STRCASEEQ('x','X',"xx-small",attr_font_size)) {
3094           attr_font_size = apr_pstrdup(doc->pool, "1");
3095         }
3096         else if (STRCASEEQ('x','X',"x-small",attr_font_size)) {
3097           attr_font_size = apr_pstrdup(doc->pool, "2");
3098         }
3099         else if (STRCASEEQ('s','S',"small",attr_font_size)) {
3100           attr_font_size = apr_pstrdup(doc->pool, "3");
3101         }
3102         else if (STRCASEEQ('m','M',"medium",attr_font_size)) {
3103           attr_font_size = apr_pstrdup(doc->pool, "4");
3104         }
3105         else if (STRCASEEQ('l','L',"large",attr_font_size)) {
3106           attr_font_size = apr_pstrdup(doc->pool, "5");
3107         }
3108         else if (STRCASEEQ('x','X',"x-large",attr_font_size)) {
3109           attr_font_size = apr_pstrdup(doc->pool, "6");
3110         }
3111         else if (STRCASEEQ('x','X',"xx-large",attr_font_size)) {
3112           attr_font_size = apr_pstrdup(doc->pool, "7");
3113         }
3114       }
3115       if (attr_display) {
3116         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
3117         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
3118         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
3119         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
3120           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
3121             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
3122           }
3123         }
3124         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
3125           if (STRCASEEQ('l','L',"ltr",cur->value)) {
3126             attr_wap_marquee_dir = apr_pstrdup(doc->pool, "right");
3127           }
3128           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
3129             attr_wap_marquee_dir = apr_pstrdup(doc->pool, "left");
3130           }
3131         }
3132         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
3133           if (STRCASEEQ('i','I',"infinite",cur->value)) {
3134             attr_wap_marquee_loop = apr_pstrdup(doc->pool, "16");
3135           }
3136           else {
3137             attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
3138           }
3139         }
3140       }
3141     }
3142   }  
3143   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
3144   memset(flg, 0, sizeof(*flg));
3145   if (attr_align) {
3146     W_L("<div");
3147     W_L(" align=\"");
3148     W_V(attr_align);
3149     W_L("\"");
3150     W_L(">");
3151     flg->with_div_flag = 1;
3152   }
3153   if ((attr_color
3154       && ! ((STRCASEEQ('w','W',"white",attr_color) || STRCASEEQ('#','#',"#ffffff",attr_color)) && attr_bgcolor))
3155       || attr_font_size) {
3156     W_L("<font");
3157     if (attr_color) {
3158       W_L(" color=\"");
3159       W_V(attr_color);
3160       W_L("\"");
3161     }
3162     if (attr_font_size) {
3163       W_L(" size=\"");
3164       W_V(attr_font_size);
3165       W_L("\"");
3166     }
3167     W_L(">");
3168     flg->with_font_flag = 1;
3169   }
3170   if (attr_decoration) {
3171     W_L("<blink>");
3172     flg->with_blink_flag = 1;
3173   }
3174   if (attr_display) {
3175     W_L("<marquee");
3176     if (attr_wap_marquee_style) {
3177       W_L(" behavior=\"");
3178       W_V(attr_wap_marquee_style);
3179       W_L("\"");
3180     }
3181     if (attr_wap_marquee_dir) {
3182       W_L(" direction=\"");
3183       W_V(attr_wap_marquee_dir);
3184       W_L("\"");
3185     }
3186     if (attr_wap_marquee_loop) {
3187       W_L(" loop=\"");
3188       W_V(attr_wap_marquee_loop);
3189       W_L("\"");
3190     }
3191     W_L(">");
3192     flg->with_marquee_flag = 1;
3193   }
3194   if (!attr_align && !attr_color && !attr_decoration && !attr_display && !attr_font_size) {
3195     W_L("<div>");
3196     flg->with_div_flag = 1;
3197   }
3198   node->userData = flg;
3199
3200   return jhtml->out;
3201 }
3202
3203
3204 /**
3205  * It is a handler who processes the DIV tag.
3206  *
3207  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3208  *                     destination is specified.
3209  * @param node   [i]   The DIV tag node is specified.
3210  * @return The conversion result is returned.
3211  */
3212 static char *
3213 s_jhtml_end_div_tag(void *pdoc, Node *node)
3214 {
3215   jhtml_t    *jhtml = GET_JHTML(pdoc);
3216   Doc          *doc = jhtml->doc;
3217
3218   jhtml_flags_t *flg = node->userData;
3219   if (flg && flg->with_marquee_flag) {
3220     W_L("</marquee>");
3221   }
3222   if (flg && flg->with_blink_flag) {
3223     W_L("</blink>");
3224   }
3225   if (flg && flg->with_font_flag) {
3226     W_L("</font>");
3227   }
3228   if (flg && flg->with_div_flag) {
3229     W_L("</div>");
3230   }
3231   if (IS_CSS_ON(jhtml->entryp)) {
3232     chxj_css_pop_prop_list(jhtml->css_prop_stack);
3233   }
3234   node->userData = NULL;
3235
3236   return jhtml->out;
3237 }
3238
3239
3240 static char *
3241 chxj_istyle_to_mode(apr_pool_t *p, const char *s)
3242 {
3243   char *tmp;
3244
3245   if (s) {
3246     switch (s[0]) {
3247     case '1': return apr_psprintf(p, "hiragana");
3248     case '2': return apr_psprintf(p, "hankakukana");
3249     case '3': return apr_psprintf(p, "alphabet");
3250     case '4': return apr_psprintf(p, "numeric");
3251     default: 
3252       tmp = apr_palloc(p, 1);
3253       tmp[0] = '\0';
3254       return apr_pstrdup(p, tmp);
3255     }
3256   }
3257
3258   tmp = apr_palloc(p, 1);
3259   tmp[0] = '\0';
3260   return apr_pstrdup(p,tmp);
3261 }
3262
3263
3264 static char *
3265 s_jhtml_chxjif_tag(void *pdoc, Node *node)
3266 {
3267   jhtml_t *jhtml;
3268   Doc     *doc;
3269   Node    *child;
3270   request_rec *r;
3271
3272   jhtml = GET_JHTML(pdoc);
3273   doc   = jhtml->doc;
3274   r     = doc->r;
3275
3276   for (child = qs_get_child_node(doc, node);
3277        child;
3278        child = qs_get_next_node(doc, child)) {
3279     W_V(child->otext);
3280     s_jhtml_chxjif_tag(jhtml, child);
3281   }
3282   return NULL;
3283 }
3284
3285
3286 /**
3287  * It is a handler who processes the TEXTARE tag.
3288  *
3289  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3290  *                     destination is specified.
3291  * @param node   [i]   The TEXTAREA tag node is specified.
3292  * @return The conversion result is returned.
3293  */
3294 static char *
3295 s_jhtml_start_textarea_tag(void *pdoc, Node *node) 
3296 {
3297   jhtml_t       *jhtml;
3298   Doc           *doc;
3299   request_rec   *r;
3300   Attr          *attr;
3301   char          *attr_accesskey = NULL;
3302   char          *attr_name      = NULL;
3303   char          *attr_rows      = NULL;
3304   char          *attr_cols      = NULL;
3305   char          *attr_istyle    = NULL;
3306   char          *attr_style     = NULL;
3307
3308   jhtml = GET_JHTML(pdoc);
3309   doc   = jhtml->doc;
3310   r     = doc->r;
3311
3312   jhtml->textarea_flag++;
3313   for (attr = qs_get_attr(doc,node);
3314        attr;
3315        attr = qs_get_next_attr(doc,attr)) {
3316     char *name  = qs_get_attr_name(doc,attr);
3317     char *value = qs_get_attr_value(doc,attr);
3318     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3319       attr_accesskey = value;
3320     }
3321     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3322       attr_istyle = value;
3323     }
3324     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3325       attr_name = value;
3326     }
3327     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3328       attr_rows = value;
3329     }
3330     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3331       attr_cols = value;
3332     }
3333     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3334       attr_style = value;
3335     }
3336   }
3337   if (IS_CSS_ON(jhtml->entryp)) {
3338     css_prop_list_t *style = s_jhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3339     if (style) {
3340       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3341       css_property_t *cur;
3342       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3343         if (strcasestr(cur->value, "<ja:n>")) {
3344           attr_istyle = "4";
3345         }
3346         else if (strcasestr(cur->value, "<ja:en>")) {
3347           attr_istyle = "3";
3348         }
3349         else if (strcasestr(cur->value, "<ja:hk>")) {
3350           attr_istyle = "2";
3351         }
3352         else if (strcasestr(cur->value, "<ja:h>")) {
3353           attr_istyle = "1";
3354         }
3355       }
3356     }
3357   }
3358   W_L("<textarea");
3359   if (attr_accesskey) {
3360     W_L(" accesskey=\"");
3361     W_V(attr_accesskey);
3362     W_L("\"");
3363   }
3364   if (attr_name) {
3365     W_L(" name=\"");
3366     W_V(attr_name);
3367     W_L("\"");
3368   }
3369   if (attr_rows) {
3370     W_L(" rows=\"");
3371     W_V(attr_rows);
3372     W_L("\"");
3373   }
3374   if (attr_cols) {
3375     W_L(" cols=\"");
3376     W_V(attr_cols);
3377     W_L("\"");
3378   }
3379   if (attr_istyle) {
3380     char *vv = chxj_istyle_to_mode(doc->buf.pool,attr_istyle);
3381     W_L(" mode=\"");
3382     W_V(vv);
3383     W_L("\"");
3384   }
3385   W_L(">");
3386   return jhtml->out;
3387 }
3388
3389
3390 /**
3391  * It is a handler who processes the TEXTAREA tag.
3392  *
3393  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3394  *                     destination is specified.
3395  * @param node   [i]   The TEXTAREA tag node is specified.
3396  * @return The conversion result is returned.
3397  */
3398 static char *
3399 s_jhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3400 {
3401   jhtml_t       *jhtml;
3402   Doc           *doc;
3403   request_rec   *r;
3404
3405   jhtml = GET_JHTML(pdoc);
3406   doc   = jhtml->doc;
3407   r     = doc->r;
3408
3409   W_L("</textarea>");
3410   jhtml->textarea_flag--;
3411
3412   return jhtml->out;
3413 }
3414
3415
3416 /**
3417  * It is a handler who processes the B tag.
3418  *
3419  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3420  *                     destination is specified.
3421  * @param node   [i]   The B tag node is specified.
3422  * @return The conversion result is returned.
3423  */
3424 static char*
3425 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
3426 {
3427   jhtml_t*      jhtml;
3428   Doc*          doc;
3429   request_rec*  r;
3430
3431   jhtml = GET_JHTML(pdoc);
3432   doc   = jhtml->doc;
3433   r     = doc->r;
3434
3435   W_L("<b>");
3436   return jhtml->out;
3437 }
3438
3439
3440 /**
3441  * It is a handler who processes the B tag.
3442  *
3443  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
3444  *                     destination is specified.
3445  * @param node   [i]   The B tag node is specified.
3446  * @return The conversion result is returned.
3447  */
3448 static char*
3449 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
3450 {
3451   jhtml_t*      jhtml = GET_JHTML(pdoc);
3452   Doc*          doc   = jhtml->doc;
3453
3454   W_L("</b>");
3455   return jhtml->out;
3456 }
3457
3458 static char*
3459 s_jhtml_text_tag(void* pdoc, Node* child)
3460 {
3461   jhtml_t*     jhtml;
3462   Doc*         doc;
3463   char*        textval;
3464   char*        tmp;
3465   char*        tdst;
3466   char         one_byte[2];
3467   int          ii;
3468   int          tdst_len;
3469   request_rec* r;
3470
3471   jhtml = GET_JHTML(pdoc);
3472   doc   = jhtml->doc;
3473   r     = doc->r;
3474   DBG(r, "start s_jhtml_text_tag()");
3475
3476   textval = qs_get_node_value(doc,child);
3477   if (strlen(textval) == 0) {
3478     return jhtml->out;
3479   }
3480
3481   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3482   memset(tmp, 0, qs_get_node_size(doc,child)+1);
3483
3484   tdst     = qs_alloc_zero_byte_string(r->pool);
3485   memset(one_byte, 0, sizeof(one_byte));
3486   tdst_len = 0;
3487
3488   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3489     char* out;
3490     int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
3491     if (rtn) {
3492       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3493       ii+=(rtn - 1);
3494       continue;
3495     }
3496
3497     if (is_sjis_kanji(textval[ii])) {
3498       one_byte[0] = textval[ii+0];
3499       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3500       one_byte[0] = textval[ii+1];
3501       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3502       ii++;
3503     }
3504     else 
3505     if (jhtml->pre_flag) {
3506       one_byte[0] = textval[ii+0];
3507       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3508     }
3509     else
3510     if (jhtml->textarea_flag) {
3511       one_byte[0] = textval[ii+0];
3512       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3513     }
3514     else {
3515       if (textval[ii] != '\r' && textval[ii] != '\n') {
3516         one_byte[0] = textval[ii+0];
3517         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3518       }
3519     }
3520   }
3521   W_V(tdst);
3522   DBG(r, "end s_jhtml_text_tag()");
3523   return jhtml->out;
3524 }
3525
3526
3527 /**
3528  * It is a handler who processes the BLOCKQUOTE tag.
3529  *
3530  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3531  *                     destination is specified.
3532  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3533  * @return The conversion result is returned.
3534  */
3535 static char *
3536 s_jhtml_start_blockquote_tag(void *pdoc, Node *node)
3537 {
3538   jhtml_t *jhtml;
3539   Doc     *doc;
3540   Attr    *attr;
3541   char    *attr_style = NULL;
3542   char    *attr_color = NULL;
3543   char    *attr_size  = NULL;
3544
3545   jhtml   = GET_JHTML(pdoc);
3546   doc     = jhtml->doc;
3547   for (attr = qs_get_attr(doc,node);
3548        attr;
3549        attr = qs_get_next_attr(doc,attr)) {
3550     char *nm  = qs_get_attr_name(doc,attr);
3551     char *val = qs_get_attr_value(doc,attr);
3552     if (val && STRCASEEQ('s','S',"style", nm)) {
3553       attr_style = val;
3554     }
3555   }
3556   if (IS_CSS_ON(jhtml->entryp)) {
3557     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
3558     if (style) {
3559       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
3560       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
3561       css_property_t *cur;
3562       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3563         if (cur->value && *cur->value) {
3564           attr_color = apr_pstrdup(doc->pool, cur->value);
3565         }
3566       }
3567       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3568         if (cur->value && *cur->value) {
3569           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
3570             attr_size = apr_pstrdup(doc->pool, "1");
3571           }
3572           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
3573             attr_size = apr_pstrdup(doc->pool, "2");
3574           }
3575           else if (STRCASEEQ('s','S',"small",cur->value)) {
3576             attr_size = apr_pstrdup(doc->pool, "3");
3577           }
3578           else if (STRCASEEQ('m','M',"medium",cur->value)) {
3579             attr_size = apr_pstrdup(doc->pool, "4");
3580           }
3581           else if (STRCASEEQ('l','L',"large",cur->value)) {
3582             attr_size = apr_pstrdup(doc->pool, "5");
3583           }
3584           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
3585             attr_size = apr_pstrdup(doc->pool, "6");
3586           }
3587           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
3588             attr_size = apr_pstrdup(doc->pool, "7");
3589           }
3590         }
3591       }
3592     }
3593   }
3594   W_L("<blockquote>");
3595   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
3596   memset(flg, 0, sizeof(*flg));
3597   if (attr_color || attr_size) {
3598     W_L("<font");
3599     if (attr_color) {
3600       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3601       W_L(" color=\"");
3602       W_V(attr_color);
3603       W_L("\"");
3604     }
3605     if (attr_size) {
3606       W_L(" size=\"");
3607       W_V(attr_size);
3608       W_L("\"");
3609     }
3610     W_L(">");
3611     flg->with_font_flag = 1;
3612   }
3613   node->userData = (void *)flg;
3614   return jhtml->out;
3615 }
3616
3617
3618 /**
3619  * It is a handler who processes the BLOCKQUOTE tag.
3620  *
3621  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3622  *                     destination is specified.
3623  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3624  * @return The conversion result is returned.
3625  */
3626 static char *
3627 s_jhtml_end_blockquote_tag(void *pdoc, Node *node)
3628 {
3629   jhtml_t *jhtml = GET_JHTML(pdoc);
3630   Doc     *doc     = jhtml->doc;
3631   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
3632   if (flg && flg->with_font_flag) {
3633     W_L("</font>");
3634   }
3635   W_L("</blockquote>");
3636   if (IS_CSS_ON(jhtml->entryp)) {
3637     chxj_css_pop_prop_list(jhtml->css_prop_stack);
3638   }
3639   return jhtml->out;
3640 }
3641
3642
3643 /**
3644  * It is a handler who processes the DIR tag.
3645  *
3646  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3647  *                     destination is specified.
3648  * @param node   [i]   The DIR tag node is specified.
3649  * @return The conversion result is returned.
3650  */
3651 static char *
3652 s_jhtml_start_dir_tag(void *pdoc, Node *node)
3653 {
3654   jhtml_t *jhtml = GET_JHTML(pdoc);
3655   Doc     *doc     = jhtml->doc;
3656   Attr    *attr;
3657   char    *attr_style = NULL;
3658   char    *attr_color = NULL;
3659   char    *attr_size  = NULL;
3660   for (attr = qs_get_attr(doc,node);
3661        attr;
3662        attr = qs_get_next_attr(doc,attr)) {
3663     char *name   = qs_get_attr_name(doc,attr);
3664     char *value  = qs_get_attr_value(doc,attr);
3665     if (STRCASEEQ('s','S',"style", name) && value && *value) {
3666       attr_style = value;
3667     }
3668   }
3669   if (IS_CSS_ON(jhtml->entryp)) {
3670     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
3671     if (style) {
3672       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
3673       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
3674       css_property_t *cur;
3675       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3676         if (cur->value && *cur->value) {
3677           attr_color = apr_pstrdup(doc->pool, cur->value);
3678         }
3679       }
3680       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
3681         if (cur->value && *cur->value) {
3682           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
3683             attr_size = apr_pstrdup(doc->pool, "1");
3684           }
3685           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
3686             attr_size = apr_pstrdup(doc->pool, "2");
3687           }
3688           else if (STRCASEEQ('s','S',"small",cur->value)) {
3689             attr_size = apr_pstrdup(doc->pool, "3");
3690           }
3691           else if (STRCASEEQ('m','M',"medium",cur->value)) {
3692             attr_size = apr_pstrdup(doc->pool, "4");
3693           }
3694           else if (STRCASEEQ('l','L',"large",cur->value)) {
3695             attr_size = apr_pstrdup(doc->pool, "5");
3696           }
3697           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
3698             attr_size = apr_pstrdup(doc->pool, "6");
3699           }
3700           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
3701             attr_size = apr_pstrdup(doc->pool, "7");
3702           }
3703         }
3704       }
3705     }
3706   }
3707   W_L("<dir>");
3708   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
3709   memset(flg, 0, sizeof(*flg));
3710   if (attr_color || attr_size) {
3711     W_L("<font");
3712     if (attr_color) {
3713       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3714       W_L(" color=\"");
3715       W_V(attr_color);
3716       W_L("\"");
3717     }
3718     if (attr_size) {
3719       W_L(" size=\"");
3720       W_V(attr_size);
3721       W_L("\"");
3722     }
3723     W_L(">");
3724     flg->with_font_flag = 1;
3725   }
3726   node->userData = (void *)flg;
3727   return jhtml->out;
3728 }
3729
3730
3731 /**
3732  * It is a handler who processes the DIR tag.
3733  *
3734  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3735  *                     destination is specified.
3736  * @param node   [i]   The DIR tag node is specified.
3737  * @return The conversion result is returned.
3738  */
3739 static char *
3740 s_jhtml_end_dir_tag(void *pdoc, Node *node)
3741 {
3742   jhtml_t *jhtml = GET_JHTML(pdoc);
3743   Doc *doc = jhtml->doc;
3744   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
3745   if (flg && flg->with_font_flag) {
3746     W_L("</font>");
3747   }
3748   W_L("</dir>");
3749   if (IS_CSS_ON(jhtml->entryp)) {
3750     chxj_css_pop_prop_list(jhtml->css_prop_stack);
3751   }
3752   return jhtml->out;
3753 }
3754
3755
3756 /**
3757  * It is a handler who processes the DL tag.
3758  *
3759  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3760  *                     destination is specified.
3761  * @param node   [i]   The DL tag node is specified.
3762  * @return The conversion result is returned.
3763  */
3764 static char *
3765 s_jhtml_start_dl_tag(void *pdoc, Node *node)
3766 {
3767   jhtml_t *jhtml = GET_JHTML(pdoc);
3768   Doc       *doc     = jhtml->doc;
3769   Attr      *attr;
3770   char      *attr_style = NULL;
3771   char      *attr_color = NULL;
3772   char      *attr_size  = NULL;
3773   for (attr = qs_get_attr(doc,node);
3774        attr;
3775        attr = qs_get_next_attr(doc,attr)) {
3776     char *name   = qs_get_attr_name(doc,attr);
3777     char *value  = qs_get_attr_value(doc,attr);
3778     if (STRCASEEQ('s','S',"style", name) && value && *value) {
3779       attr_style = value;
3780     }
3781   }
3782   if (IS_CSS_ON(jhtml->entryp)) {
3783     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
3784     if (style) {
3785       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
3786       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
3787       css_property_t *cur;
3788       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3789         if (cur->value && *cur->value) {
3790           attr_color = apr_pstrdup(doc->pool, cur->value);
3791         }
3792       }
3793       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
3794         if (cur->value && *cur->value) {
3795           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
3796             attr_size = apr_pstrdup(doc->pool, "1");
3797           }
3798           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
3799             attr_size = apr_pstrdup(doc->pool, "2");
3800           }
3801           else if (STRCASEEQ('s','S',"small",cur->value)) {
3802             attr_size = apr_pstrdup(doc->pool, "3");
3803           }
3804           else if (STRCASEEQ('m','M',"medium",cur->value)) {
3805             attr_size = apr_pstrdup(doc->pool, "4");
3806           }
3807           else if (STRCASEEQ('l','L',"large",cur->value)) {
3808             attr_size = apr_pstrdup(doc->pool, "5");
3809           }
3810           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
3811             attr_size = apr_pstrdup(doc->pool, "6");
3812           }
3813           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
3814             attr_size = apr_pstrdup(doc->pool, "7");
3815           }
3816         }
3817       }
3818     }
3819   }
3820   W_L("<dl>");
3821   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
3822   memset(flg, 0, sizeof(*flg));
3823   if (attr_color || attr_size) {
3824     W_L("<font");
3825     if (attr_color) {
3826       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3827       W_L(" color=\"");
3828       W_V(attr_color);
3829       W_L("\"");
3830     }
3831     if (attr_size) {
3832       W_L(" size=\"");
3833       W_V(attr_size);
3834       W_L("\"");
3835     }
3836     W_L(">");
3837     flg->with_font_flag = 1;
3838   }
3839   node->userData = (void *)flg;
3840   return jhtml->out;
3841 }
3842
3843
3844 /**
3845  * It is a handler who processes the DL tag.
3846  *
3847  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3848  *                     destination is specified.
3849  * @param node   [i]   The DL tag node is specified.
3850  * @return The conversion result is returned.
3851  */
3852 static char *
3853 s_jhtml_end_dl_tag(void *pdoc, Node *node)
3854 {
3855   jhtml_t *jhtml = GET_JHTML(pdoc);
3856   Doc     *doc = jhtml->doc;
3857   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
3858   if (flg && flg->with_font_flag) {
3859     W_L("</font>");
3860   }
3861   W_L("</dl>");
3862   if (IS_CSS_ON(jhtml->entryp)) {
3863     chxj_css_pop_prop_list(jhtml->css_prop_stack);
3864   }
3865   return jhtml->out;
3866 }
3867
3868
3869 /**
3870  * It is a handler who processes the DT tag.
3871  *
3872  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3873  *                     destination is specified.
3874  * @param node   [i]   The DT tag node is specified.
3875  * @return The conversion result is returned.
3876  */
3877 static char *
3878 s_jhtml_start_dt_tag(void *pdoc, Node *node)
3879 {
3880   jhtml_t *jhtml = GET_JHTML(pdoc);
3881   Doc       *doc     = jhtml->doc;
3882   Attr      *attr;
3883   char      *attr_style = NULL;
3884   char      *attr_color = NULL;
3885   char      *attr_size  = NULL;
3886   for (attr = qs_get_attr(doc,node);
3887        attr;
3888        attr = qs_get_next_attr(doc,attr)) {
3889     char *name   = qs_get_attr_name(doc,attr);
3890     char *value  = qs_get_attr_value(doc,attr);
3891     if (STRCASEEQ('s','S',"style", name) && value && *value) {
3892       attr_style = value;
3893     }
3894   }
3895   if (IS_CSS_ON(jhtml->entryp)) {
3896     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
3897     if (style) {
3898       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
3899       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
3900       css_property_t *cur;
3901       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3902         if (cur->value && *cur->value) {
3903           attr_color = apr_pstrdup(doc->pool, cur->value);
3904         }
3905       }
3906       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
3907         if (cur->value && *cur->value) {
3908           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
3909             attr_size = apr_pstrdup(doc->pool, "1");
3910           }
3911           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
3912             attr_size = apr_pstrdup(doc->pool, "2");
3913           }
3914           else if (STRCASEEQ('s','S',"small",cur->value)) {
3915             attr_size = apr_pstrdup(doc->pool, "3");
3916           }
3917           else if (STRCASEEQ('m','M',"medium",cur->value)) {
3918             attr_size = apr_pstrdup(doc->pool, "4");
3919           }
3920           else if (STRCASEEQ('l','L',"large",cur->value)) {
3921             attr_size = apr_pstrdup(doc->pool, "5");
3922           }
3923           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
3924             attr_size = apr_pstrdup(doc->pool, "6");
3925           }
3926           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
3927             attr_size = apr_pstrdup(doc->pool, "7");
3928           }
3929         }
3930       }
3931     }
3932   }
3933   W_L("<dt>");
3934   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
3935   memset(flg, 0, sizeof(*flg));
3936   if (attr_color || attr_size) {
3937     W_L("<font");
3938     if (attr_color) {
3939       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3940       W_L(" color=\"");
3941       W_V(attr_color);
3942       W_L("\"");
3943     }
3944     if (attr_size) {
3945       W_L(" size=\"");
3946       W_V(attr_size);
3947       W_L("\"");
3948     }
3949     W_L(">");
3950     flg->with_font_flag = 1;
3951   }
3952   node->userData = (void *)flg;
3953   return jhtml->out;
3954 }
3955
3956
3957 /**
3958  * It is a handler who processes the DT tag.
3959  *
3960  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3961  *                     destination is specified.
3962  * @param node   [i]   The DT tag node is specified.
3963  * @return The conversion result is returned.
3964  */
3965 static char *
3966 s_jhtml_end_dt_tag(void *pdoc, Node *node)
3967 {
3968   jhtml_t *jhtml = GET_JHTML(pdoc);
3969   Doc       *doc     = jhtml->doc;
3970   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
3971   if (flg && flg->with_font_flag) {
3972     W_L("</font>");
3973   }
3974   if (IS_CSS_ON(jhtml->entryp)) {
3975     chxj_css_pop_prop_list(jhtml->css_prop_stack);
3976   }
3977   return jhtml->out;
3978 }
3979
3980
3981 /**
3982  * It is a handler who processes the DD tag.
3983  *
3984  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3985  *                     destination is specified.
3986  * @param node   [i]   The DD tag node is specified.
3987  * @return The conversion result is returned.
3988  */
3989 static char *
3990 s_jhtml_start_dd_tag(void *pdoc, Node *node)
3991 {
3992   jhtml_t *jhtml = GET_JHTML(pdoc);
3993   Doc       *doc     = jhtml->doc;
3994   Attr      *attr;
3995   char      *attr_style = NULL;
3996   char      *attr_color = NULL;
3997   char      *attr_size  = NULL;
3998   for (attr = qs_get_attr(doc,node);
3999        attr;
4000        attr = qs_get_next_attr(doc,attr)) {
4001     char *name   = qs_get_attr_name(doc,attr);
4002     char *value  = qs_get_attr_value(doc,attr);
4003     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4004       attr_style = value;
4005     }
4006   }
4007   if (IS_CSS_ON(jhtml->entryp)) {
4008     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4009     if (style) {
4010       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4011       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4012       css_property_t *cur;
4013       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4014         if (cur->value && *cur->value) {
4015           attr_color = apr_pstrdup(doc->pool, cur->value);
4016         }
4017       }
4018       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4019         if (cur->value && *cur->value) {
4020           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4021             attr_size = apr_pstrdup(doc->pool, "1");
4022           }
4023           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4024             attr_size = apr_pstrdup(doc->pool, "2");
4025           }
4026           else if (STRCASEEQ('s','S',"small",cur->value)) {
4027             attr_size = apr_pstrdup(doc->pool, "3");
4028           }
4029           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4030             attr_size = apr_pstrdup(doc->pool, "4");
4031           }
4032           else if (STRCASEEQ('l','L',"large",cur->value)) {
4033             attr_size = apr_pstrdup(doc->pool, "5");
4034           }
4035           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4036             attr_size = apr_pstrdup(doc->pool, "6");
4037           }
4038           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4039             attr_size = apr_pstrdup(doc->pool, "7");
4040           }
4041         }
4042       }
4043     }
4044   }
4045   W_L("<dd>");
4046   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
4047   memset(flg, 0, sizeof(*flg));
4048   if (attr_color || attr_size) {
4049     W_L("<font");
4050     if (attr_color) {
4051       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4052       W_L(" color=\"");
4053       W_V(attr_color);
4054       W_L("\"");
4055     }
4056     if (attr_size) {
4057       W_L(" size=\"");
4058       W_V(attr_size);
4059       W_L("\"");
4060     }
4061     W_L(">");
4062     flg->with_font_flag = 1;
4063   }
4064   node->userData = (void *)flg;
4065   return jhtml->out;
4066 }
4067
4068
4069 /**
4070  * It is a handler who processes the DD tag.
4071  *
4072  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4073  *                     destination is specified.
4074  * @param node   [i]   The DD tag node is specified.
4075  * @return The conversion result is returned.
4076  */
4077 static char *
4078 s_jhtml_end_dd_tag(void *pdoc, Node *node)
4079 {
4080   jhtml_t *jhtml = GET_JHTML(pdoc);
4081   Doc     *doc = jhtml->doc;
4082   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
4083   if (flg && flg->with_font_flag) {
4084     W_L("</font>");
4085   }
4086   if (IS_CSS_ON(jhtml->entryp)) {
4087     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4088   }
4089   return jhtml->out;
4090 }
4091
4092
4093 /**
4094  * It is a handler who processes the H1 tag.
4095  *
4096  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4097  *                     destination is specified.
4098  * @param node   [i]   The H1 tag node is specified.
4099  * @return The conversion result is returned.
4100  */
4101 static char *
4102 s_jhtml_start_h1_tag(void *pdoc, Node *node)
4103 {
4104   jhtml_t     *jhtml;
4105   Doc         *doc;
4106   request_rec *r;
4107   Attr        *attr;
4108   char        *attr_style = NULL;
4109   char        *attr_align = NULL;
4110
4111   jhtml   = GET_JHTML(pdoc);
4112   doc     = jhtml->doc;
4113   r       = doc->r;
4114
4115   for (attr = qs_get_attr(doc,node);
4116        attr;
4117        attr = qs_get_next_attr(doc,attr)) {
4118     char *name  = qs_get_attr_name(doc,attr);
4119     char *value = qs_get_attr_value(doc,attr);
4120     if (STRCASEEQ('a','A',"align", name)) {
4121       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4122         attr_align = value;
4123       }
4124     }
4125     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4126       attr_style = value;
4127     }
4128   }
4129   if (IS_CSS_ON(jhtml->entryp)) {
4130     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4131     if (style) {
4132       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4133       css_property_t *cur;
4134       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4135         if (STRCASEEQ('l','L',"left", cur->value)) {
4136           attr_align = apr_pstrdup(doc->pool, "left");
4137         }
4138         else if (STRCASEEQ('c','C',"center",cur->value)) {
4139           attr_align = apr_pstrdup(doc->pool, "center");
4140         }
4141         else if (STRCASEEQ('r','R',"right",cur->value)) {
4142           attr_align = apr_pstrdup(doc->pool, "right");
4143         }
4144       }
4145     }
4146   }
4147   if (attr_align) {
4148     W_L("<div align=\"");
4149     W_V(attr_align);
4150     W_L("\">");
4151     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4152     memset(flg, 0, sizeof(*flg));
4153     flg->with_div_align_flag = 1;
4154     node->userData = (void *)flg;
4155   }
4156   else {
4157     node->userData = NULL;
4158   }
4159
4160   return jhtml->out;
4161 }
4162
4163
4164 /**
4165  * It is a handler who processes the H1 tag.
4166  *
4167  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4168  *                     destination is specified.
4169  * @param node   [i]   The H1 tag node is specified.
4170  * @return The conversion result is returned.
4171  */
4172 static char *
4173 s_jhtml_end_h1_tag(void *pdoc, Node *node)
4174 {
4175   jhtml_t*    jhtml;
4176   Doc*          doc;
4177   request_rec*  r;
4178
4179   jhtml = GET_JHTML(pdoc);
4180   doc     = jhtml->doc;
4181   r       = doc->r;
4182   
4183   jhtml_flags_t *flg = node->userData;
4184   if (flg && flg->with_div_align_flag) {
4185     W_L("</div>");
4186     node->userData = NULL; 
4187   }
4188   if (IS_CSS_ON(jhtml->entryp)) {
4189     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4190   }
4191   return jhtml->out;
4192 }
4193
4194
4195 /**
4196  * It is a handler who processes the H2 tag.
4197  *
4198  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4199  *                     destination is specified.
4200  * @param node   [i]   The H1 tag node is specified.
4201  * @return The conversion result is returned.
4202  */
4203 static char *
4204 s_jhtml_start_h2_tag(void *pdoc, Node *node)
4205 {
4206   jhtml_t     *jhtml;
4207   Doc         *doc;
4208   request_rec *r;
4209   Attr        *attr;
4210   char        *attr_style = NULL;
4211   char        *attr_align = NULL;
4212
4213   jhtml   = GET_JHTML(pdoc);
4214   doc     = jhtml->doc;
4215   r       = doc->r;
4216
4217   for (attr = qs_get_attr(doc,node);
4218        attr;
4219        attr = qs_get_next_attr(doc,attr)) {
4220     char *name  = qs_get_attr_name(doc,attr);
4221     char *value = qs_get_attr_value(doc,attr);
4222     if (STRCASEEQ('a','A',"align", name)) {
4223       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4224         attr_align = value;
4225       }
4226     }
4227     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4228       attr_style = value;
4229     }
4230   }
4231   if (IS_CSS_ON(jhtml->entryp)) {
4232     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4233     if (style) {
4234       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4235       css_property_t *cur;
4236       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4237         if (STRCASEEQ('l','L',"left", cur->value)) {
4238           attr_align = apr_pstrdup(doc->pool, "left");
4239         }
4240         else if (STRCASEEQ('c','C',"center",cur->value)) {
4241           attr_align = apr_pstrdup(doc->pool, "center");
4242         }
4243         else if (STRCASEEQ('r','R',"right",cur->value)) {
4244           attr_align = apr_pstrdup(doc->pool, "right");
4245         }
4246       }
4247     }
4248   }
4249   if (attr_align) {
4250     W_L("<div align=\"");
4251     W_V(attr_align);
4252     W_L("\">");
4253     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4254     memset(flg, 0, sizeof(*flg));
4255     flg->with_div_align_flag = 1;
4256     node->userData = (void *)flg;
4257   }
4258   else {
4259     node->userData = NULL;
4260   }
4261
4262   return jhtml->out;
4263 }
4264
4265
4266 /**
4267  * It is a handler who processes the H2 tag.
4268  *
4269  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4270  *                     destination is specified.
4271  * @param node   [i]   The H1 tag node is specified.
4272  * @return The conversion result is returned.
4273  */
4274 static char *
4275 s_jhtml_end_h2_tag(void *pdoc, Node *node)
4276 {
4277   jhtml_t     *jhtml;
4278   Doc         *doc;
4279   request_rec *r;
4280
4281   jhtml = GET_JHTML(pdoc);
4282   doc     = jhtml->doc;
4283   r       = doc->r;
4284
4285   jhtml_flags_t *flg = node->userData;
4286   if (flg && flg->with_div_align_flag) {
4287     W_L("</div>");
4288     node->userData = NULL;
4289   }
4290   if (IS_CSS_ON(jhtml->entryp)) {
4291     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4292   }
4293   return jhtml->out;
4294 }
4295
4296
4297 /**
4298  * It is a handler who processes the H3 tag.
4299  *
4300  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4301  *                     destination is specified.
4302  * @param node   [i]   The H1 tag node is specified.
4303  * @return The conversion result is returned.
4304  */
4305 static char *
4306 s_jhtml_start_h3_tag(void *pdoc, Node *node)
4307 {
4308   jhtml_t     *jhtml;
4309   Doc         *doc;
4310   request_rec *r;
4311   Attr        *attr;
4312   char        *attr_style = NULL;
4313   char        *attr_align = NULL;
4314
4315   jhtml   = GET_JHTML(pdoc);
4316   doc     = jhtml->doc;
4317   r       = doc->r;
4318
4319   for (attr = qs_get_attr(doc,node);
4320        attr;
4321        attr = qs_get_next_attr(doc,attr)) {
4322     char *name  = qs_get_attr_name(doc,attr);
4323     char *value = qs_get_attr_value(doc,attr);
4324     if (STRCASEEQ('a','A',"align", name)) {
4325       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4326         attr_align = value;
4327       }
4328     }
4329     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4330       attr_style = value;
4331     }
4332   }
4333   if (IS_CSS_ON(jhtml->entryp)) {
4334     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4335     if (style) {
4336       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4337       css_property_t *cur;
4338       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4339         if (STRCASEEQ('l','L',"left", cur->value)) {
4340           attr_align = apr_pstrdup(doc->pool, "left");
4341         }
4342         else if (STRCASEEQ('c','C',"center",cur->value)) {
4343           attr_align = apr_pstrdup(doc->pool, "center");
4344         }
4345         else if (STRCASEEQ('r','R',"right",cur->value)) {
4346           attr_align = apr_pstrdup(doc->pool, "right");
4347         }
4348       }
4349     }
4350   }
4351   if (attr_align) {
4352     W_L("<div align=\"");
4353     W_V(attr_align);
4354     W_L("\">");
4355     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4356     memset(flg, 0, sizeof(*flg));
4357     flg->with_div_align_flag = 1;
4358     node->userData = (void *)flg;
4359   }
4360   else {
4361     node->userData = NULL;
4362   }
4363
4364   return jhtml->out;
4365 }
4366
4367
4368 /**
4369  * It is a handler who processes the H3 tag.
4370  *
4371  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4372  *                     destination is specified.
4373  * @param node   [i]   The H1 tag node is specified.
4374  * @return The conversion result is returned.
4375  */
4376 static char *
4377 s_jhtml_end_h3_tag(void *pdoc, Node *node)
4378 {
4379   jhtml_t*    jhtml;
4380   Doc*          doc;
4381   request_rec*  r;
4382
4383   jhtml = GET_JHTML(pdoc);
4384   doc     = jhtml->doc;
4385   r       = doc->r;
4386   
4387   jhtml_flags_t *flg = node->userData;
4388   if (flg && flg->with_div_align_flag) {
4389     W_L("</div>");
4390     node->userData = NULL;
4391   }
4392   if (IS_CSS_ON(jhtml->entryp)) {
4393     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4394   }
4395
4396   return jhtml->out;
4397 }
4398
4399
4400 /**
4401  * It is a handler who processes the H4 tag.
4402  *
4403  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4404  *                     destination is specified.
4405  * @param node   [i]   The H1 tag node is specified.
4406  * @return The conversion result is returned.
4407  */
4408 static char *
4409 s_jhtml_start_h4_tag(void *pdoc, Node *node)
4410 {
4411   jhtml_t     *jhtml;
4412   Doc         *doc;
4413   request_rec *r;
4414   Attr        *attr;
4415   char        *attr_style = NULL;
4416   char        *attr_align = NULL;
4417
4418   jhtml   = GET_JHTML(pdoc);
4419   doc     = jhtml->doc;
4420   r       = doc->r;
4421
4422   for (attr = qs_get_attr(doc,node);
4423        attr;
4424        attr = qs_get_next_attr(doc,attr)) {
4425     char *name  = qs_get_attr_name(doc,attr);
4426     char *value = qs_get_attr_value(doc,attr);
4427     if (STRCASEEQ('a','A',"align", name)) {
4428       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4429         attr_align = value;
4430       }
4431     }
4432     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4433       attr_style = value;
4434     }
4435   }
4436   if (IS_CSS_ON(jhtml->entryp)) {
4437     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4438     if (style) {
4439       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4440       css_property_t *cur;
4441       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4442         if (STRCASEEQ('l','L',"left", cur->value)) {
4443           attr_align = apr_pstrdup(doc->pool, "left");
4444         }
4445         else if (STRCASEEQ('c','C',"center",cur->value)) {
4446           attr_align = apr_pstrdup(doc->pool, "center");
4447         }
4448         else if (STRCASEEQ('r','R',"right",cur->value)) {
4449           attr_align = apr_pstrdup(doc->pool, "right");
4450         }
4451       }
4452     }
4453   }
4454   if (attr_align) {
4455     W_L("<div align=\"");
4456     W_V(attr_align);
4457     W_L("\">");
4458     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4459     memset(flg, 0, sizeof(*flg));
4460     flg->with_div_align_flag = 1;
4461     node->userData = (void *)flg;
4462   }
4463   else {
4464     node->userData = NULL;
4465   }
4466   return jhtml->out;
4467 }
4468
4469
4470 /**
4471  * It is a handler who processes the H4 tag.
4472  *
4473  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4474  *                     destination is specified.
4475  * @param node   [i]   The H1 tag node is specified.
4476  * @return The conversion result is returned.
4477  */
4478 static char *
4479 s_jhtml_end_h4_tag(void *pdoc, Node *node)
4480 {
4481   jhtml_t      *jhtml;
4482   Doc          *doc;
4483   request_rec  *r;
4484
4485   jhtml = GET_JHTML(pdoc);
4486   doc     = jhtml->doc;
4487   r       = doc->r;
4488   
4489   jhtml_flags_t *flg = node->userData;
4490   if (flg && flg->with_div_align_flag) {
4491     W_L("</div>");
4492     node->userData = NULL;
4493   }
4494   if (IS_CSS_ON(jhtml->entryp)) {
4495     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4496   }
4497   return jhtml->out;
4498 }
4499
4500
4501 /**
4502  * It is a handler who processes the H5 tag.
4503  *
4504  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4505  *                     destination is specified.
4506  * @param node   [i]   The H1 tag node is specified.
4507  * @return The conversion result is returned.
4508  */
4509 static char *
4510 s_jhtml_start_h5_tag(void *pdoc, Node *node)
4511 {
4512   jhtml_t     *jhtml;
4513   Doc         *doc;
4514   request_rec *r;
4515   Attr        *attr;
4516   char        *attr_style = NULL;
4517   char        *attr_align = NULL;
4518
4519   jhtml   = GET_JHTML(pdoc);
4520   doc     = jhtml->doc;
4521   r       = doc->r;
4522
4523   for (attr = qs_get_attr(doc,node);
4524        attr;
4525        attr = qs_get_next_attr(doc,attr)) {
4526     char *name  = qs_get_attr_name(doc,attr);
4527     char *value = qs_get_attr_value(doc,attr);
4528     if (STRCASEEQ('a','A',"align", name)) {
4529       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4530         attr_align = value;
4531       }
4532     }
4533     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4534       attr_style = value;
4535     }
4536   }
4537   if (IS_CSS_ON(jhtml->entryp)) {
4538     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4539     if (style) {
4540       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4541       css_property_t *cur;
4542       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4543         if (STRCASEEQ('l','L',"left", cur->value)) {
4544           attr_align = apr_pstrdup(doc->pool, "left");
4545         }
4546         else if (STRCASEEQ('c','C',"center",cur->value)) {
4547           attr_align = apr_pstrdup(doc->pool, "center");
4548         }
4549         else if (STRCASEEQ('r','R',"right",cur->value)) {
4550           attr_align = apr_pstrdup(doc->pool, "right");
4551         }
4552       }
4553     }
4554   }
4555   if (attr_align) {
4556     W_L("<div align=\"");
4557     W_V(attr_align);
4558     W_L("\">");
4559     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4560     memset(flg, 0, sizeof(*flg));
4561     flg->with_div_align_flag = 1;
4562     node->userData = (void *)flg;
4563   }
4564   else {
4565     node->userData = NULL;
4566   }
4567   return jhtml->out;
4568 }
4569
4570
4571 /**
4572  * It is a handler who processes the H5 tag.
4573  *
4574  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4575  *                     destination is specified.
4576  * @param node   [i]   The H1 tag node is specified.
4577  * @return The conversion result is returned.
4578  */
4579 static char *
4580 s_jhtml_end_h5_tag(void *pdoc, Node *node)
4581 {
4582   jhtml_t*    jhtml;
4583   Doc*          doc;
4584   request_rec*  r;
4585
4586   jhtml = GET_JHTML(pdoc);
4587   doc     = jhtml->doc;
4588   r       = doc->r;
4589   
4590   jhtml_flags_t *flg = node->userData;
4591   if (flg && flg->with_div_align_flag) {
4592     W_L("</div>");
4593     node->userData = NULL;
4594   }
4595   if (IS_CSS_ON(jhtml->entryp)) {
4596     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4597   }
4598
4599   return jhtml->out;
4600 }
4601
4602
4603 /**
4604  * It is a handler who processes the H6 tag.
4605  *
4606  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4607  *                     destination is specified.
4608  * @param node   [i]   The H1 tag node is specified.
4609  * @return The conversion result is returned.
4610  */
4611 static char *
4612 s_jhtml_start_h6_tag(void *pdoc, Node *node)
4613 {
4614   jhtml_t     *jhtml;
4615   Doc         *doc;
4616   request_rec *r;
4617   Attr        *attr;
4618   char        *attr_style = NULL;
4619   char        *attr_align = NULL;
4620
4621   jhtml   = GET_JHTML(pdoc);
4622   doc     = jhtml->doc;
4623   r       = doc->r;
4624
4625   for (attr = qs_get_attr(doc,node);
4626        attr;
4627        attr = qs_get_next_attr(doc,attr)) {
4628     char *name  = qs_get_attr_name(doc,attr);
4629     char *value = qs_get_attr_value(doc,attr);
4630     if (STRCASEEQ('a','A',"align", name)) {
4631       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4632         attr_align = value;
4633       }
4634     }
4635     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4636       attr_style = value;
4637     }
4638   }
4639   if (IS_CSS_ON(jhtml->entryp)) {
4640     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4641     if (style) {
4642       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4643       css_property_t *cur;
4644       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4645         if (STRCASEEQ('l','L',"left", cur->value)) {
4646           attr_align = apr_pstrdup(doc->pool, "left");
4647         }
4648         else if (STRCASEEQ('c','C',"center",cur->value)) {
4649           attr_align = apr_pstrdup(doc->pool, "center");
4650         }
4651         else if (STRCASEEQ('r','R',"right",cur->value)) {
4652           attr_align = apr_pstrdup(doc->pool, "right");
4653         }
4654       }
4655     }
4656   }
4657   if (attr_align) {
4658     W_L("<div align=\"");
4659     W_V(attr_align);
4660     W_L("\">");
4661     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4662     memset(flg, 0, sizeof(*flg));
4663     flg->with_div_align_flag = 1;
4664     node->userData = (void *)flg;
4665   }
4666   else {
4667     node->userData = NULL;
4668   }
4669
4670   return jhtml->out;
4671 }
4672
4673
4674 /**
4675  * It is a handler who processes the H6 tag.
4676  *
4677  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4678  *                     destination is specified.
4679  * @param node   [i]   The H1 tag node is specified.
4680  * @return The conversion result is returned.
4681  */
4682 static char *
4683 s_jhtml_end_h6_tag(void *pdoc, Node *node)
4684 {
4685   jhtml_t     *jhtml;
4686   Doc         *doc;
4687   request_rec *r;
4688
4689   jhtml = GET_JHTML(pdoc);
4690   doc     = jhtml->doc;
4691   r       = doc->r;
4692   
4693   jhtml_flags_t *flg = node->userData;
4694   if (flg && flg->with_div_align_flag) {
4695     W_L("</div>");
4696     node->userData = NULL;
4697   }
4698   if (IS_CSS_ON(jhtml->entryp)) {
4699     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4700   }
4701
4702   return jhtml->out;
4703 }
4704
4705
4706 /**
4707  * It is a handler who processes the MENU tag.
4708  *
4709  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4710  *                     destination is specified.
4711  * @param node   [i]   The MENU tag node is specified.
4712  * @return The conversion result is returned.
4713  */
4714 static char *
4715 s_jhtml_start_menu_tag(void *pdoc, Node *node)
4716 {
4717   jhtml_t *jhtml = GET_JHTML(pdoc);
4718   Doc     *doc     = jhtml->doc;
4719   Attr    *attr;
4720   char    *attr_style = NULL;
4721   char    *attr_color = NULL;
4722   char    *attr_size  = NULL;
4723   for (attr = qs_get_attr(doc,node);
4724        attr;
4725        attr = qs_get_next_attr(doc,attr)) {
4726     char *name   = qs_get_attr_name(doc,attr);
4727     char *value  = qs_get_attr_value(doc,attr);
4728     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4729       attr_style = value;
4730     }
4731   }
4732   if (IS_CSS_ON(jhtml->entryp)) {
4733     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4734     if (style) {
4735       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4736       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4737       css_property_t *cur;
4738       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4739         if (cur->value && *cur->value) {
4740           attr_color = apr_pstrdup(doc->pool, cur->value);
4741         }
4742       }
4743       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4744         if (cur->value && *cur->value) {
4745           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4746             attr_size = apr_pstrdup(doc->pool, "1");
4747           }
4748           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4749             attr_size = apr_pstrdup(doc->pool, "2");
4750           }
4751           else if (STRCASEEQ('s','S',"small",cur->value)) {
4752             attr_size = apr_pstrdup(doc->pool, "3");
4753           }
4754           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4755             attr_size = apr_pstrdup(doc->pool, "4");
4756           }
4757           else if (STRCASEEQ('l','L',"large",cur->value)) {
4758             attr_size = apr_pstrdup(doc->pool, "5");
4759           }
4760           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4761             attr_size = apr_pstrdup(doc->pool, "6");
4762           }
4763           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4764             attr_size = apr_pstrdup(doc->pool, "7");
4765           }
4766         }
4767       }
4768     }
4769   }
4770   W_L("<menu>");
4771   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
4772   memset(flg, 0, sizeof(*flg));
4773   if (attr_color || attr_size) {
4774     W_L("<font");
4775     if (attr_color) {
4776       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4777       W_L(" color=\"");
4778       W_V(attr_color);
4779       W_L("\"");
4780     }
4781     if (attr_size) {
4782       W_L(" size=\"");
4783       W_V(attr_size);
4784       W_L("\"");
4785     }
4786     W_L(">");
4787     flg->with_font_flag = 1;
4788   }
4789   node->userData = (void *)flg;
4790   return jhtml->out;
4791 }
4792
4793
4794 /**
4795  * It is a handler who processes the MENU tag.
4796  *
4797  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4798  *                     destination is specified.
4799  * @param node   [i]   The MENU tag node is specified.
4800  * @return The conversion result is returned.
4801  */
4802 static char *
4803 s_jhtml_end_menu_tag(void *pdoc, Node *node)
4804 {
4805   jhtml_t *jhtml = GET_JHTML(pdoc);
4806   Doc *doc = jhtml->doc;
4807   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
4808   if (flg && flg->with_font_flag) {
4809     W_L("</font>");
4810   }
4811   W_L("</menu>");
4812   if (IS_CSS_ON(jhtml->entryp)) {
4813     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4814   }
4815   return jhtml->out;
4816 }
4817
4818
4819 /**
4820  * It is a handler who processes the PLAINTEXT tag.
4821  *
4822  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4823  *                     destination is specified.
4824  * @param node   [i]   The PLAINTEXT tag node is specified.
4825  * @return The conversion result is returned.
4826  */
4827 static char *
4828 s_jhtml_start_plaintext_tag(void *pdoc, Node *node)
4829 {
4830   jhtml_t *jhtml;
4831   Doc *doc;
4832
4833   jhtml = GET_JHTML(pdoc);
4834   doc     = jhtml->doc;
4835   W_L("<plaintext>");
4836   s_jhtml_start_plaintext_tag_inner(pdoc,node);
4837   return jhtml->out;
4838 }
4839
4840 static char *
4841 s_jhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
4842 {
4843   jhtml_t *jhtml;
4844   Doc *doc;
4845   Node *child;
4846   jhtml = GET_JHTML(pdoc);
4847   doc     = jhtml->doc;
4848   for (child = qs_get_child_node(doc, node);
4849        child;
4850        child = qs_get_next_node(doc, child)) {
4851     W_V(child->otext);
4852     s_jhtml_start_plaintext_tag_inner(pdoc, child);
4853   }
4854   return jhtml->out;
4855 }
4856
4857
4858 /**
4859  * It is a handler who processes the PLAINTEXT tag.
4860  *
4861  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4862  *                     destination is specified.
4863  * @param node   [i]   The PLAINTEXT tag node is specified.
4864  * @return The conversion result is returned.
4865  */
4866 static char *
4867 s_jhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4868 {
4869   jhtml_t *jhtml = GET_JHTML(pdoc);
4870   return jhtml->out;
4871 }
4872
4873
4874 /**
4875  * It is a handler who processes the BLINK tag.
4876  *
4877  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4878  *                     destination is specified.
4879  * @param node   [i]   The BLINK tag node is specified.
4880  * @return The conversion result is returned.
4881  */
4882 static char *
4883 s_jhtml_start_blink_tag(void *pdoc, Node *node)
4884 {
4885   jhtml_t *jhtml = GET_JHTML(pdoc);
4886   Doc     *doc     = jhtml->doc;
4887   Attr    *attr;
4888   char    *attr_style = NULL;
4889   char    *attr_color = NULL;
4890   char    *attr_size  = NULL;
4891   for (attr = qs_get_attr(doc,node);
4892        attr;
4893        attr = qs_get_next_attr(doc,attr)) {
4894     char *name   = qs_get_attr_name(doc,attr);
4895     char *value  = qs_get_attr_value(doc,attr);
4896     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4897       attr_style = value;
4898     }
4899   }
4900   if (IS_CSS_ON(jhtml->entryp)) {
4901     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
4902     if (style) {
4903       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4904       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4905       css_property_t *cur;
4906       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4907         if (cur->value && *cur->value) {
4908           attr_color = apr_pstrdup(doc->pool, cur->value);
4909         }
4910       }
4911       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4912         if (cur->value && *cur->value) {
4913           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4914             attr_size = apr_pstrdup(doc->pool, "1");
4915           }
4916           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4917             attr_size = apr_pstrdup(doc->pool, "2");
4918           }
4919           else if (STRCASEEQ('s','S',"small",cur->value)) {
4920             attr_size = apr_pstrdup(doc->pool, "3");
4921           }
4922           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4923             attr_size = apr_pstrdup(doc->pool, "4");
4924           }
4925           else if (STRCASEEQ('l','L',"large",cur->value)) {
4926             attr_size = apr_pstrdup(doc->pool, "5");
4927           }
4928           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4929             attr_size = apr_pstrdup(doc->pool, "6");
4930           }
4931           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4932             attr_size = apr_pstrdup(doc->pool, "7");
4933           }
4934         }
4935       }
4936     }
4937   }
4938   W_L("<blink>");
4939   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
4940   memset(flg, 0, sizeof(*flg));
4941   if (attr_color || attr_size) {
4942     W_L("<font");
4943     if (attr_color) {
4944       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4945       W_L(" color=\"");
4946       W_V(attr_color);
4947       W_L("\"");
4948     }
4949     if (attr_size) {
4950       W_L(" size=\"");
4951       W_V(attr_size);
4952       W_L("\"");
4953     }
4954     W_L(">");
4955     flg->with_font_flag = 1;
4956   }
4957   node->userData = (void *)flg;
4958   return jhtml->out;
4959 }
4960
4961
4962 /**
4963  * It is a handler who processes the BLINK tag.
4964  *
4965  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4966  *                     destination is specified.
4967  * @param node   [i]   The BLINK tag node is specified.
4968  * @return The conversion result is returned.
4969  */
4970 static char *
4971 s_jhtml_end_blink_tag(void *pdoc, Node *node)
4972 {
4973   jhtml_t *jhtml = GET_JHTML(pdoc);
4974   Doc *doc = jhtml->doc;
4975   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
4976   if (flg && flg->with_font_flag) {
4977     W_L("</font>");
4978   }
4979   W_L("</blink>");
4980   if (IS_CSS_ON(jhtml->entryp)) {
4981     chxj_css_pop_prop_list(jhtml->css_prop_stack);
4982   }
4983   return jhtml->out;
4984 }
4985
4986
4987 /**
4988  * It is a handler who processes the MARQUEE tag.
4989  *
4990  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
4991  *                     destination is specified.
4992  * @param node   [i]   The MARQUEE tag node is specified.
4993  * @return The conversion result is returned.
4994  */
4995 static char *
4996 s_jhtml_start_marquee_tag(void *pdoc, Node *node)
4997 {
4998   jhtml_t *jhtml = GET_JHTML(pdoc);
4999   Doc     *doc = jhtml->doc;
5000   Attr    *attr;
5001   char    *attr_direction = NULL;
5002   char    *attr_style     = NULL;
5003   char    *attr_color     = NULL;
5004   char    *attr_size      = NULL;
5005   /*--------------------------------------------------------------------------*/
5006   /* Get Attributes                                                           */
5007   /*--------------------------------------------------------------------------*/
5008   for (attr = qs_get_attr(doc,node);
5009        attr;
5010        attr = qs_get_next_attr(doc,attr)) {
5011     char *name   = qs_get_attr_name(doc,attr);
5012     char *value  = qs_get_attr_value(doc,attr);
5013     if (STRCASEEQ('d','D',"direction", name)) {
5014       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
5015         attr_direction = value;
5016       }
5017     }
5018     else if (STRCASEEQ('b','B',"behavior",name)) {
5019       /* ignore */
5020     }
5021     else if (STRCASEEQ('l','L',"loop",name)) {
5022       /* ignore */
5023     }
5024     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5025       attr_style = value;
5026     }
5027   }
5028   if (IS_CSS_ON(jhtml->entryp)) {
5029     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
5030     if (style) {
5031       css_property_t *color_prop     = chxj_css_get_property_value(doc, style, "color");
5032       css_property_t *size_prop      = chxj_css_get_property_value(doc, style, "font-size");
5033       css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5034       css_property_t *cur;
5035       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5036         if (cur->value && *cur->value) {
5037           attr_color = apr_pstrdup(doc->pool, cur->value);
5038         }
5039       }
5040       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5041         if (cur->value && *cur->value) {
5042           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5043             attr_size = apr_pstrdup(doc->pool, "1");
5044           }
5045           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5046             attr_size = apr_pstrdup(doc->pool, "2");
5047           }
5048           else if (STRCASEEQ('s','S',"small",cur->value)) {
5049             attr_size = apr_pstrdup(doc->pool, "3");
5050           }
5051           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5052             attr_size = apr_pstrdup(doc->pool, "4");
5053           }
5054           else if (STRCASEEQ('l','L',"large",cur->value)) {
5055             attr_size = apr_pstrdup(doc->pool, "5");
5056           }
5057           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5058             attr_size = apr_pstrdup(doc->pool, "6");
5059           }
5060           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5061             attr_size = apr_pstrdup(doc->pool, "7");
5062           }
5063         }
5064       }
5065       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
5066         if (cur->value && *cur->value) {
5067           if (STRCASEEQ('l','L',"ltr",cur->value)) {
5068             attr_direction = "right";
5069           }
5070           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
5071             attr_direction = "left";
5072           }
5073         }
5074       }
5075     }
5076   }
5077   W_L("<marquee");
5078   if (attr_direction) {
5079     W_L(" direction=\"");
5080     W_V(attr_direction);
5081     W_L("\"");
5082   }
5083   W_L(">");
5084
5085   jhtml_flags_t *flg = (jhtml_flags_t *)apr_palloc(doc->pool, sizeof(jhtml_flags_t));
5086   memset(flg, 0, sizeof(*flg));
5087   if (attr_color || attr_size) {
5088     W_L("<font");
5089     if (attr_color) {
5090       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5091       W_L(" color=\"");
5092       W_V(attr_color);
5093       W_L("\"");
5094     }
5095     if (attr_size) {
5096       W_L(" size=\"");
5097       W_V(attr_size);
5098       W_L("\"");
5099     }
5100     W_L(">");
5101     flg->with_font_flag = 1;
5102   }
5103   node->userData = (void *)flg;
5104   return jhtml->out;
5105 }
5106
5107
5108 /**
5109  * It is a handler who processes the MARQUEE tag.
5110  *
5111  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5112  *                     destination is specified.
5113  * @param node   [i]   The MARQUEE tag node is specified.
5114  * @return The conversion result is returned.
5115  */
5116 static char *
5117 s_jhtml_end_marquee_tag(void *pdoc, Node *node)
5118 {
5119   jhtml_t *jhtml = GET_JHTML(pdoc);
5120   Doc     *doc   = jhtml->doc;
5121
5122   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
5123   if (flg && flg->with_font_flag) {
5124     W_L("</font>");
5125   }
5126   W_L("</marquee>");
5127   if (IS_CSS_ON(jhtml->entryp)) {
5128     chxj_css_pop_prop_list(jhtml->css_prop_stack);
5129   }
5130   return jhtml->out;
5131 }
5132
5133
5134 /**
5135  * It is handler who processes the New Line Code.
5136  */
5137 static char *
5138 s_jhtml_newline_mark(void *pdoc, Node *UNUSED(node))
5139 {
5140   jhtml_t *jhtml = GET_JHTML(pdoc);
5141   Doc *doc = jhtml->doc;
5142   W_NLCODE();
5143   return jhtml->out;
5144 }
5145
5146
5147 /**
5148  * It is a handler who processes the LINK tag.
5149  *
5150  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
5151  *                     destination is specified.
5152  * @param node   [i]   The LINK tag node is specified.
5153  * @return The conversion result is returned.
5154  */
5155 static char *
5156 s_jhtml_link_tag(void *pdoc, Node *node)
5157 {
5158   jhtml_t       *jhtml;
5159   Doc           *doc;
5160   Attr          *attr;
5161   char          *rel  = NULL;
5162   char          *href = NULL;
5163   char          *type = NULL;
5164
5165   jhtml = GET_JHTML(pdoc);
5166   doc   = jhtml->doc;
5167
5168   if (! IS_CSS_ON(jhtml->entryp)) {
5169     return jhtml->out;
5170   }
5171
5172   for (attr = qs_get_attr(doc,node);
5173        attr;
5174        attr = qs_get_next_attr(doc,attr)) {
5175     char *name  = qs_get_attr_name(doc,attr);
5176     char *value = qs_get_attr_value(doc,attr);
5177     if (STRCASEEQ('r','R',"rel", name)) {
5178       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
5179         rel = value;
5180       }
5181     }
5182     else if (STRCASEEQ('h','H',"href", name)) {
5183       if (value && *value) {
5184         href = value;
5185       }
5186     }
5187     else if (STRCASEEQ('t','T',"type", name)) {
5188       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5189         type = value;
5190       }
5191     }
5192   }
5193
5194   if (rel && href && type) {
5195     DBG(doc->r, "start load CSS. url:[%s]", href);
5196     jhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, jhtml->style, href);
5197     DBG(doc->r, "end load CSS. url:[%s]", href);
5198   }
5199
5200   return jhtml->out;
5201 }
5202
5203
5204 static css_prop_list_t *
5205 s_jhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5206 {
5207   jhtml_t *jhtml = GET_JHTML(pdoc);
5208   Doc *doc = jhtml->doc;
5209   css_prop_list_t *last_css = NULL;
5210   if (IS_CSS_ON(jhtml->entryp)) {
5211     css_prop_list_t *dup_css;
5212     css_selector_t  *selector;
5213
5214     last_css = chxj_css_get_last_prop_list(jhtml->css_prop_stack);
5215     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5216     selector = chxj_css_find_selector(doc, jhtml->style, node);
5217     if (selector) {
5218       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5219     }
5220     chxj_css_push_prop_list(jhtml->css_prop_stack, dup_css);
5221     last_css = chxj_css_get_last_prop_list(jhtml->css_prop_stack);
5222
5223     if (style_attr_value) {
5224       css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
5225       if (ssheet) {
5226         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5227       }
5228     }
5229   }
5230   return last_css;
5231 }
5232
5233
5234 static css_prop_list_t *
5235 s_jhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5236 {
5237   jhtml_t *jhtml = GET_JHTML(pdoc);
5238   Doc *doc = jhtml->doc;
5239   css_prop_list_t *last_css = NULL;
5240   if (IS_CSS_ON(jhtml->entryp)) {
5241     css_prop_list_t *dup_css;
5242     css_selector_t  *selector;
5243
5244     last_css = chxj_css_get_last_prop_list(jhtml->css_prop_stack);
5245     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5246     selector = chxj_css_find_selector(doc, jhtml->style, node);
5247     if (selector) {
5248       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5249     }
5250     last_css = dup_css;
5251
5252     if (style_attr_value) {
5253       css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
5254       if (ssheet) {
5255         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5256       }
5257     }
5258   }
5259   return last_css;
5260 }
5261
5262
5263 /**
5264  * It is a handler who processes the SPAN tag.
5265  *
5266  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5267  *                     destination is specified.
5268  * @param node   [i]   The SPAN tag node is specified.
5269  * @return The conversion result is returned.
5270  */
5271 static char *
5272 s_jhtml_start_span_tag(void *pdoc, Node *node)
5273 {
5274   jhtml_t *jhtml;
5275   Doc *doc;
5276   Attr *attr;
5277   char *attr_style = NULL;
5278   char *attr_color = NULL;
5279   char *attr_size = NULL;
5280   char *attr_align = NULL;
5281   char *attr_blink = NULL;
5282   char *attr_marquee = NULL;
5283   char *attr_marquee_dir = NULL;
5284   char *attr_marquee_style = NULL;
5285   char *attr_marquee_loop = NULL;
5286
5287   jhtml = GET_JHTML(pdoc);
5288   doc     = jhtml->doc;
5289
5290   for (attr = qs_get_attr(doc,node);
5291        attr;
5292        attr = qs_get_next_attr(doc,attr)) {
5293     char *nm  = qs_get_attr_name(doc,attr);
5294     char *val = qs_get_attr_value(doc,attr);
5295     if (val && STRCASEEQ('s','S',"style", nm)) {
5296       attr_style = val;
5297     }
5298   }
5299   if (IS_CSS_ON(jhtml->entryp)) {
5300     css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
5301     if (style) {
5302       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5303       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
5304       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
5305       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
5306       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
5307       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5308       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5309       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5310       css_property_t *cur;
5311       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5312         attr_color = apr_pstrdup(doc->pool, cur->value);
5313       }
5314       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5315         if (cur->value && *cur->value) {
5316           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5317             attr_size = apr_pstrdup(doc->pool, "1");
5318           }
5319           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5320             attr_size = apr_pstrdup(doc->pool, "2");
5321           }
5322           else if (STRCASEEQ('s','S',"small",cur->value)) {
5323             attr_size = apr_pstrdup(doc->pool, "3");
5324           }
5325           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5326             attr_size = apr_pstrdup(doc->pool, "4");
5327           }
5328           else if (STRCASEEQ('l','L',"large",cur->value)) {
5329             attr_size = apr_pstrdup(doc->pool, "5");
5330           }
5331           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5332             attr_size = apr_pstrdup(doc->pool, "6");
5333           }
5334           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5335             attr_size = apr_pstrdup(doc->pool, "7");
5336           }
5337         }
5338       }
5339       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
5340         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
5341           attr_blink = apr_pstrdup(doc->pool, cur->value);
5342         }
5343       }
5344       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
5345         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
5346           attr_marquee = apr_pstrdup(doc->pool, cur->value);
5347         }
5348       }
5349       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
5350         if (cur->value && *cur->value) {
5351           if (STRCASEEQ('l','L',"ltr",cur->value)) {
5352             attr_marquee_dir = "right";
5353           }
5354           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
5355             attr_marquee_dir = "left";
5356           }
5357         }
5358       }
5359       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
5360         if (cur->value && *cur->value) {
5361           if ( STRCASEEQ('s','S',"scroll",cur->value)
5362             || STRCASEEQ('s','S',"slide",cur->value)
5363             || STRCASEEQ('a','A',"alternate",cur->value)) {
5364             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
5365           }
5366         }
5367       }
5368       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
5369         if (cur->value && *cur->value) {
5370           if (STRCASEEQ('i','I',"infinite",cur->value)) {
5371             attr_marquee_loop = "16";
5372           }
5373           else {
5374             attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
5375           }
5376         }
5377       }
5378       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
5379         if (STRCASEEQ('l','L',"left", cur->value)) {
5380           attr_align = apr_pstrdup(doc->pool, "left");
5381         }
5382         else if (STRCASEEQ('c','C',"center",cur->value)) {
5383           attr_align = apr_pstrdup(doc->pool, "center");
5384         }
5385         else if (STRCASEEQ('r','R',"right",cur->value)) {
5386           attr_align = apr_pstrdup(doc->pool, "right");
5387         }
5388       }
5389     }
5390   }
5391   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee) {
5392     jhtml_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
5393     memset(flg, 0, sizeof(*flg));
5394     if (attr_blink) {
5395       W_L("<blink>");
5396       flg->with_blink_flag = 1;
5397     }
5398     if (attr_marquee) {
5399       W_L("<marquee");
5400       if (attr_marquee_dir) {
5401         W_L(" direction=\"");
5402         W_V(attr_marquee_dir);
5403         W_L("\"");
5404       }
5405       if (attr_marquee_style) {
5406         W_L(" behavior=\"");
5407         W_V(attr_marquee_style);
5408         W_L("\"");
5409       }
5410       if (attr_marquee_loop) {
5411         W_L(" loop=\"");
5412         W_V(attr_marquee_loop);
5413         W_L("\"");
5414       }
5415       W_L(">");
5416       flg->with_marquee_flag = 1;
5417     }
5418     if (attr_color||attr_size) {
5419       W_L("<font");
5420       if (attr_color) {
5421         attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5422         W_L(" color=\"");
5423         W_V(attr_color);
5424         W_L("\"");
5425       }
5426       if (attr_size) {
5427         W_L(" size=\"");
5428         W_V(attr_size);
5429         W_L("\"");
5430       }
5431       W_L(">");
5432       flg->with_font_flag = 1;
5433     }
5434     if (attr_align) {
5435       W_L("<div align=\"");
5436       W_V(attr_align);
5437       W_L("\">");
5438       flg->with_div_flag = 1;
5439     }
5440     node->userData = flg;
5441   }
5442   else {
5443     node->userData = NULL;
5444   }
5445   return jhtml->out;
5446 }
5447
5448
5449 /**
5450  * It is a handler who processes the SPAN tag.
5451  *
5452  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5453  *                     destination is specified.
5454  * @param node   [i]   The SPAN tag node is specified.
5455  * @return The conversion result is returned.
5456  */
5457 static char *
5458 s_jhtml_end_span_tag(void *pdoc, Node *node)
5459 {
5460   jhtml_t *jhtml = GET_JHTML(pdoc);
5461   Doc *doc = jhtml->doc;
5462
5463   jhtml_flags_t *flg = (jhtml_flags_t *)node->userData;
5464   if (flg && flg->with_div_flag) {
5465     W_L("</div>");
5466   }
5467   if (flg && flg->with_font_flag) {
5468     W_L("</font>");
5469   }
5470   if (flg && flg->with_marquee_flag) {
5471     W_L("</marquee>");
5472   }
5473   if (flg && flg->with_blink_flag) {
5474     W_L("</blink>");
5475   }
5476   if (IS_CSS_ON(jhtml->entryp)) {
5477     chxj_css_pop_prop_list(jhtml->css_prop_stack);
5478   }
5479   return jhtml->out;
5480 }
5481
5482
5483 /**
5484  * It is a handler who processes the STYLE tag.
5485  *
5486  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5487  *                     destination is specified.
5488  * @param node   [i]   The STYLE tag node is specified.
5489  * @return The conversion result is returned.
5490  */
5491 static char *
5492 s_jhtml_style_tag(void *pdoc, Node *node)
5493 {
5494   jhtml_t     *jhtml;
5495   Doc           *doc;
5496   Attr          *attr;
5497   char          *type = NULL;
5498
5499   jhtml = GET_JHTML(pdoc);
5500   doc     = jhtml->doc;
5501
5502   if (! IS_CSS_ON(jhtml->entryp)) {
5503     return jhtml->out;
5504   }
5505
5506   for (attr = qs_get_attr(doc,node);
5507        attr;
5508        attr = qs_get_next_attr(doc,attr)) {
5509     char *name  = qs_get_attr_name(doc,attr);
5510     char *value = qs_get_attr_value(doc,attr);
5511     if (STRCASEEQ('t','T',"type", name)) {
5512       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5513         type = value;
5514       }
5515     }
5516   }
5517
5518   Node *child = qs_get_child_node(doc, node);
5519   if (type && child) {
5520     char *name  = qs_get_node_name(doc, child);
5521     if (STRCASEEQ('t','T',"text", name)) {
5522       char *value = qs_get_node_value(doc, child);
5523       DBG(doc->r, "start load CSS. buf:[%s]", value);
5524       jhtml->style = chxj_css_parse_style_value(doc, jhtml->style, value);
5525       DBG(doc->r, "end load CSS. value:[%s]", value);
5526     }
5527   }
5528   return jhtml->out;
5529 }
5530 /*
5531  * vim:ts=2 et
5532  */