OSDN Git Service

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