OSDN Git Service

<p style="clear:char" /> for XHTML(i,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     /*------------------------------------------------------------------------*/
1951     /* CHTML 2.0                                                              */
1952     /*------------------------------------------------------------------------*/
1953     if (attr_type && STRCASEEQ('p','P',"password", attr_type) && ! jxhtml->entryp->pc_flag ) {
1954       char *vv = qs_conv_istyle_to_format(doc->buf.pool, "4");
1955       W_L(" style=\"-wap-input-format:&quot;*");
1956       W_V(vv);
1957       W_L("&quot;;\"");
1958     }
1959     else {
1960       char *vv = qs_conv_istyle_to_format(doc->buf.pool, attr_istyle);
1961       W_L(" style=\"");
1962       W_L("-wap-input-format:&quot;*");
1963       W_V(vv);
1964       W_L("&quot;;");
1965       W_L("\"");
1966     }
1967   }
1968   else if (attr_type && STRCASEEQ('p','P',"password",attr_type)) {
1969     char *vv = qs_conv_istyle_to_format(doc->buf.pool, "4");
1970     W_L(" style=\"-wap-input-format:&quot;*");
1971     W_V(vv);
1972     W_L("&quot;;\"");
1973   }
1974   /*--------------------------------------------------------------------------*/
1975   /* The figure is default for the password.                                  */
1976   /*--------------------------------------------------------------------------*/
1977   if (attr_max_length && *attr_max_length) {
1978     if (chxj_chk_numeric(attr_max_length) == 0) {
1979       W_L(" maxlength=\"");
1980       W_V(attr_max_length);
1981       W_L("\"");
1982     }
1983   }
1984   if (attr_checked) {
1985     W_L(" checked=\"checked\"");
1986   }
1987   W_L(" />");
1988 #if 0
1989   jxhtml_t       *jxhtml;
1990   Doc           *doc;
1991   request_rec   *r;
1992   char          *max_length;
1993   char          *type;
1994   char          *name;
1995   char          *value;
1996   char          *istyle;
1997   char          *size;
1998   char          *checked;
1999   char          *accesskey;
2000
2001   jxhtml       = GET_JXHTML(pdoc);
2002   doc         = jxhtml->doc;
2003   r           = doc->r;
2004   max_length  = NULL;
2005   type        = NULL;
2006   name        = NULL;
2007   value       = NULL;
2008   istyle      = NULL;
2009   size        = NULL;
2010   checked     = NULL;
2011   accesskey   = NULL;
2012
2013   W_L("<input");
2014   /*--------------------------------------------------------------------------*/
2015   /* Get Attributes                                                           */
2016   /*--------------------------------------------------------------------------*/
2017   type       = qs_get_type_attr(doc, node, doc->buf.pool);
2018   name       = qs_get_name_attr(doc, node, doc->buf.pool);
2019   value      = qs_get_value_attr(doc,node, doc->buf.pool);
2020   istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
2021   max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
2022   checked    = qs_get_checked_attr(doc,node,doc->buf.pool);
2023   accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
2024   size       = qs_get_size_attr(doc, node, doc->buf.pool);
2025
2026   if (type) {
2027     if (type && (STRCASEEQ('t','T',"text",    type) ||
2028                  STRCASEEQ('p','P',"password",type) ||
2029                  STRCASEEQ('c','C',"checkbox",type) ||
2030                  STRCASEEQ('r','R',"radio",   type) ||
2031                  STRCASEEQ('h','H',"hidden",  type) ||
2032                  STRCASEEQ('s','S',"submit",  type) ||
2033                  STRCASEEQ('r','R',"reset",   type))) {
2034       W_L(" type=\"");
2035       W_V(type);
2036       W_L("\"");
2037     }
2038   }
2039   if (size && *size) {
2040     W_L(" size=\"");
2041     W_V(size);
2042     W_L("\"");
2043   }
2044   if (name && *name) {
2045     W_L(" name=\"");
2046     W_V(chxj_jreserved_to_safe_tag(r, name, jxhtml->entryp));
2047     W_L("\"");
2048   }
2049   if (value && *value) {
2050     if (type && (STRCASEEQ('s','S',"submit",type) || STRCASEEQ('r','R',"reset",type))) {
2051       apr_size_t value_len = strlen(value);
2052       value = chxj_conv_z2h(r, value, &value_len, jxhtml->entryp);
2053     }
2054
2055     W_L(" value=\"");
2056     W_V(chxj_add_slash_to_doublequote(doc->pool, value));
2057     W_L("\"");
2058   }
2059   if (accesskey && *accesskey) {
2060     W_L(" accesskey=\"");
2061     W_V(accesskey);
2062     W_L("\"");
2063   }
2064   if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
2065     /*------------------------------------------------------------------------*/
2066     /* CHTML 2.0                                                              */
2067     /*------------------------------------------------------------------------*/
2068     if (type && STRCASEEQ('p','P',"password", type) && ! jxhtml->entryp->pc_flag ) {
2069       W_L(" style=\"-wap-input-format: &quot;*&lt;ja:n&gt;&quot;;\"");
2070     }
2071     else {
2072       char *vv = qs_conv_istyle_to_format(doc->buf.pool, istyle);
2073       W_L(" style=\"");
2074       W_L("-wap-input-format:'*");
2075       W_V(vv);
2076       W_L("';");
2077       W_L("\"");
2078     }
2079   }
2080   else if (type && STRCASEEQ('p','P',"password",type)) {
2081     W_L(" style=\"-wap-input-format: &quot;*&lt;ja:n&gt;&quot;;\"");
2082   }
2083   /*--------------------------------------------------------------------------*/
2084   /* The figure is default for the password.                                  */
2085   /*--------------------------------------------------------------------------*/
2086   if (max_length && *max_length) {
2087     if (chxj_chk_numeric(max_length) == 0) {
2088       W_L(" maxlength=\"");
2089       W_V(max_length);
2090       W_L("\"");
2091     }
2092   }
2093
2094   if (checked) {
2095     W_L(" checked=\"checked\"");
2096   }
2097   W_L(" />");
2098 #endif
2099   return jxhtml->out;
2100 }
2101
2102
2103 /**
2104  * It is a handler who processes the INPUT tag.
2105  *
2106  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2107  *                     destination is specified.
2108  * @param node   [i]   The INPUT tag node is specified.
2109  * @return The conversion result is returned.
2110  */
2111 static char *
2112 s_jxhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
2113 {
2114   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2115   return jxhtml->out;
2116 }
2117
2118
2119 /**
2120  * It is a handler who processes the CENTER tag.
2121  *
2122  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2123  *                     destination is specified.
2124  * @param node   [i]   The CENTER tag node is specified.
2125  * @return The conversion result is returned.
2126  */
2127 static char *
2128 s_jxhtml_start_center_tag(void *pdoc, Node *node)
2129 {
2130   jxhtml_t *jxhtml;
2131   Doc       *doc;
2132   Attr      *attr;
2133   char      *attr_style = NULL;
2134   char      *attr_color = NULL;
2135   char      *attr_size  = NULL;
2136
2137   jxhtml = GET_JXHTML(pdoc);
2138   doc    = jxhtml->doc;
2139
2140   for (attr = qs_get_attr(doc,node);
2141        attr;
2142        attr = qs_get_next_attr(doc,attr)) {
2143     char *name  = qs_get_attr_name(doc,attr);
2144     char *value = qs_get_attr_value(doc,attr);
2145     if (STRCASEEQ('s','S',"style",name) && value && *value) {
2146       attr_style = value;
2147     }
2148   }
2149   if (IS_CSS_ON(jxhtml->entryp)) {
2150     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2151     if (style) {
2152       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2153       css_property_t *size_prop       = chxj_css_get_property_value(doc, style, "font-size");
2154       css_property_t *cur;
2155       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2156         if (cur->value && *cur->value) {
2157           attr_color = apr_pstrdup(doc->pool, cur->value);
2158         }
2159       }
2160       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
2161         if (cur->value && *cur->value) {
2162           attr_size = apr_pstrdup(doc->pool, cur->value);
2163         }
2164       }
2165     }
2166   }
2167
2168   W_L("<center");
2169   if (attr_size || attr_color) {
2170     W_L(" style=\"");
2171     if (attr_size) {
2172       W_L("font-size:");
2173       W_V(attr_size);
2174       W_L(";");
2175     }
2176     if (attr_color) {
2177       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2178       W_L("color:");
2179       W_V(attr_color);
2180       W_L(";");
2181     }
2182     W_L("\"");
2183   }
2184   W_L(">");
2185   
2186   return jxhtml->out;
2187 }
2188
2189
2190 /**
2191  * It is a handler who processes the CENTER tag.
2192  *
2193  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2194  *                     destination is specified.
2195  * @param node   [i]   The CENTER tag node is specified.
2196  * @return The conversion result is returned.
2197  */
2198 static char *
2199 s_jxhtml_end_center_tag(void *pdoc, Node *UNUSED(node))
2200 {
2201   jxhtml_t    *jxhtml;
2202   Doc         *doc;
2203   request_rec *r;
2204
2205   jxhtml = GET_JXHTML(pdoc);
2206   doc    = jxhtml->doc;
2207   r      = doc->r;
2208
2209   W_L("</center>");
2210   if (IS_CSS_ON(jxhtml->entryp)) {
2211     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2212   }
2213   return jxhtml->out;
2214 }
2215
2216
2217 /**
2218  * It is a handler who processes the li tag.
2219  *
2220  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2221  *                     destination is specified.
2222  * @param node   [i]   The li tag node is specified.
2223  * @return The conversion result is returned.
2224  */
2225 static char *
2226 s_jxhtml_start_li_tag(void *pdoc, Node *node)
2227 {
2228   jxhtml_t    *jxhtml;
2229   Doc         *doc;
2230   request_rec *r;
2231   Attr        *attr;
2232   char        *attr_type  = NULL;
2233   char        *attr_value = NULL;
2234   char        *attr_style = NULL;
2235
2236   jxhtml = GET_JXHTML(pdoc);
2237   doc   = jxhtml->doc;
2238   r     = doc->r;
2239
2240   for (attr = qs_get_attr(doc,node);
2241        attr;
2242        attr = qs_get_next_attr(doc,attr)) {
2243     char *name  = qs_get_attr_name(doc,attr);
2244     char *value = qs_get_attr_value(doc,attr);
2245     if (STRCASEEQ('t','T',"type",name)) {
2246       if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
2247         if (*value == '1') {
2248           attr_type = apr_pstrdup(doc->pool, "decimal");
2249         }
2250         else if (*value == 'a') {
2251           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2252         }
2253         else if (*value == 'A') {
2254           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2255         }
2256         else {
2257           attr_type = value;
2258         }
2259       }
2260     }
2261     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2262       attr_value = value;
2263     }
2264     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2265       attr_style = value;
2266     }
2267   }
2268   if (IS_CSS_ON(jxhtml->entryp)) {
2269     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2270     if (style) {
2271       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2272       css_property_t *cur;
2273       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2274         if (STRCASEEQ('d','D',"decimal", cur->value)) {
2275           attr_type = apr_pstrdup(doc->pool, "decimal");
2276         }
2277         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2278           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2279         }
2280         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2281           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2282         }
2283         else if (STRCASEEQ('d','D',"disc", cur->value)) {
2284           attr_type = apr_pstrdup(doc->pool, "disc");
2285         }
2286         else if (STRCASEEQ('s','S',"square", cur->value)) {
2287           attr_type = apr_pstrdup(doc->pool, "square");
2288         }
2289         else if (STRCASEEQ('c','C',"circle", cur->value)) {
2290           attr_type = apr_pstrdup(doc->pool, "circle");
2291         }
2292       }
2293     }
2294   }
2295
2296
2297   W_L("<li");
2298   if (attr_type) {
2299     W_L(" style=\"");
2300     W_L("list-style-type:");
2301     W_V(attr_type);
2302     W_L(";");
2303     W_L("\"");
2304   }
2305   if (attr_value) {
2306     W_L(" value=\"");
2307     W_V(attr_value);
2308     W_L("\"");
2309   }
2310   W_L(">");
2311   return jxhtml->out;
2312 }
2313
2314
2315 /**
2316  * It is a handler who processes the li tag.
2317  *
2318  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2319  *                     destination is specified.
2320  * @param node   [i]   The li tag node is specified.
2321  * @return The conversion result is returned.
2322  */
2323 static char *
2324 s_jxhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
2325 {
2326   jxhtml_t     *jxhtml;
2327   Doc         *doc;
2328   request_rec *r;
2329
2330   jxhtml = GET_JXHTML(pdoc);
2331   doc   = jxhtml->doc;
2332   r     = doc->r;
2333
2334   if (IS_CSS_ON(jxhtml->entryp)) {
2335     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2336   }
2337   W_L("</li>");
2338   return jxhtml->out;
2339 }
2340
2341
2342 /**
2343  * It is a handler who processes the OL tag.
2344  *
2345  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2346  *                     destination is specified.
2347  * @param node   [i]   The OL tag node is specified.
2348  * @return The conversion result is returned.
2349  */
2350 static char *
2351 s_jxhtml_start_ol_tag(void *pdoc, Node *node)
2352 {
2353   jxhtml_t    *jxhtml;
2354   Doc         *doc;
2355   request_rec *r;
2356   Attr        *attr;
2357   char        *attr_style = NULL;
2358   char        *attr_start = NULL;
2359   char        *attr_type  = NULL;
2360
2361   jxhtml = GET_JXHTML(pdoc);
2362   doc   = jxhtml->doc;
2363   r     = doc->r;
2364
2365   /*--------------------------------------------------------------------------*/
2366   /* Get Attributes                                                           */
2367   /*--------------------------------------------------------------------------*/
2368   for (attr = qs_get_attr(doc,node);
2369        attr;
2370        attr = qs_get_next_attr(doc,attr)) {
2371     char *name = qs_get_attr_name(doc,attr);
2372     char *value = qs_get_attr_value(doc,attr);
2373     if (STRCASEEQ('t','T',"type",name) && value) {
2374       if (*value == '1') {
2375         attr_type = apr_pstrdup(doc->pool, "decimal");
2376       }
2377       else if (*value == 'a') {
2378         attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2379       }
2380       else if (*value == 'A') {
2381         attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2382       }
2383     }
2384     else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2385       attr_start = value;
2386     }
2387     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2388       attr_style = value;
2389     }
2390   }
2391   if (IS_CSS_ON(jxhtml->entryp)) {
2392     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2393     if (style) {
2394       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2395       css_property_t *cur;
2396       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2397         if (STRCASEEQ('d','D',"decimal", cur->value)) {
2398           attr_type = apr_pstrdup(doc->pool, "decimal");
2399         }
2400         else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2401           attr_type = apr_pstrdup(doc->pool, "upper-alpha");
2402         }
2403         else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2404           attr_type = apr_pstrdup(doc->pool, "lower-alpha");
2405         }
2406       }
2407     }
2408   }
2409   W_L("<ol");
2410   if (attr_type) {
2411     W_L(" style=\"");
2412     W_L("list-style-type:");
2413     W_V(attr_type);
2414     W_L(";");
2415     W_L("\"");
2416   }
2417   if (attr_start) {
2418     W_L(" start=\"");
2419     W_V(attr_start);
2420     W_L("\"");
2421   }
2422   W_L(">");
2423
2424   return jxhtml->out;
2425 }
2426
2427
2428 /**
2429  * It is a handler who processes the OL tag.
2430  *
2431  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2432  *                     destination is specified.
2433  * @param node   [i]   The OL tag node is specified.
2434  * @return The conversion result is returned.
2435  */
2436 static char *
2437 s_jxhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
2438 {
2439   jxhtml_t     *jxhtml;
2440   Doc         *doc;
2441   request_rec *r;
2442
2443   jxhtml = GET_JXHTML(pdoc);
2444   doc   = jxhtml->doc;
2445   r     = doc->r;
2446
2447   W_L("</ol>");
2448   if (IS_CSS_ON(jxhtml->entryp)) {
2449     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2450   }
2451   return jxhtml->out;
2452 }
2453
2454
2455 /**
2456  * It is a handler who processes the P tag.
2457  *
2458  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2459  *                     destination is specified.
2460  * @param node   [i]   The P tag node is specified.
2461  * @return The conversion result is returned.
2462  */
2463 static char *
2464 s_jxhtml_start_p_tag(void *pdoc, Node *node)
2465 {
2466   jxhtml_t    *jxhtml;
2467   Doc         *doc;
2468   request_rec *r;
2469   Attr        *attr;
2470   char        *attr_align = NULL;
2471   char        *attr_style = NULL;
2472   char        *attr_color = NULL;
2473   char        *attr_blink = NULL;
2474   char        *css_clear  = NULL;
2475
2476   jxhtml = GET_JXHTML(pdoc);
2477   doc   = jxhtml->doc;
2478   r     = doc->r;
2479
2480   for (attr = qs_get_attr(doc,node);
2481        attr;
2482        attr = qs_get_next_attr(doc,attr)) {
2483     char *nm  = qs_get_attr_name(doc,attr);
2484     char *val = qs_get_attr_value(doc,attr);
2485     if (STRCASEEQ('a','A',"align", nm)) {
2486       /*----------------------------------------------------------------------*/
2487       /* CHTML 1.0 (W3C version 3.2)                                          */
2488       /*----------------------------------------------------------------------*/
2489       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2490         attr_align = apr_pstrdup(doc->buf.pool, val);
2491         break;
2492       }
2493     }
2494     else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2495       attr_style = apr_pstrdup(doc->buf.pool, val);
2496     }
2497   }
2498   if (IS_CSS_ON(jxhtml->entryp)) {
2499     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2500     if (style) {
2501       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2502       css_property_t *color_prop      = chxj_css_get_property_value(doc, style, "color");
2503       css_property_t *text_deco_prop  = chxj_css_get_property_value(doc, style, "text-decoration");
2504       css_property_t *clear_prop      = chxj_css_get_property_value(doc, style, "clear");
2505       css_property_t *cur;
2506       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2507         if (STRCASEEQ('l','L',"left",cur->value)) {
2508           attr_align = apr_pstrdup(doc->pool, "left");
2509         }
2510         else if (STRCASEEQ('c','C',"center",cur->value)) {
2511           attr_align = apr_pstrdup(doc->pool, "center");
2512         }
2513         else if (STRCASEEQ('r','R',"right",cur->value)) {
2514           attr_align = apr_pstrdup(doc->pool, "right");
2515         }
2516       }
2517       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2518         if (cur->value && *cur->value) {
2519           attr_color = apr_pstrdup(doc->pool, cur->value);
2520         }
2521       }
2522       for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2523         if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2524           attr_blink = apr_pstrdup(doc->pool, cur->value);
2525         }
2526       }
2527       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
2528         css_clear = apr_pstrdup(doc->pool, cur->value);
2529       }
2530     }
2531   }
2532   W_L("<p");
2533   if ((attr_align && *attr_align) || (attr_color && *attr_color) || (attr_blink && *attr_blink) || css_clear) {
2534     W_L(" style=\"");
2535     if (attr_align) {
2536       W_L("text-align:");
2537       W_V(attr_align);
2538       W_L(";");
2539     }
2540     if (attr_color) {
2541       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2542       W_L("color:");
2543       W_V(attr_color);
2544       W_L(";");
2545     }
2546     if (attr_blink) {
2547       W_L("text-decoration:");
2548       W_V(attr_blink);
2549       W_L(";");
2550     }
2551     if (css_clear){
2552       W_L("clear:");
2553       W_V(css_clear);
2554       W_L(";");
2555     }
2556     W_L("\"");
2557   }
2558   W_L(">");
2559   return jxhtml->out;
2560 }
2561
2562
2563 /**
2564  * It is a handler who processes the P tag.
2565  *
2566  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2567  *                     destination is specified.
2568  * @param node   [i]   The P tag node is specified.
2569  * @return The conversion result is returned.
2570  */
2571 static char *
2572 s_jxhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
2573 {
2574   jxhtml_t  *jxhtml = GET_JXHTML(pdoc);
2575   Doc       *doc    = jxhtml->doc;
2576
2577   W_L("</p>");
2578   if (IS_CSS_ON(jxhtml->entryp)) {
2579     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2580   }
2581   return jxhtml->out;
2582 }
2583
2584
2585 /**
2586  * It is a handler who processes the PRE tag.
2587  *
2588  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2589  *                     destination is specified.
2590  * @param node   [i]   The PRE tag node is specified.
2591  * @return The conversion result is returned.
2592  */
2593 static char *
2594 s_jxhtml_start_pre_tag(void *pdoc, Node *node)
2595 {
2596   jxhtml_t  *jxhtml = GET_JXHTML(pdoc);
2597   Doc       *doc   = jxhtml->doc;
2598   Attr      *attr;
2599   char      *attr_style = NULL;
2600
2601   for (attr = qs_get_attr(doc,node);
2602        attr;
2603        attr = qs_get_next_attr(doc,attr)) {
2604     char *nm  = qs_get_attr_name(doc,attr);
2605     char *val = qs_get_attr_value(doc,attr);
2606     if (val && STRCASEEQ('s','S',"style", nm)) {
2607       attr_style = val;
2608     }
2609   }
2610
2611   if (IS_CSS_ON(jxhtml->entryp)) {
2612     s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2613   }
2614
2615   jxhtml->pre_flag++;
2616   W_L("<pre>");
2617   return jxhtml->out;
2618 }
2619
2620
2621 /**
2622  * It is a handler who processes the PRE tag.
2623  *
2624  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2625  *                     destination is specified.
2626  * @param node   [i]   The PRE tag node is specified.
2627  * @return The conversion result is returned.
2628  */
2629 static char *
2630 s_jxhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
2631 {
2632   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2633   Doc     *doc   = jxhtml->doc;
2634
2635   W_L("</pre>");
2636   jxhtml->pre_flag--;
2637   if (IS_CSS_ON(jxhtml->entryp)) {
2638     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2639   }
2640
2641   return jxhtml->out;
2642 }
2643
2644
2645 /**
2646  * It is a handler who processes the UL tag.
2647  *
2648  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2649  *                     destination is specified.
2650  * @param node   [i]   The UL tag node is specified.
2651  * @return The conversion result is returned.
2652  */
2653 static char *
2654 s_jxhtml_start_ul_tag(void *pdoc, Node *node)
2655 {
2656   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2657   Doc      *doc    = jxhtml->doc;
2658   Attr     *attr;
2659   char     *attr_type = NULL;
2660   char     *attr_style = NULL;
2661   /*--------------------------------------------------------------------------*/
2662   /* Get Attributes                                                           */
2663   /*--------------------------------------------------------------------------*/
2664   for (attr = qs_get_attr(doc,node);
2665        attr;
2666        attr = qs_get_next_attr(doc,attr)) {
2667     char *name   = qs_get_attr_name(doc,attr);
2668     char *value  = qs_get_attr_value(doc,attr);
2669     if (STRCASEEQ('t','T',"type",name)) {
2670       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2671         attr_type = value;
2672       }
2673     }
2674     else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2675       attr_style = value;
2676     }
2677   }
2678   if (IS_CSS_ON(jxhtml->entryp)) {
2679     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
2680     if (style) {
2681       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2682       css_property_t *cur;
2683       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2684         if (STRCASEEQ('d','D',"disc",cur->value)) {
2685           attr_type = apr_pstrdup(doc->pool, "disc");
2686         }
2687         else if (STRCASEEQ('c','C',"circle",cur->value)) {
2688           attr_type = apr_pstrdup(doc->pool, "circle");
2689         }
2690         else if (STRCASEEQ('s','S',"square",cur->value)) {
2691           attr_type = apr_pstrdup(doc->pool, "square");
2692         }
2693       }
2694     }
2695   }
2696   W_L("<ul");
2697   if (attr_type) {
2698     W_L(" style=\"");
2699     W_L("list-style-type:");
2700     W_V(attr_type);
2701     W_L(";");
2702     W_L("\"");
2703   }
2704   W_L(">");
2705   return jxhtml->out;
2706 }
2707
2708
2709 /**
2710  * It is a handler who processes the UL tag.
2711  *
2712  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2713  *                     destination is specified.
2714  * @param node   [i]   The UL tag node is specified.
2715  * @return The conversion result is returned.
2716  */
2717 static char *
2718 s_jxhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
2719 {
2720   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2721   Doc     *doc   = jxhtml->doc;
2722
2723   W_L("</ul>");
2724   if (IS_CSS_ON(jxhtml->entryp)) {
2725     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
2726   }
2727   return jxhtml->out;
2728 }
2729
2730
2731 /**
2732  * It is a handler who processes the HR tag.
2733  *
2734  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2735  *                     destination is specified.
2736  * @param node   [i]   The HR tag node is specified.
2737  * @return The conversion result is returned.
2738  */
2739 static char *
2740 s_jxhtml_start_hr_tag(void *pdoc, Node *node) 
2741 {
2742   Attr        *attr;
2743   jxhtml_t     *jxhtml;
2744   Doc         *doc;
2745   request_rec *r;
2746   char        *attr_align   = NULL;
2747   char        *attr_size    = NULL;
2748   char        *attr_width   = NULL;
2749   char        *attr_noshade = NULL;
2750   char        *attr_style   = NULL;
2751   char        *attr_color   = NULL;
2752   
2753   char        *style_float  = NULL;
2754   char        *style_border_color = NULL;
2755
2756   jxhtml   = GET_JXHTML(pdoc);
2757   doc     = jxhtml->doc;
2758   r       = doc->r;
2759
2760   for (attr = qs_get_attr(doc,node);
2761        attr; 
2762        attr = qs_get_next_attr(doc,attr)) {
2763     char *name  = qs_get_attr_name (doc,attr);
2764     char *value = qs_get_attr_value(doc,attr);
2765     switch(*name) {
2766     case 'a':
2767     case 'A':
2768       if (strcasecmp(name, "align") == 0) {
2769         /*--------------------------------------------------------------------*/
2770         /* CHTML 1.0                                                          */
2771         /*--------------------------------------------------------------------*/
2772         if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2773           attr_align = value;
2774         }
2775       }
2776       break;
2777
2778     case 's':
2779     case 'S':
2780       if (strcasecmp(name, "size") == 0) {
2781         /*--------------------------------------------------------------------*/
2782         /* CHTML 1.0                                                          */
2783         /*--------------------------------------------------------------------*/
2784         if (value && *value) {
2785           attr_size = value;
2786         }
2787       }
2788       else if (strcasecmp(name, "style") == 0) {
2789         if (value && *value) {
2790           attr_style = value;
2791         }
2792       }
2793       break;
2794
2795     case 'w':
2796     case 'W':
2797       if (strcasecmp(name, "width") == 0) {
2798         /*--------------------------------------------------------------------*/
2799         /* CHTML 1.0                                                          */
2800         /*--------------------------------------------------------------------*/
2801         if (value && *value) {
2802           attr_width = value;
2803         }
2804       }
2805       break;
2806
2807     case 'n':
2808     case 'N':
2809       if (strcasecmp(name, "noshade") == 0) {
2810         /*--------------------------------------------------------------------*/
2811         /* CHTML 1.0                                                          */
2812         /*--------------------------------------------------------------------*/
2813         attr_noshade = apr_pstrdup(doc->pool, "noshade");
2814       }
2815       break;
2816
2817     case 'c':
2818     case 'C':
2819       if (strcasecmp(name, "color") == 0 && value && *value) {
2820         /*--------------------------------------------------------------------*/
2821         /* CHTML 4.0                                                          */
2822         /*--------------------------------------------------------------------*/
2823         attr_color = value;
2824       }
2825       break;
2826
2827     default:
2828       break;
2829     }
2830   }
2831   if (IS_CSS_ON(jxhtml->entryp)) {
2832     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
2833     if (style) {
2834       css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2835       css_property_t *height_prop       = chxj_css_get_property_value(doc, style, "height");
2836       css_property_t *width_prop        = chxj_css_get_property_value(doc, style, "width");
2837       
2838       css_property_t *bgcolor_prop      = chxj_css_get_property_value(doc, style, "background-color");
2839       css_property_t *float_prop        = chxj_css_get_property_value(doc, style, "float");
2840       css_property_t *border_color_prop = chxj_css_get_property_value(doc, style, "border-color");
2841       css_property_t *cur;
2842       
2843       for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2844         if (STRCASEEQ('s','S',"solid",cur->value)) {
2845           attr_noshade = "noshade";
2846         }
2847       }
2848       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2849         char *tmp = apr_pstrdup(doc->pool, cur->value);
2850         char *tmpp = strstr(tmp, "px");
2851         if (tmpp) { 
2852           attr_size = apr_pstrdup(doc->pool, tmp);
2853         }
2854       }
2855       if(!attr_color){
2856           for(cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next){
2857           char *tmp   = apr_pstrdup(doc->pool,cur->value);
2858           attr_color  = apr_pstrdup(doc->pool,tmp);
2859         }
2860       }
2861       for (cur = float_prop->next; cur != float_prop; cur = cur->next) {
2862         char *tmp = apr_pstrdup(doc->pool, cur->value);
2863         char *tmpp = strstr(tmp,"none");
2864         if(tmpp){
2865           style_float = "center";
2866         }
2867         else{
2868           style_float = apr_pstrdup(doc->pool,tmp);
2869         }
2870       }
2871       
2872       
2873       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2874         char *tmp = apr_pstrdup(doc->pool, cur->value);
2875         char *tmpp = strstr(tmp, "px");
2876         if (tmpp) {
2877           attr_width = apr_pstrdup(doc->pool, tmp);
2878         }
2879         else {
2880           tmpp = strstr(tmp, "%");
2881           if (tmpp) {
2882             attr_width = apr_pstrdup(doc->pool, tmp);
2883           }
2884         }
2885       }
2886       
2887       for (cur = border_color_prop->next; cur != border_color_prop; cur = cur->next) {
2888         char *tmp = apr_pstrdup(doc->pool, cur->value);
2889         if(tmp){
2890           style_border_color = apr_pstrdup(doc->pool, tmp);
2891         }
2892       }
2893     }
2894   }
2895   W_L("<hr");
2896   if (attr_align) {
2897     W_L(" align=\"");
2898     W_V(attr_align);
2899     W_L("\"");
2900   }
2901   else{
2902     if(style_float){
2903       W_L(" align=\"");
2904       W_V(style_float);
2905       W_L("\"");
2906     }
2907   }
2908   if (attr_size || attr_width || attr_noshade || style_border_color) {
2909     W_L(" style=\"");
2910     if (attr_size) {
2911       W_L("height:");
2912       W_V(attr_size);
2913       if (!strstr(attr_size, "px")) {
2914         W_L("px");
2915       }
2916       W_L(";");
2917     }
2918     if (attr_width) {
2919       W_L("width:");
2920       W_V(attr_width);
2921       if (!strstr(attr_width, "px") && !strstr(attr_width, "%")) {
2922         W_L("px");
2923       }
2924       W_L(";");
2925     }
2926     if (attr_noshade) {
2927       W_L("border-style:solid;");
2928     }
2929     if(style_border_color){
2930       W_L("border-color:");
2931       W_V(style_border_color);
2932       W_V(";");
2933     }
2934     W_L("\"");
2935   }
2936   if (attr_color) {
2937     W_L(" color=\"");
2938     W_V(attr_color);
2939     W_L("\"");
2940   }
2941   
2942   W_L(" />");
2943
2944   return jxhtml->out;
2945 }
2946
2947
2948 /**
2949  * It is a handler who processes the HR tag.
2950  *
2951  * @param jxhtml  [i/o] The pointer to the JXHTML structure at the output
2952  *                     destination is specified.
2953  * @param node   [i]   The HR tag node is specified.
2954  * @return The conversion result is returned.
2955  */
2956 static char *
2957 s_jxhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
2958 {
2959   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
2960   return jxhtml->out;
2961 }
2962
2963
2964 /**
2965  * It is a handler who processes the IMG tag.
2966  *
2967  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
2968  *                     destination is specified.
2969  * @param node   [i]   The IMG tag node is specified.
2970  * @return The conversion result is returned.
2971  */
2972 static char *
2973 s_jxhtml_start_img_tag(void *pdoc, Node *node) 
2974 {
2975   jxhtml_t    *jxhtml = GET_JXHTML(pdoc);
2976   Doc         *doc   = jxhtml->doc;
2977   request_rec *r     = doc->r;
2978   Attr        *attr;
2979   char        *attr_src    = NULL;
2980   char        *attr_height = NULL;
2981   char        *attr_width  = NULL;
2982   char        *attr_align  = NULL;
2983   char        *attr_alt    = NULL;
2984   char        *attr_style  = NULL;
2985   char        *attr_hspace = NULL;
2986   char        *attr_vspace = NULL;
2987   
2988   char        *css_float          = NULL;
2989   char        *css_margin_left    = NULL;
2990   char        *css_margin_right   = NULL;
2991   char        *css_margin_top     = NULL;
2992   char        *css_margin_bottom  = NULL;
2993   char        *css_display        = NULL;
2994   char        *css_valign         = NULL;
2995   
2996 #ifndef IMG_NOT_CONVERT_FILENAME
2997   device_table  *spec = jxhtml->spec;
2998 #endif
2999
3000   /*--------------------------------------------------------------------------*/
3001   /* Get Attributes                                                           */
3002   /*--------------------------------------------------------------------------*/
3003   for (attr = qs_get_attr(doc,node);
3004        attr;
3005        attr = qs_get_next_attr(doc,attr)) {
3006     char *name  = qs_get_attr_name(doc,attr);
3007     char *value = qs_get_attr_value(doc,attr);
3008     if (STRCASEEQ('s','S',"src",name)) {
3009       /*----------------------------------------------------------------------*/
3010       /* CHTML 1.0                                                            */
3011       /*----------------------------------------------------------------------*/
3012 #ifdef IMG_NOT_CONVERT_FILENAME
3013       value = chxj_encoding_parameter(r, value, 1);
3014       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3015       value = chxj_add_cookie_no_update_parameter(r, value);
3016       attr_src = value;
3017 #else
3018       value = chxj_img_conv(r, spec, value);
3019       value = chxj_encoding_parameter(r, value, 1);
3020       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jxhtml->entryp, 1);
3021       value = chxj_add_cookie_no_update_parameter(r, value);
3022       attr_src = value;
3023 #endif
3024     }
3025     else if (STRCASEEQ('a','A',"align",name)) {
3026       /*----------------------------------------------------------------------*/
3027       /* CHTML 1.0                                                            */
3028       /*----------------------------------------------------------------------*/
3029       if (value) {
3030         if (STRCASEEQ('t','T',"top",   value) ||
3031             STRCASEEQ('m','M',"middle",value) ||
3032             STRCASEEQ('b','B',"bottom",value)){
3033           css_valign = value;
3034         }else if (STRCASEEQ('l','L',"left",  value) || STRCASEEQ('r','R',"right", value)) {
3035           css_float = value;
3036         }
3037         else if (STRCASEEQ('c','C',"center",value)) {
3038           css_valign = apr_pstrdup(doc->pool, "middle");
3039         }
3040       }
3041     }
3042     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
3043       /*----------------------------------------------------------------------*/
3044       /* CHTML 1.0                                                            */
3045       /*----------------------------------------------------------------------*/
3046       attr_width = value;
3047     }
3048     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
3049       /*----------------------------------------------------------------------*/
3050       /* CHTML 1.0                                                            */
3051       /*----------------------------------------------------------------------*/
3052       attr_height = value;
3053     }
3054     else if (STRCASEEQ('h','H',"hspace",name)) {
3055       /*----------------------------------------------------------------------*/
3056       /* CHTML 1.0                                                            */
3057       /*----------------------------------------------------------------------*/
3058       attr_hspace = value;
3059     }
3060     else if (STRCASEEQ('v','V',"vspace",name)) {
3061       /*----------------------------------------------------------------------*/
3062       /* CHTML 1.0                                                            */
3063       /*----------------------------------------------------------------------*/
3064       attr_vspace = value;
3065     }
3066     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
3067       /*----------------------------------------------------------------------*/
3068       /* CHTML 1.0                                                            */
3069       /*----------------------------------------------------------------------*/
3070       attr_alt = value;
3071     }
3072     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3073       /*----------------------------------------------------------------------*/
3074       /* CHTML 1.0                                                            */
3075       /*----------------------------------------------------------------------*/
3076       attr_style = value;
3077     }
3078   }
3079
3080   if (IS_CSS_ON(jxhtml->entryp)) {
3081     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3082     if (style) {
3083       css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
3084       css_property_t *width_prop  = chxj_css_get_property_value(doc, style, "width");
3085       css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
3086       css_property_t *margin_left_prop   = chxj_css_get_property_value(doc, style, "margin-left");
3087       css_property_t *margin_right_prop  = chxj_css_get_property_value(doc, style, "margin-right");
3088       css_property_t *margin_top_prop    = chxj_css_get_property_value(doc, style, "margin-top");
3089       css_property_t *margin_bottom_prop = chxj_css_get_property_value(doc, style, "margin-bottom");
3090       
3091       
3092       css_property_t *cur;
3093       for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
3094         attr_height = apr_pstrdup(doc->pool, cur->value);
3095       }
3096       for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
3097         attr_width = apr_pstrdup(doc->pool, cur->value);
3098       }
3099       if(!css_valign){
3100         for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
3101           css_valign = apr_pstrdup(doc->pool, cur->value);
3102         }
3103       }
3104       if (! attr_hspace) {
3105         for (cur = margin_left_prop->next; cur != margin_left_prop; cur = cur->next) {
3106           css_margin_left   = apr_pstrdup(doc->pool, cur->value);
3107         }
3108         for (cur = margin_right_prop->next; cur != margin_right_prop; cur = cur->next) {
3109           css_margin_right  = apr_pstrdup(doc->pool, cur->value);
3110         }
3111       }
3112       if (! attr_vspace) {
3113         for (cur = margin_top_prop->next; cur != margin_top_prop; cur = cur->next) {
3114           css_margin_top = apr_pstrdup(doc->pool, cur->value);
3115         }
3116         for (cur = margin_bottom_prop->next; cur != margin_bottom_prop; cur = cur->next) {
3117           css_margin_bottom = apr_pstrdup(doc->pool, cur->value);
3118         }
3119       }
3120       if(!css_float){
3121         css_property_t *float_prop = chxj_css_get_property_value(doc, style, "float");
3122         for (cur = float_prop->next; cur != float_prop; cur = cur->next) {
3123           css_float = apr_pstrdup(doc->pool, cur->value);
3124         }
3125       }
3126       
3127       css_property_t *display_prop       = chxj_css_get_property_value(doc, style, "display");
3128       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3129         char *tmp = apr_pstrdup(doc->pool, cur->value);
3130         char *tmpp = strstr(tmp, "none");
3131         if(tmpp){
3132           css_display = apr_pstrdup(doc->pool, tmp);
3133         }
3134       }
3135     }
3136   }
3137
3138   W_L("<img");
3139   if (attr_src) {
3140     W_L(" src=\"");
3141     W_V(attr_src);
3142     W_L("\"");
3143   }
3144   if (attr_hspace || attr_vspace || css_float || css_margin_left || css_margin_right || css_margin_top || css_margin_bottom || css_valign || css_display) {
3145     W_L(" style=\"");
3146     if(css_float){
3147       W_L("float:");
3148       W_V(css_float);
3149       W_L(";");
3150     }
3151     if(css_valign){
3152       W_L("vertical-align:");
3153       W_V(css_valign);
3154       W_L(";");
3155     }
3156     if (attr_hspace) {
3157       W_L("margin-left:");
3158       W_V(attr_hspace);
3159       W_L(";");
3160       W_L("margin-right:");
3161       W_V(attr_hspace);
3162       W_L(";");
3163     }
3164     else{
3165       if(css_margin_left){
3166         W_L("margin-left:");
3167         W_V(css_margin_left);
3168         W_L(";");
3169       }
3170       if(css_margin_right){
3171         W_L("margin-right:");
3172         W_V(css_margin_right);
3173         W_L(";");
3174       }
3175     }
3176     if (attr_vspace) {
3177       W_L("margin-top:");
3178       W_V(attr_vspace);
3179       W_L(";");
3180       W_L("margin-bottom:");
3181       W_V(attr_vspace);
3182       W_L(";");
3183     }
3184     else{
3185       if(css_margin_top){
3186         W_L("margin-top:");
3187         W_V(css_margin_top);
3188         W_L(";");
3189       }
3190       if(css_margin_bottom){
3191         W_L("margin-bottom:");
3192         W_V(css_margin_bottom);
3193         W_L(";");
3194       }
3195     }
3196     if(css_display){
3197       W_L("display:none;");
3198     }
3199     W_L("\"");
3200   }
3201   
3202   if (attr_width) {
3203     W_L(" width=\"");
3204     W_V(attr_width);
3205     W_L("\"");
3206   }
3207   if (attr_height) {
3208     W_L(" height=\"");
3209     W_V(attr_height);
3210     W_L("\"");
3211   }
3212   if (attr_alt) {
3213     W_L(" alt=\"");
3214     W_V(attr_alt);
3215     W_L("\"");
3216   } 
3217   else {
3218     W_L(" alt=\"\"");
3219   }
3220   W_L(" />");
3221   return jxhtml->out;
3222 }
3223
3224
3225 /**
3226  * It is a handler who processes the IMG tag.
3227  *
3228  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3229  *                     destination is specified.
3230  * @param node   [i]   The IMG tag node is specified.
3231  * @return The conversion result is returned.
3232  */
3233 static char *
3234 s_jxhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
3235 {
3236   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3237   return jxhtml->out;
3238 }
3239
3240
3241 /**
3242  * It is a handler who processes the SELECT tag.
3243  *
3244  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3245  *                     destination is specified.
3246  * @param node   [i]   The SELECT tag node is specified.
3247  * @return The conversion result is returned.
3248  */
3249 static char *
3250 s_jxhtml_start_select_tag(void *pdoc, Node *node)
3251 {
3252   jxhtml_t *jxhtml    = GET_JXHTML(pdoc);
3253   Doc     *doc      = jxhtml->doc;
3254   Attr    *attr;
3255   char    *size     = NULL;
3256   char    *name     = NULL;
3257   char    *multiple = NULL;
3258   char    *attr_style = NULL;
3259
3260   W_L("<select");
3261   for (attr = qs_get_attr(doc,node);
3262        attr;
3263        attr = qs_get_next_attr(doc,attr)) {
3264     char *nm  = qs_get_attr_name(doc,attr);
3265     char *val = qs_get_attr_value(doc,attr);
3266     if (STRCASEEQ('s','S',"size",nm)) {
3267       /*----------------------------------------------------------------------*/
3268       /* CHTML 1.0 version 2.0                                                */
3269       /*----------------------------------------------------------------------*/
3270       size = apr_pstrdup(doc->buf.pool, val);
3271     }
3272     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3273       /*----------------------------------------------------------------------*/
3274       /* CHTML 1.0 version 2.0                                                */
3275       /*----------------------------------------------------------------------*/
3276       attr_style = apr_pstrdup(doc->buf.pool, val);
3277     }
3278     else if (STRCASEEQ('n','N',"name",nm)) {
3279       /*----------------------------------------------------------------------*/
3280       /* CHTML 1.0 version 2.0                                                */
3281       /*----------------------------------------------------------------------*/
3282       name = apr_pstrdup(doc->buf.pool, val);
3283     }
3284     else if (STRCASEEQ('m','M',"multiple", nm)) {
3285       /*----------------------------------------------------------------------*/
3286       /* CHTML 1.0 version 2.0                                                */
3287       /*----------------------------------------------------------------------*/
3288       multiple = apr_pstrdup(doc->buf.pool, val);
3289     }
3290   }
3291   if (size && *size) {
3292     W_L(" size=\"");
3293     W_V(size);
3294     W_L("\"");
3295   }
3296   if (name && *name) {
3297     W_L(" name=\"");
3298     W_V(name);
3299     W_L("\"");
3300   }
3301   if (multiple) {
3302     W_L(" multiple");
3303   }
3304   W_L(">");
3305
3306   if (IS_CSS_ON(jxhtml->entryp)) {
3307     s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
3308   }
3309
3310   return jxhtml->out;
3311 }
3312
3313
3314 /**
3315  * It is a handler who processes the SELECT tag.
3316  *
3317  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3318  *                     destination is specified.
3319  * @param node   [i]   The SELECT tag node is specified.
3320  * @return The conversion result is returned.
3321  */
3322 static char *
3323 s_jxhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
3324 {
3325   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3326   Doc     *doc   = jxhtml->doc;
3327
3328   W_L("</select>");
3329   if (IS_CSS_ON(jxhtml->entryp)) {
3330     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3331   }
3332
3333   return jxhtml->out;
3334 }
3335
3336 /**
3337  * It is a handler who processes the OPTION tag.
3338  *
3339  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3340  *                     destination is specified.
3341  * @param node   [i]   The OPTION tag node is specified.
3342  * @return The conversion result is returned.
3343  */
3344 static char *
3345 s_jxhtml_start_option_tag(void *pdoc, Node *node)
3346 {
3347   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3348   Doc     *doc   = jxhtml->doc;
3349   Attr    *attr;
3350
3351   char *selected   = NULL;
3352   char *value      = NULL;
3353   char *attr_style = NULL;
3354
3355   W_L("<option");
3356   for (attr = qs_get_attr(doc,node);
3357        attr;
3358        attr = qs_get_next_attr(doc,attr)) {
3359     char *nm  = qs_get_attr_name(doc,attr);
3360     char *val = qs_get_attr_value(doc,attr);
3361     if (STRCASEEQ('s','S',"selected",nm)) {
3362       /*----------------------------------------------------------------------*/
3363       /* CHTML 1.0 version 2.0                                                */
3364       /*----------------------------------------------------------------------*/
3365       selected = apr_pstrdup(doc->buf.pool, val);
3366     }
3367     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3368       /*----------------------------------------------------------------------*/
3369       /* CHTML 1.0 version 2.0                                                */
3370       /*----------------------------------------------------------------------*/
3371       attr_style = apr_pstrdup(doc->buf.pool, val);
3372     }
3373     else if (STRCASEEQ('v','V',"value",nm)) {
3374       /*----------------------------------------------------------------------*/
3375       /* CHTML 1.0 version 2.0                                                */
3376       /*----------------------------------------------------------------------*/
3377       value = apr_pstrdup(doc->buf.pool, val);
3378     }
3379   }
3380   if (value) {
3381     W_L(" value=\"");
3382     W_V(value);
3383     W_L("\"");
3384   }
3385   if (selected) {
3386     W_L(" selected");
3387   }
3388   W_L(">");
3389
3390   if (IS_CSS_ON(jxhtml->entryp)) {
3391     s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
3392   }
3393
3394   return jxhtml->out;
3395 }
3396
3397
3398 /**
3399  * It is a handler who processes the OPTION tag.
3400  *
3401  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3402  *                     destination is specified.
3403  * @param node   [i]   The OPTION tag node is specified.
3404  * @return The conversion result is returned.
3405  */
3406 static char *
3407 s_jxhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
3408 {
3409   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
3410   Doc      *doc = jxhtml->doc;
3411
3412   W_L("</option>");
3413   if (IS_CSS_ON(jxhtml->entryp)) {
3414     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3415   }
3416
3417   return jxhtml->out;
3418 }
3419
3420
3421 /**
3422  * It is a handler who processes the DIV tag.
3423  *
3424  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3425  *                     destination is specified.
3426  * @param node   [i]   The DIV tag node is specified.
3427  * @return The conversion result is returned.
3428  */
3429 static char *
3430 s_jxhtml_start_div_tag(void *pdoc, Node *node)
3431 {
3432   jxhtml_t    *jxhtml;
3433   Doc         *doc;
3434   request_rec *r;
3435   Attr        *attr;
3436   char        *attr_style             = NULL;
3437   char        *attr_align             = NULL;
3438   char        *attr_display           = NULL;
3439   char        *attr_decoration        = NULL;
3440   char        *attr_wap_marquee_style = NULL;
3441   char        *attr_wap_marquee_dir   = NULL;
3442   char        *attr_wap_marquee_loop  = NULL;
3443   char        *attr_color             = NULL;
3444   char        *attr_bgcolor           = NULL;
3445   char        *attr_font_size         = NULL;
3446   char        *css_clear              = NULL;
3447
3448   jxhtml = GET_JXHTML(pdoc);
3449   doc   = jxhtml->doc;
3450   r     = doc->r;
3451
3452   for (attr = qs_get_attr(doc,node);
3453        attr;
3454        attr = qs_get_next_attr(doc,attr)) {
3455     char *nm  = qs_get_attr_name(doc,attr);
3456     char *val = qs_get_attr_value(doc,attr);
3457     if (STRCASEEQ('a','A',"align",nm)) {
3458       /*----------------------------------------------------------------------*/
3459       /* CHTML 1.0 (W3C version 3.2)                                          */
3460       /*----------------------------------------------------------------------*/
3461       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3462         attr_align = apr_pstrdup(doc->buf.pool, val);
3463       }
3464     }
3465     else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3466       attr_style = apr_pstrdup(doc->buf.pool, val);
3467     }
3468   }
3469
3470   if (IS_CSS_ON(jxhtml->entryp)) {
3471     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3472     if (style) {
3473       css_property_t *display_prop           = chxj_css_get_property_value(doc, style, "display");
3474       css_property_t *text_decoration_prop   = chxj_css_get_property_value(doc, style, "text-decoration");
3475       css_property_t *color_prop             = chxj_css_get_property_value(doc, style, "color");
3476       css_property_t *text_align_prop        = chxj_css_get_property_value(doc, style, "text-align");
3477       css_property_t *font_size_prop         = chxj_css_get_property_value(doc, style, "font-size");
3478       css_property_t *background_color_prop  = chxj_css_get_property_value(doc, style, "background-color");
3479       css_property_t *background_prop        = chxj_css_get_property_value(doc, style, "background");
3480       css_property_t *clear_prop             = chxj_css_get_property_value(doc, style, "clear");
3481
3482       css_property_t *cur;
3483       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3484         if (strcasecmp("-wap-marquee", cur->value) == 0) {
3485           attr_display = apr_pstrdup(doc->pool, cur->value);
3486         }
3487       }
3488       for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
3489         if (STRCASEEQ('b','B',"blink", cur->value)) {
3490           attr_decoration = apr_pstrdup(doc->pool, cur->value);
3491         }
3492       }
3493       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3494         attr_color = apr_pstrdup(doc->pool, cur->value);
3495       }
3496       for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
3497         attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3498         attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3499       }
3500       for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
3501         char *ss = strchr(cur->value, '#');
3502         if (!ss || !*ss) {
3503           ss = strstr(cur->value, "rgb");
3504         }
3505         if (ss && *ss) {
3506           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3507           attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3508         }
3509       }
3510       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3511         attr_align = apr_pstrdup(doc->pool, cur->value);
3512       }
3513       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3514         if (   STRCASEEQ('x','X',"xx-small",cur->value)
3515             || STRCASEEQ('x','X',"x-small",cur->value)
3516             || STRCASEEQ('s','S',"small",cur->value)
3517             || STRCASEEQ('m','M',"medium",cur->value)
3518             || STRCASEEQ('l','L',"large",cur->value)
3519             || STRCASEEQ('x','X',"x-large",cur->value)
3520             || STRCASEEQ('x','X',"xx-large",cur->value)) {
3521           attr_font_size = apr_pstrdup(doc->pool, cur->value);
3522         }
3523       }
3524       if (attr_display) {
3525         css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
3526         css_property_t *wap_marquee_dir_prop   = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
3527         css_property_t *wap_marquee_loop_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
3528         for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
3529           if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
3530             attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
3531           }
3532         }
3533         for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
3534           if (STRCASEEQ('l','L',"ltr",cur->value)) {
3535             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3536           }
3537           else if (STRCASEEQ('r','R',"rtl",cur->value)) {
3538             attr_wap_marquee_dir = apr_pstrdup(doc->pool, cur->value);
3539           }
3540         }
3541         for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
3542           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
3543             attr_wap_marquee_loop = "infinite";
3544           }
3545           else{
3546             attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
3547           }
3548         }
3549       }
3550       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
3551         css_clear = apr_pstrdup(doc->pool, cur->value);
3552       }
3553     }
3554   }  
3555   W_L("<div");
3556   if (attr_align
3557       || attr_display
3558       || attr_decoration
3559       || attr_wap_marquee_style
3560       || attr_wap_marquee_dir
3561       || attr_wap_marquee_loop
3562       || attr_color
3563       || attr_bgcolor
3564       || attr_font_size
3565       || css_clear ) {
3566     W_L(" style=\"");
3567     if (attr_align) {
3568       W_L("text-align:");
3569       W_V(attr_align);
3570       W_L(";");
3571     }
3572     if (attr_display) {
3573       W_L("display:");
3574       W_V(attr_display);
3575       W_L(";");
3576     }
3577     if (attr_decoration) {
3578       W_L("text-decoration:");
3579       W_V(attr_decoration);
3580       W_L(";");
3581     }
3582     if (attr_wap_marquee_style) {
3583       W_L("-wap-marquee-style:");
3584       W_V(attr_wap_marquee_style);
3585       W_L(";");
3586     }
3587     if (attr_wap_marquee_dir) {
3588       W_L("-wap-marquee-dir:");
3589       W_V(attr_wap_marquee_dir);
3590       W_L(";");
3591     }
3592     if (attr_wap_marquee_loop) {
3593       W_L("-wap-marquee-loop:");
3594       W_V(attr_wap_marquee_loop);
3595       W_L(";");
3596     }
3597     if (attr_color) {
3598       W_L("color:");
3599       W_V(attr_color);
3600       W_L(";");
3601     }
3602     if (attr_bgcolor) {
3603       W_L("background-color:");
3604       W_V(attr_bgcolor);
3605       W_L(";");
3606     }
3607     if (attr_font_size) {
3608       W_L("font-size:");
3609       W_V(attr_font_size);
3610       W_L(";");
3611     }
3612     if (css_clear){
3613       W_L("clear:");
3614       W_V(css_clear);
3615       W_L(";");
3616     }
3617     W_L("\"");
3618   }
3619   W_L(">");
3620   return jxhtml->out;
3621 }
3622
3623
3624 /**
3625  * It is a handler who processes the DIV tag.
3626  *
3627  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3628  *                     destination is specified.
3629  * @param node   [i]   The DIV tag node is specified.
3630  * @return The conversion result is returned.
3631  */
3632 static char *
3633 s_jxhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
3634 {
3635   jxhtml_t      *jxhtml;
3636   Doc          *doc;
3637   request_rec  *r;
3638
3639   jxhtml = GET_JXHTML(pdoc);
3640   doc   = jxhtml->doc;
3641   r     = doc->r;
3642
3643   W_L("</div>");
3644   if (IS_CSS_ON(jxhtml->entryp)) {
3645     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
3646   }
3647   return jxhtml->out;
3648 }
3649
3650
3651 static char *
3652 s_jxhtml_chxjif_tag(void *pdoc, Node *node)
3653 {
3654   jxhtml_t *jxhtml;
3655   Doc     *doc;
3656   Node    *child;
3657   request_rec *r;
3658
3659   jxhtml = GET_JXHTML(pdoc);
3660   doc   = jxhtml->doc;
3661   r     = doc->r;
3662
3663   for (child = qs_get_child_node(doc, node);
3664        child;
3665        child = qs_get_next_node(doc, child)) {
3666     W_V(child->otext);
3667     s_jxhtml_chxjif_tag(jxhtml, child);
3668   }
3669   return NULL;
3670 }
3671
3672
3673 /**
3674  * It is a handler who processes the TEXTARE tag.
3675  *
3676  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3677  *                     destination is specified.
3678  * @param node   [i]   The TEXTAREA tag node is specified.
3679  * @return The conversion result is returned.
3680  */
3681 static char *
3682 s_jxhtml_start_textarea_tag(void *pdoc, Node *node) 
3683 {
3684   jxhtml_t      *jxhtml;
3685   Doc           *doc;
3686   request_rec   *r;
3687   Attr          *attr;
3688   char          *attr_accesskey = NULL;
3689   char          *attr_name      = NULL;
3690   char          *attr_rows      = NULL;
3691   char          *attr_cols      = NULL;
3692   char          *attr_istyle    = NULL;
3693   char          *attr_style     = NULL;
3694
3695
3696   jxhtml = GET_JXHTML(pdoc);
3697   doc   = jxhtml->doc;
3698   r     = doc->r;
3699
3700   jxhtml->textarea_flag++;
3701   for (attr = qs_get_attr(doc,node);
3702        attr;
3703        attr = qs_get_next_attr(doc,attr)) {
3704     char *name  = qs_get_attr_name(doc,attr);
3705     char *value = qs_get_attr_value(doc,attr);
3706     if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3707       attr_accesskey = value;
3708     }
3709     else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3710       attr_istyle = value;
3711     }
3712     else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3713       attr_name = value;
3714     }
3715     else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3716       attr_rows = value;
3717     }
3718     else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3719       attr_cols = value;
3720     }
3721     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3722       attr_style = value;
3723     }
3724   }
3725   if (IS_CSS_ON(jxhtml->entryp)) {
3726     css_prop_list_t *style = s_jxhtml_nopush_and_get_now_style(pdoc, node, attr_style);
3727     if (style) {
3728       css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3729       css_property_t *cur;
3730       for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3731         if (strcasestr(cur->value, "<ja:n>")) {
3732           attr_istyle = "4";
3733         }
3734         else if (strcasestr(cur->value, "<ja:en>")) {
3735           attr_istyle = "3";
3736         }
3737         else if (strcasestr(cur->value, "<ja:hk>")) {
3738           attr_istyle = "2";
3739         }
3740         else if (strcasestr(cur->value, "<ja:h>")) {
3741           attr_istyle = "1";
3742         }
3743       }
3744     }
3745   }
3746   W_L("<textarea");
3747   if (attr_accesskey) {
3748     W_L(" accesskey=\"");
3749     W_V(attr_accesskey);
3750     W_L("\"");
3751   }
3752   if (attr_name) {
3753     W_L(" name=\"");
3754     W_V(attr_name);
3755     W_L("\"");
3756   }
3757   if (attr_rows) {
3758     W_L(" rows=\"");
3759     W_V(attr_rows);
3760     W_L("\"");
3761   }
3762   if (attr_cols) {
3763     W_L(" cols=\"");
3764     W_V(attr_cols);
3765     W_L("\"");
3766   }
3767   if (attr_istyle) {
3768     char *vv = qs_conv_istyle_to_format(doc->buf.pool, attr_istyle);
3769     W_L(" style=\"");
3770     W_L("-wap-input-format:&quot;*");
3771     W_V(vv);
3772     W_L("&quot;;");
3773     W_L("\"");
3774   }
3775   W_L(">");
3776   return jxhtml->out;
3777 }
3778
3779
3780 /**
3781  * It is a handler who processes the TEXTAREA tag.
3782  *
3783  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3784  *                     destination is specified.
3785  * @param node   [i]   The TEXTAREA tag node is specified.
3786  * @return The conversion result is returned.
3787  */
3788 static char *
3789 s_jxhtml_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
3790 {
3791   jxhtml_t       *jxhtml;
3792   Doc           *doc;
3793   request_rec   *r;
3794
3795   jxhtml = GET_JXHTML(pdoc);
3796   doc   = jxhtml->doc;
3797   r     = doc->r;
3798
3799   W_L("</textarea>");
3800   jxhtml->textarea_flag--;
3801
3802   return jxhtml->out;
3803 }
3804
3805
3806 /**
3807  * It is a handler who processes the B tag.
3808  *
3809  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3810  *                     destination is specified.
3811  * @param node   [i]   The B tag node is specified.
3812  * @return The conversion result is returned.
3813  */
3814 static char*
3815 s_jxhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
3816 {
3817   jxhtml_t*      jxhtml;
3818   Doc*          doc;
3819   request_rec*  r;
3820
3821   jxhtml = GET_JXHTML(pdoc);
3822   doc   = jxhtml->doc;
3823   r     = doc->r;
3824
3825   W_L("<b>");
3826   return jxhtml->out;
3827 }
3828
3829
3830 /**
3831  * It is a handler who processes the B tag.
3832  *
3833  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3834  *                     destination is specified.
3835  * @param node   [i]   The B tag node is specified.
3836  * @return The conversion result is returned.
3837  */
3838 static char*
3839 s_jxhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
3840 {
3841   jxhtml_t*      jxhtml = GET_JXHTML(pdoc);
3842   Doc*          doc   = jxhtml->doc;
3843
3844   W_L("</b>");
3845   return jxhtml->out;
3846 }
3847
3848 static char*
3849 s_jxhtml_text_tag(void* pdoc, Node* child)
3850 {
3851   jxhtml_t*     jxhtml;
3852   Doc*         doc;
3853   char*        textval;
3854   char*        tmp;
3855   char*        tdst;
3856   char         one_byte[2];
3857   int          ii;
3858   int          tdst_len;
3859   request_rec* r;
3860   apr_size_t   z2h_input_len;
3861
3862   jxhtml = GET_JXHTML(pdoc);
3863   doc   = jxhtml->doc;
3864   r     = doc->r;
3865
3866   textval = qs_get_node_value(doc,child);
3867   if (strlen(textval) == 0) {
3868     return jxhtml->out;
3869   }
3870
3871   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3872   memset(tmp, 0, qs_get_node_size(doc,child)+1);
3873
3874   tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
3875   memset(one_byte, 0, sizeof(one_byte));
3876   tdst_len = 0;
3877
3878   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3879     char* out;
3880     int rtn = s_jxhtml_search_emoji(jxhtml, &textval[ii], &out);
3881     if (rtn) {
3882       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3883       ii+=(rtn - 1);
3884       continue;
3885     }
3886
3887     if (is_sjis_kanji(textval[ii])) {
3888       one_byte[0] = textval[ii+0];
3889       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3890       one_byte[0] = textval[ii+1];
3891       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3892       ii++;
3893     }
3894     else 
3895     if (jxhtml->pre_flag) {
3896       one_byte[0] = textval[ii+0];
3897       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3898     }
3899     else
3900     if (jxhtml->textarea_flag) {
3901       one_byte[0] = textval[ii+0];
3902       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3903     }
3904     else {
3905       if (textval[ii] != '\r' && textval[ii] != '\n') {
3906         one_byte[0] = textval[ii+0];
3907         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3908       }
3909     }
3910   }
3911   z2h_input_len = strlen(tdst);
3912   tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, jxhtml->entryp);
3913
3914   W_V(tdst);
3915   return jxhtml->out;
3916 }
3917
3918
3919 /**
3920  * It is a handler who processes the BLOCKQUOTE tag.
3921  *
3922  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
3923  *                     destination is specified.
3924  * @param node   [i]   The BLOCKQUOTE tag node is specified.
3925  * @return The conversion result is returned.
3926  */
3927 static char *
3928 s_jxhtml_start_blockquote_tag(void *pdoc, Node *node)
3929 {
3930   jxhtml_t *jxhtml;
3931   Doc      *doc;
3932   Attr     *attr;
3933   char     *attr_style = NULL;
3934   char     *attr_color = NULL;
3935   char     *attr_size  = NULL;
3936
3937   jxhtml  = GET_JXHTML(pdoc);
3938   doc     = jxhtml->doc;
3939   for (attr = qs_get_attr(doc,node);
3940        attr;
3941        attr = qs_get_next_attr(doc,attr)) {
3942     char *nm  = qs_get_attr_name(doc,attr);
3943     char *val = qs_get_attr_value(doc,attr);
3944     if (val && STRCASEEQ('s','S',"style", nm)) {
3945       attr_style = val;
3946     }
3947   }
3948   if (IS_CSS_ON(jxhtml->entryp)) {
3949     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
3950     if (style) {
3951       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
3952       css_property_t *font_size_prop = chxj_css_get_property_value(doc, style, "font-size");
3953       css_property_t *cur;
3954       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3955         if (cur->value && *cur->value) {
3956           attr_color = apr_pstrdup(doc->pool, cur->value);
3957         }
3958       }
3959       for (cur = font_size_prop->next; cur != font_size_prop; cur = cur->next) {
3960         if (cur->value && *cur->value) {
3961           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
3962             attr_size = apr_pstrdup(doc->pool, cur->value);
3963           }
3964           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
3965             attr_size = apr_pstrdup(doc->pool, cur->value);
3966           }
3967           else if (STRCASEEQ('s','S',"small",cur->value)) {
3968             attr_size = apr_pstrdup(doc->pool, cur->value);
3969           }
3970           else if (STRCASEEQ('m','M',"medium",cur->value)) {
3971             attr_size = apr_pstrdup(doc->pool, cur->value);
3972           }
3973           else if (STRCASEEQ('l','L',"large",cur->value)) {
3974             attr_size = apr_pstrdup(doc->pool, cur->value);
3975           }
3976           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
3977             attr_size = apr_pstrdup(doc->pool, cur->value);
3978           }
3979           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
3980             attr_size = apr_pstrdup(doc->pool, cur->value);
3981           }
3982         }
3983       }
3984     }
3985   }
3986   W_L("<blockquote");
3987   if (attr_color || attr_size) {
3988     W_L(" style=\"");
3989     if (attr_color) {
3990       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3991       W_L("color:");
3992       W_V(attr_color);
3993       W_L(";");
3994     }
3995     if (attr_size) {
3996       W_L("font-size:");
3997       W_V(attr_size);
3998       W_L(";");
3999     }
4000     W_L("\"");
4001   }
4002   W_L(">");
4003   return jxhtml->out;
4004 }
4005
4006
4007 /**
4008  * It is a handler who processes the BLOCKQUOTE tag.
4009  *
4010  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4011  *                     destination is specified.
4012  * @param node   [i]   The BLOCKQUOTE tag node is specified.
4013  * @return The conversion result is returned.
4014  */
4015 static char *
4016 s_jxhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
4017 {
4018   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4019   Doc     *doc   = jxhtml->doc;
4020   W_L("</blockquote>");
4021   if (IS_CSS_ON(jxhtml->entryp)) {
4022     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4023   }
4024   return jxhtml->out;
4025 }
4026
4027
4028 /**
4029  * It is a handler who processes the DIR tag.
4030  *
4031  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4032  *                     destination is specified.
4033  * @param node   [i]   The DIR tag node is specified.
4034  * @return The conversion result is returned.
4035  */
4036 static char *
4037 s_jxhtml_start_dir_tag(void *pdoc, Node *node)
4038 {
4039   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4040   Doc       *doc        = jxhtml->doc;
4041   Attr      *attr;
4042   char      *attr_style = NULL;
4043   char      *attr_color = NULL;
4044   char      *attr_type  = NULL;
4045   char      *attr_size  = NULL;
4046   for (attr = qs_get_attr(doc,node);
4047        attr;
4048        attr = qs_get_next_attr(doc,attr)) {
4049     char *name   = qs_get_attr_name(doc,attr);
4050     char *value  = qs_get_attr_value(doc,attr);
4051     if (STRCASEEQ('t','T',"type",name)) {
4052       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4053         attr_type = value;
4054       }
4055     }
4056     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4057       attr_style = value;
4058     }
4059   }
4060   if (IS_CSS_ON(jxhtml->entryp)) {
4061     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4062     if (style) {
4063       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4064       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4065       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
4066       css_property_t *cur;
4067       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4068         if (cur->value && *cur->value) {
4069           attr_color = apr_pstrdup(doc->pool, cur->value);
4070         }
4071       }
4072       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4073         if (cur->value && *cur->value) {
4074           attr_type = apr_pstrdup(doc->pool, cur->value);
4075         }
4076       }
4077       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4078         if (cur->value && *cur->value) {
4079           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4080             attr_size = apr_pstrdup(doc->pool, cur->value);
4081           }
4082           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4083             attr_size = apr_pstrdup(doc->pool, cur->value);
4084           }
4085           else if (STRCASEEQ('s','S',"small",cur->value)) {
4086             attr_size = apr_pstrdup(doc->pool, cur->value);
4087           }
4088           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4089             attr_size = apr_pstrdup(doc->pool, cur->value);
4090           }
4091           else if (STRCASEEQ('l','L',"large",cur->value)) {
4092             attr_size = apr_pstrdup(doc->pool, cur->value);
4093           }
4094           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4095             attr_size = apr_pstrdup(doc->pool, cur->value);
4096           }
4097           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4098             attr_size = apr_pstrdup(doc->pool, cur->value);
4099           }
4100         }
4101       }
4102     }
4103   }
4104   W_L("<dir");
4105   if (attr_type || attr_color || attr_size) {
4106     W_L(" style=\"");
4107     if (attr_type) {
4108       W_L("list-style-type:");
4109       W_V(attr_type);
4110       W_L(";");
4111     }
4112     if (attr_color) {
4113       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4114       W_L("color:");
4115       W_V(attr_color);
4116       W_L(";");
4117     }
4118     if (attr_size) {
4119       W_L("font-size:");
4120       W_V(attr_size);
4121       W_L(";");
4122     }
4123     W_L("\"");
4124   }
4125   W_L(">");
4126   return jxhtml->out;
4127 }
4128
4129
4130 /**
4131  * It is a handler who processes the DIR tag.
4132  *
4133  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4134  *                     destination is specified.
4135  * @param node   [i]   The DIR tag node is specified.
4136  * @return The conversion result is returned.
4137  */
4138 static char *
4139 s_jxhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
4140 {
4141   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4142   Doc *doc = jxhtml->doc;
4143   W_L("</dir>");
4144   if (IS_CSS_ON(jxhtml->entryp)) {
4145     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4146   }
4147   return jxhtml->out;
4148 }
4149
4150
4151 /**
4152  * It is a handler who processes the DL tag.
4153  *
4154  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4155  *                     destination is specified.
4156  * @param node   [i]   The DL tag node is specified.
4157  * @return The conversion result is returned.
4158  */
4159 static char *
4160 s_jxhtml_start_dl_tag(void *pdoc, Node *node)
4161 {
4162   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4163   Doc       *doc        = jxhtml->doc;
4164   Attr      *attr;
4165   char      *attr_style = NULL;
4166   char      *attr_color = NULL;
4167   char      *attr_size  = NULL;
4168   for (attr = qs_get_attr(doc,node);
4169        attr;
4170        attr = qs_get_next_attr(doc,attr)) {
4171     char *name   = qs_get_attr_name(doc,attr);
4172     char *value  = qs_get_attr_value(doc,attr);
4173     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4174       attr_style = value;
4175     }
4176   }
4177   if (IS_CSS_ON(jxhtml->entryp)) {
4178     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4179     if (style) {
4180       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4181       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4182       css_property_t *cur;
4183       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4184         if (cur->value && *cur->value) {
4185           attr_color = apr_pstrdup(doc->pool, cur->value);
4186         }
4187       }
4188       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4189         if (cur->value && *cur->value) {
4190           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4191             attr_size = apr_pstrdup(doc->pool, cur->value);
4192           }
4193           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4194             attr_size = apr_pstrdup(doc->pool, cur->value);
4195           }
4196           else if (STRCASEEQ('s','S',"small",cur->value)) {
4197             attr_size = apr_pstrdup(doc->pool, cur->value);
4198           }
4199           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4200             attr_size = apr_pstrdup(doc->pool, cur->value);
4201           }
4202           else if (STRCASEEQ('l','L',"large",cur->value)) {
4203             attr_size = apr_pstrdup(doc->pool, cur->value);
4204           }
4205           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4206             attr_size = apr_pstrdup(doc->pool, cur->value);
4207           }
4208           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4209             attr_size = apr_pstrdup(doc->pool, cur->value);
4210           }
4211         }
4212       }
4213     }
4214   }
4215   W_L("<dl");
4216   if (attr_color || attr_size) {
4217     W_L(" style=\"");
4218     if (attr_color) {
4219       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4220       W_L("color:");
4221       W_V(attr_color);
4222       W_L(";");
4223     }
4224     if (attr_size) {
4225       W_L("font-size:");
4226       W_V(attr_size);
4227       W_L(";");
4228     }
4229     W_L("\"");
4230   }
4231   W_L(">");
4232   return jxhtml->out;
4233 }
4234
4235
4236 /**
4237  * It is a handler who processes the DL tag.
4238  *
4239  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4240  *                     destination is specified.
4241  * @param node   [i]   The DL tag node is specified.
4242  * @return The conversion result is returned.
4243  */
4244 static char *
4245 s_jxhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
4246 {
4247   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4248   Doc *doc = jxhtml->doc;
4249   W_L("</dl>");
4250   if (IS_CSS_ON(jxhtml->entryp)) {
4251     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4252   }
4253   return jxhtml->out;
4254 }
4255
4256
4257 /**
4258  * It is a handler who processes the DT tag.
4259  *
4260  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4261  *                     destination is specified.
4262  * @param node   [i]   The DT tag node is specified.
4263  * @return The conversion result is returned.
4264  */
4265 static char *
4266 s_jxhtml_start_dt_tag(void *pdoc, Node *node)
4267 {
4268   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4269   Doc       *doc        = jxhtml->doc;
4270   Attr      *attr;
4271   char      *attr_style = NULL;
4272   char      *attr_color = NULL;
4273   char      *attr_size  = NULL;
4274   for (attr = qs_get_attr(doc,node);
4275        attr;
4276        attr = qs_get_next_attr(doc,attr)) {
4277     char *name   = qs_get_attr_name(doc,attr);
4278     char *value  = qs_get_attr_value(doc,attr);
4279     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4280       attr_style = value;
4281     }
4282   }
4283   if (IS_CSS_ON(jxhtml->entryp)) {
4284     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4285     if (style) {
4286       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4287       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4288       css_property_t *cur;
4289       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4290         if (cur->value && *cur->value) {
4291           attr_color = apr_pstrdup(doc->pool, cur->value);
4292         }
4293       }
4294       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4295         if (cur->value && *cur->value) {
4296           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4297             attr_size = apr_pstrdup(doc->pool, cur->value);
4298           }
4299           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4300             attr_size = apr_pstrdup(doc->pool, cur->value);
4301           }
4302           else if (STRCASEEQ('s','S',"small",cur->value)) {
4303             attr_size = apr_pstrdup(doc->pool, cur->value);
4304           }
4305           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4306             attr_size = apr_pstrdup(doc->pool, cur->value);
4307           }
4308           else if (STRCASEEQ('l','L',"large",cur->value)) {
4309             attr_size = apr_pstrdup(doc->pool, cur->value);
4310           }
4311           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4312             attr_size = apr_pstrdup(doc->pool, cur->value);
4313           }
4314           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4315             attr_size = apr_pstrdup(doc->pool, cur->value);
4316           }
4317         }
4318       }
4319     }
4320   }
4321   W_L("<dt");
4322   if (attr_color || attr_size) {
4323     W_L(" style=\"");
4324     if (attr_color) {
4325       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4326       W_L("color:");
4327       W_V(attr_color);
4328       W_L(";");
4329     }
4330     if (attr_size) {
4331       W_L("font-size:");
4332       W_V(attr_size);
4333       W_L(";");
4334     }
4335     W_L("\"");
4336   }
4337   W_L(">");
4338   return jxhtml->out;
4339 }
4340
4341
4342 /**
4343  * It is a handler who processes the DT tag.
4344  *
4345  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4346  *                     destination is specified.
4347  * @param node   [i]   The DT tag node is specified.
4348  * @return The conversion result is returned.
4349  */
4350 static char *
4351 s_jxhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
4352 {
4353   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4354   Doc      *doc    = jxhtml->doc;
4355   W_L("</dt>");
4356   if (IS_CSS_ON(jxhtml->entryp)) {
4357     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4358   }
4359   return jxhtml->out;
4360 }
4361
4362
4363 /**
4364  * It is a handler who processes the DD tag.
4365  *
4366  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4367  *                     destination is specified.
4368  * @param node   [i]   The DD tag node is specified.
4369  * @return The conversion result is returned.
4370  */
4371 static char *
4372 s_jxhtml_start_dd_tag(void *pdoc, Node *node)
4373 {
4374   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
4375   Doc       *doc        = jxhtml->doc;
4376   Attr      *attr;
4377   char      *attr_style = NULL;
4378   char      *attr_color = NULL;
4379   char      *attr_size  = NULL;
4380   for (attr = qs_get_attr(doc,node);
4381        attr;
4382        attr = qs_get_next_attr(doc,attr)) {
4383     char *name   = qs_get_attr_name(doc,attr);
4384     char *value  = qs_get_attr_value(doc,attr);
4385     if (STRCASEEQ('s','S',"style", name) && value && *value) {
4386       attr_style = value;
4387     }
4388   }
4389   if (IS_CSS_ON(jxhtml->entryp)) {
4390     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4391     if (style) {
4392       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
4393       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
4394       css_property_t *cur;
4395       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4396         if (cur->value && *cur->value) {
4397           attr_color = apr_pstrdup(doc->pool, cur->value);
4398         }
4399       }
4400       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
4401         if (cur->value && *cur->value) {
4402           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
4403             attr_size = apr_pstrdup(doc->pool, cur->value);
4404           }
4405           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
4406             attr_size = apr_pstrdup(doc->pool, cur->value);
4407           }
4408           else if (STRCASEEQ('s','S',"small",cur->value)) {
4409             attr_size = apr_pstrdup(doc->pool, cur->value);
4410           }
4411           else if (STRCASEEQ('m','M',"medium",cur->value)) {
4412             attr_size = apr_pstrdup(doc->pool, cur->value);
4413           }
4414           else if (STRCASEEQ('l','L',"large",cur->value)) {
4415             attr_size = apr_pstrdup(doc->pool, cur->value);
4416           }
4417           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
4418             attr_size = apr_pstrdup(doc->pool, cur->value);
4419           }
4420           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
4421             attr_size = apr_pstrdup(doc->pool, cur->value);
4422           }
4423         }
4424       }
4425     }
4426   }
4427   W_L("<dd");
4428   if (attr_color || attr_size) {
4429     W_L(" style=\"");
4430     if (attr_color) {
4431       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4432       W_L("color:");
4433       W_V(attr_color);
4434       W_L(";");
4435     }
4436     if (attr_size) {
4437       W_L("font-size:");
4438       W_V(attr_size);
4439       W_L(";");
4440     }
4441     W_L("\"");
4442   }
4443   W_L(">");
4444   return jxhtml->out;
4445 }
4446
4447
4448 /**
4449  * It is a handler who processes the DD tag.
4450  *
4451  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4452  *                     destination is specified.
4453  * @param node   [i]   The DD tag node is specified.
4454  * @return The conversion result is returned.
4455  */
4456 static char *
4457 s_jxhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
4458 {
4459   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
4460   Doc      *doc = jxhtml->doc;
4461   W_L("</dd>");
4462   if (IS_CSS_ON(jxhtml->entryp)) {
4463     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4464   }
4465   return jxhtml->out;
4466 }
4467
4468
4469 /**
4470  * It is a handler who processes the H1 tag.
4471  *
4472  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4473  *                     destination is specified.
4474  * @param node   [i]   The H1 tag node is specified.
4475  * @return The conversion result is returned.
4476  */
4477 static char *
4478 s_jxhtml_start_h1_tag(void *pdoc, Node *node)
4479 {
4480   jxhtml_t    *jxhtml;
4481   Doc         *doc;
4482   request_rec *r;
4483   Attr        *attr;
4484   char        *attr_style = NULL;
4485   char        *attr_align = NULL;
4486   char        *css_clear  = NULL;
4487
4488   jxhtml = GET_JXHTML(pdoc);
4489   doc    = jxhtml->doc;
4490   r      = doc->r;
4491
4492   for (attr = qs_get_attr(doc,node);
4493        attr;
4494        attr = qs_get_next_attr(doc,attr)) {
4495     char *name  = qs_get_attr_name(doc,attr);
4496     char *value = qs_get_attr_value(doc,attr);
4497     if (STRCASEEQ('a','A',"align", name)) {
4498       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4499         attr_align = value;
4500       }
4501     }
4502     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4503       attr_style = value;
4504     }
4505   }
4506   if (IS_CSS_ON(jxhtml->entryp)) {
4507     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4508     if (style) {
4509       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4510       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4511       css_property_t *cur;
4512       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4513         if (STRCASEEQ('l','L',"left", cur->value)) {
4514           attr_align = apr_pstrdup(doc->pool, "left");
4515         }
4516         else if (STRCASEEQ('c','C',"center",cur->value)) {
4517           attr_align = apr_pstrdup(doc->pool, "center");
4518         }
4519         else if (STRCASEEQ('r','R',"right",cur->value)) {
4520           attr_align = apr_pstrdup(doc->pool, "right");
4521         }
4522       }
4523       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4524         if (STRCASEEQ('b','B',"both", cur->value)) {
4525           css_clear = apr_pstrdup(doc->pool, "both");
4526         }
4527         else if (STRCASEEQ('r','R',"right", cur->value)) {
4528           css_clear = apr_pstrdup(doc->pool, "right");
4529         }
4530         else if (STRCASEEQ('l','L',"left", cur->value)) {
4531           css_clear = apr_pstrdup(doc->pool, "left");
4532         }
4533       }
4534     }
4535   }
4536   W_L("<h1");
4537   if (attr_align || css_clear ) {
4538     W_L(" style=\"");
4539     if(attr_align){
4540       W_L("text-align:");
4541       W_V(attr_align);
4542       W_L(";");
4543     }
4544     if(css_clear){
4545       W_L("clear:");
4546       W_V(css_clear);
4547       W_L(";");
4548     }
4549     W_L("\"");
4550   }
4551   W_L(">");
4552
4553   return jxhtml->out;
4554 }
4555
4556
4557 /**
4558  * It is a handler who processes the H1 tag.
4559  *
4560  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4561  *                     destination is specified.
4562  * @param node   [i]   The H1 tag node is specified.
4563  * @return The conversion result is returned.
4564  */
4565 static char *
4566 s_jxhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
4567 {
4568   jxhtml_t*    jxhtml;
4569   Doc*          doc;
4570   request_rec*  r;
4571
4572   jxhtml = GET_JXHTML(pdoc);
4573   doc     = jxhtml->doc;
4574   r       = doc->r;
4575   
4576   W_L("</h1>");
4577   if (IS_CSS_ON(jxhtml->entryp)) {
4578     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4579   }
4580
4581   return jxhtml->out;
4582 }
4583
4584
4585 /**
4586  * It is a handler who processes the H2 tag.
4587  *
4588  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4589  *                     destination is specified.
4590  * @param node   [i]   The H1 tag node is specified.
4591  * @return The conversion result is returned.
4592  */
4593 static char *
4594 s_jxhtml_start_h2_tag(void *pdoc, Node *node)
4595 {
4596   jxhtml_t    *jxhtml;
4597   Doc         *doc;
4598   request_rec *r;
4599   Attr        *attr;
4600   char        *attr_style = NULL;
4601   char        *attr_align = NULL;
4602   char        *css_clear  = NULL;
4603
4604   jxhtml   = GET_JXHTML(pdoc);
4605   doc     = jxhtml->doc;
4606   r       = doc->r;
4607
4608   for (attr = qs_get_attr(doc,node);
4609        attr;
4610        attr = qs_get_next_attr(doc,attr)) {
4611     char *name  = qs_get_attr_name(doc,attr);
4612     char *value = qs_get_attr_value(doc,attr);
4613     if (STRCASEEQ('a','A',"align", name)) {
4614       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4615         attr_align = value;
4616       }
4617     }
4618     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4619       attr_style = value;
4620     }
4621   }
4622   if (IS_CSS_ON(jxhtml->entryp)) {
4623     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4624     if (style) {
4625       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4626       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4627       css_property_t *cur;
4628       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4629         if (STRCASEEQ('l','L',"left", cur->value)) {
4630           attr_align = apr_pstrdup(doc->pool, "left");
4631         }
4632         else if (STRCASEEQ('c','C',"center",cur->value)) {
4633           attr_align = apr_pstrdup(doc->pool, "center");
4634         }
4635         else if (STRCASEEQ('r','R',"right",cur->value)) {
4636           attr_align = apr_pstrdup(doc->pool, "right");
4637         }
4638       }
4639       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4640         if (STRCASEEQ('b','B',"both", cur->value)) {
4641           css_clear = apr_pstrdup(doc->pool, "both");
4642         }
4643         else if (STRCASEEQ('r','R',"right", cur->value)) {
4644           css_clear = apr_pstrdup(doc->pool, "right");
4645         }
4646         else if (STRCASEEQ('l','L',"left", cur->value)) {
4647           css_clear = apr_pstrdup(doc->pool, "left");
4648         }
4649       }
4650     }
4651   }
4652   W_L("<h2");
4653   if (attr_align || css_clear ) {
4654     W_L(" style=\"");
4655     if(attr_align){
4656       W_L("text-align:");
4657       W_V(attr_align);
4658       W_L(";");
4659     }
4660     if(css_clear){
4661       W_L("clear:");
4662       W_V(css_clear);
4663       W_L(";");
4664     }
4665     W_L("\"");
4666   }
4667   W_L(">");
4668
4669   return jxhtml->out;
4670 }
4671
4672
4673 /**
4674  * It is a handler who processes the H2 tag.
4675  *
4676  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4677  *                     destination is specified.
4678  * @param node   [i]   The H1 tag node is specified.
4679  * @return The conversion result is returned.
4680  */
4681 static char *
4682 s_jxhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
4683 {
4684   jxhtml_t*    jxhtml;
4685   Doc*          doc;
4686   request_rec*  r;
4687
4688   jxhtml = GET_JXHTML(pdoc);
4689   doc     = jxhtml->doc;
4690   r       = doc->r;
4691   
4692   W_L("</h2>");
4693   if (IS_CSS_ON(jxhtml->entryp)) {
4694     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4695   }
4696   return jxhtml->out;
4697 }
4698
4699
4700 /**
4701  * It is a handler who processes the H3 tag.
4702  *
4703  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4704  *                     destination is specified.
4705  * @param node   [i]   The H1 tag node is specified.
4706  * @return The conversion result is returned.
4707  */
4708 static char *
4709 s_jxhtml_start_h3_tag(void *pdoc, Node *node)
4710 {
4711   jxhtml_t    *jxhtml;
4712   Doc         *doc;
4713   request_rec *r;
4714   Attr        *attr;
4715   char        *attr_style = NULL;
4716   char        *attr_align = NULL;
4717   char        *css_clear  = NULL;
4718
4719   jxhtml   = GET_JXHTML(pdoc);
4720   doc     = jxhtml->doc;
4721   r       = doc->r;
4722
4723   for (attr = qs_get_attr(doc,node);
4724        attr;
4725        attr = qs_get_next_attr(doc,attr)) {
4726     char *name  = qs_get_attr_name(doc,attr);
4727     char *value = qs_get_attr_value(doc,attr);
4728     if (STRCASEEQ('a','A',"align", name)) {
4729       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4730         attr_align = value;
4731       }
4732     }
4733     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4734       attr_style = value;
4735     }
4736   }
4737   if (IS_CSS_ON(jxhtml->entryp)) {
4738     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4739     if (style) {
4740       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4741       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4742       css_property_t *cur;
4743       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4744         if (STRCASEEQ('l','L',"left", cur->value)) {
4745           attr_align = apr_pstrdup(doc->pool, "left");
4746         }
4747         else if (STRCASEEQ('c','C',"center",cur->value)) {
4748           attr_align = apr_pstrdup(doc->pool, "center");
4749         }
4750         else if (STRCASEEQ('r','R',"right",cur->value)) {
4751           attr_align = apr_pstrdup(doc->pool, "right");
4752         }
4753       }
4754       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4755         if (STRCASEEQ('b','B',"both", cur->value)) {
4756           css_clear = apr_pstrdup(doc->pool, "both");
4757         }
4758         else if (STRCASEEQ('r','R',"right", cur->value)) {
4759           css_clear = apr_pstrdup(doc->pool, "right");
4760         }
4761         else if (STRCASEEQ('l','L',"left", cur->value)) {
4762           css_clear = apr_pstrdup(doc->pool, "left");
4763         }
4764       }
4765     }
4766   }
4767   W_L("<h3");
4768   if (attr_align || css_clear ) {
4769     W_L(" style=\"");
4770     if(attr_align){
4771       W_L("text-align:");
4772       W_V(attr_align);
4773       W_L(";");
4774     }
4775     if(css_clear){
4776       W_L("clear:");
4777       W_V(css_clear);
4778       W_L(";");
4779     }
4780     W_L("\"");
4781   }
4782   W_L(">");
4783
4784   return jxhtml->out;
4785 }
4786
4787
4788 /**
4789  * It is a handler who processes the H3 tag.
4790  *
4791  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4792  *                     destination is specified.
4793  * @param node   [i]   The H1 tag node is specified.
4794  * @return The conversion result is returned.
4795  */
4796 static char *
4797 s_jxhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
4798 {
4799   jxhtml_t*    jxhtml;
4800   Doc*          doc;
4801   request_rec*  r;
4802
4803   jxhtml = GET_JXHTML(pdoc);
4804   doc     = jxhtml->doc;
4805   r       = doc->r;
4806
4807   W_L("</h3>");
4808   if (IS_CSS_ON(jxhtml->entryp)) {
4809     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4810   }
4811   return jxhtml->out;
4812 }
4813
4814
4815 /**
4816  * It is a handler who processes the H4 tag.
4817  *
4818  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4819  *                     destination is specified.
4820  * @param node   [i]   The H1 tag node is specified.
4821  * @return The conversion result is returned.
4822  */
4823 static char *
4824 s_jxhtml_start_h4_tag(void *pdoc, Node *node)
4825 {
4826   jxhtml_t    *jxhtml;
4827   Doc         *doc;
4828   request_rec *r;
4829   Attr        *attr;
4830   char        *attr_style = NULL;
4831   char        *attr_align = NULL;
4832   char        *css_clear  = NULL;
4833
4834   jxhtml   = GET_JXHTML(pdoc);
4835   doc     = jxhtml->doc;
4836   r       = doc->r;
4837
4838   for (attr = qs_get_attr(doc,node);
4839        attr;
4840        attr = qs_get_next_attr(doc,attr)) {
4841     char *name  = qs_get_attr_name(doc,attr);
4842     char *value = qs_get_attr_value(doc,attr);
4843     if (STRCASEEQ('a','A',"align", name)) {
4844       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4845         attr_align = value;
4846       }
4847     }
4848     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4849       attr_style = value;
4850     }
4851   }
4852   if (IS_CSS_ON(jxhtml->entryp)) {
4853     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4854     if (style) {
4855       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4856       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4857       css_property_t *cur;
4858       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4859         if (STRCASEEQ('l','L',"left", cur->value)) {
4860           attr_align = apr_pstrdup(doc->pool, "left");
4861         }
4862         else if (STRCASEEQ('c','C',"center",cur->value)) {
4863           attr_align = apr_pstrdup(doc->pool, "center");
4864         }
4865         else if (STRCASEEQ('r','R',"right",cur->value)) {
4866           attr_align = apr_pstrdup(doc->pool, "right");
4867         }
4868       }
4869       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4870         if (STRCASEEQ('b','B',"both", cur->value)) {
4871           css_clear = apr_pstrdup(doc->pool, "both");
4872         }
4873         else if (STRCASEEQ('r','R',"right", cur->value)) {
4874           css_clear = apr_pstrdup(doc->pool, "right");
4875         }
4876         else if (STRCASEEQ('l','L',"left", cur->value)) {
4877           css_clear = apr_pstrdup(doc->pool, "left");
4878         }
4879       }
4880     }
4881   }
4882   W_L("<h4");
4883   if (attr_align || css_clear ) {
4884     W_L(" style=\"");
4885     if(attr_align){
4886       W_L("text-align:");
4887       W_V(attr_align);
4888       W_L(";");
4889     }
4890     if(css_clear){
4891       W_L("clear:");
4892       W_V(css_clear);
4893       W_L(";");
4894     }
4895     W_L("\"");
4896   }
4897   W_L(">");
4898
4899   return jxhtml->out;
4900 }
4901
4902
4903 /**
4904  * It is a handler who processes the H4 tag.
4905  *
4906  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4907  *                     destination is specified.
4908  * @param node   [i]   The H1 tag node is specified.
4909  * @return The conversion result is returned.
4910  */
4911 static char *
4912 s_jxhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
4913 {
4914   jxhtml_t      *jxhtml;
4915   Doc           *doc;
4916   request_rec   *r;
4917
4918   jxhtml = GET_JXHTML(pdoc);
4919   doc     = jxhtml->doc;
4920   r       = doc->r;
4921   
4922   W_L("</h4>");
4923   if (IS_CSS_ON(jxhtml->entryp)) {
4924     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
4925   }
4926
4927   return jxhtml->out;
4928 }
4929
4930
4931 /**
4932  * It is a handler who processes the H5 tag.
4933  *
4934  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
4935  *                     destination is specified.
4936  * @param node   [i]   The H1 tag node is specified.
4937  * @return The conversion result is returned.
4938  */
4939 static char *
4940 s_jxhtml_start_h5_tag(void *pdoc, Node *node)
4941 {
4942   jxhtml_t    *jxhtml;
4943   Doc         *doc;
4944   request_rec *r;
4945   Attr        *attr;
4946   char        *attr_style = NULL;
4947   char        *attr_align = NULL;
4948   char        *css_clear  = NULL;
4949
4950   jxhtml   = GET_JXHTML(pdoc);
4951   doc     = jxhtml->doc;
4952   r       = doc->r;
4953
4954   for (attr = qs_get_attr(doc,node);
4955        attr;
4956        attr = qs_get_next_attr(doc,attr)) {
4957     char *name  = qs_get_attr_name(doc,attr);
4958     char *value = qs_get_attr_value(doc,attr);
4959     if (STRCASEEQ('a','A',"align", name)) {
4960       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
4961         attr_align = value;
4962       }
4963     }
4964     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4965       attr_style = value;
4966     }
4967   }
4968   if (IS_CSS_ON(jxhtml->entryp)) {
4969     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
4970     if (style) {
4971       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
4972       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
4973       css_property_t *cur;
4974       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
4975         if (STRCASEEQ('l','L',"left", cur->value)) {
4976           attr_align = apr_pstrdup(doc->pool, "left");
4977         }
4978         else if (STRCASEEQ('c','C',"center",cur->value)) {
4979           attr_align = apr_pstrdup(doc->pool, "center");
4980         }
4981         else if (STRCASEEQ('r','R',"right",cur->value)) {
4982           attr_align = apr_pstrdup(doc->pool, "right");
4983         }
4984       }
4985       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
4986         if (STRCASEEQ('b','B',"both", cur->value)) {
4987           css_clear = apr_pstrdup(doc->pool, "both");
4988         }
4989         else if (STRCASEEQ('r','R',"right", cur->value)) {
4990           css_clear = apr_pstrdup(doc->pool, "right");
4991         }
4992         else if (STRCASEEQ('l','L',"left", cur->value)) {
4993           css_clear = apr_pstrdup(doc->pool, "left");
4994         }
4995       }
4996     }
4997   }
4998   W_L("<h5");
4999   if (attr_align || css_clear ) {
5000     W_L(" style=\"");
5001     if(attr_align){
5002       W_L("text-align:");
5003       W_V(attr_align);
5004       W_L(";");
5005     }
5006     if(css_clear){
5007       W_L("clear:");
5008       W_V(css_clear);
5009       W_L(";");
5010     }
5011     W_L("\"");
5012   }
5013   W_L(">");
5014
5015   return jxhtml->out;
5016 }
5017
5018
5019 /**
5020  * It is a handler who processes the H5 tag.
5021  *
5022  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5023  *                     destination is specified.
5024  * @param node   [i]   The H1 tag node is specified.
5025  * @return The conversion result is returned.
5026  */
5027 static char *
5028 s_jxhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
5029 {
5030   jxhtml_t    *jxhtml;
5031   Doc         *doc;
5032   request_rec *r;
5033
5034   jxhtml = GET_JXHTML(pdoc);
5035   doc     = jxhtml->doc;
5036   r       = doc->r;
5037   
5038   W_L("</h5>");
5039   if (IS_CSS_ON(jxhtml->entryp)) {
5040     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5041   }
5042
5043   return jxhtml->out;
5044 }
5045
5046
5047 /**
5048  * It is a handler who processes the H6 tag.
5049  *
5050  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5051  *                     destination is specified.
5052  * @param node   [i]   The H1 tag node is specified.
5053  * @return The conversion result is returned.
5054  */
5055 static char *
5056 s_jxhtml_start_h6_tag(void *pdoc, Node *node)
5057 {
5058   jxhtml_t    *jxhtml;
5059   Doc         *doc;
5060   request_rec *r;
5061   Attr        *attr;
5062   char        *attr_style = NULL;
5063   char        *attr_align = NULL;
5064   char        *css_clear  = NULL;
5065
5066   jxhtml   = GET_JXHTML(pdoc);
5067   doc     = jxhtml->doc;
5068   r       = doc->r;
5069
5070   for (attr = qs_get_attr(doc,node);
5071        attr;
5072        attr = qs_get_next_attr(doc,attr)) {
5073     char *name  = qs_get_attr_name(doc,attr);
5074     char *value = qs_get_attr_value(doc,attr);
5075     if (STRCASEEQ('a','A',"align", name)) {
5076       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
5077         attr_align = value;
5078       }
5079     }
5080     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5081       attr_style = value;
5082     }
5083   }
5084   if (IS_CSS_ON(jxhtml->entryp)) {
5085     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
5086     if (style) {
5087       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
5088       css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
5089       css_property_t *cur;
5090       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5091         if (STRCASEEQ('l','L',"left", cur->value)) {
5092           attr_align = apr_pstrdup(doc->pool, "left");
5093         }
5094         else if (STRCASEEQ('c','C',"center",cur->value)) {
5095           attr_align = apr_pstrdup(doc->pool, "center");
5096         }
5097         else if (STRCASEEQ('r','R',"right",cur->value)) {
5098           attr_align = apr_pstrdup(doc->pool, "right");
5099         }
5100       }
5101       for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
5102         if (STRCASEEQ('b','B',"both", cur->value)) {
5103           css_clear = apr_pstrdup(doc->pool, "both");
5104         }
5105         else if (STRCASEEQ('r','R',"right", cur->value)) {
5106           css_clear = apr_pstrdup(doc->pool, "right");
5107         }
5108         else if (STRCASEEQ('l','L',"left", cur->value)) {
5109           css_clear = apr_pstrdup(doc->pool, "left");
5110         }
5111       }
5112     }
5113   }
5114   W_L("<h6");
5115   if (attr_align || css_clear ) {
5116     W_L(" style=\"");
5117     if(attr_align){
5118       W_L("text-align:");
5119       W_V(attr_align);
5120       W_L(";");
5121     }
5122     if(css_clear){
5123       W_L("clear:");
5124       W_V(css_clear);
5125       W_L(";");
5126     }
5127     W_L("\"");
5128   }
5129   W_L(">");
5130
5131   return jxhtml->out;
5132 }
5133
5134
5135 /**
5136  * It is a handler who processes the H6 tag.
5137  *
5138  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5139  *                     destination is specified.
5140  * @param node   [i]   The H1 tag node is specified.
5141  * @return The conversion result is returned.
5142  */
5143 static char *
5144 s_jxhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
5145 {
5146   jxhtml_t    *jxhtml;
5147   Doc         *doc;
5148   request_rec *r;
5149
5150   jxhtml = GET_JXHTML(pdoc);
5151   doc     = jxhtml->doc;
5152   r       = doc->r;
5153   
5154   W_L("</h6>");
5155   if (IS_CSS_ON(jxhtml->entryp)) {
5156     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5157   }
5158
5159   return jxhtml->out;
5160 }
5161
5162
5163 /**
5164  * It is a handler who processes the MENU tag.
5165  *
5166  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5167  *                     destination is specified.
5168  * @param node   [i]   The MENU tag node is specified.
5169  * @return The conversion result is returned.
5170  */
5171 static char *
5172 s_jxhtml_start_menu_tag(void *pdoc, Node *node)
5173 {
5174   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5175   Doc       *doc        = jxhtml->doc;
5176   Attr      *attr;
5177   char      *attr_style = NULL;
5178   char      *attr_color = NULL;
5179   char      *attr_type  = NULL;
5180   char      *attr_size  = NULL;
5181   for (attr = qs_get_attr(doc,node);
5182        attr;
5183        attr = qs_get_next_attr(doc,attr)) {
5184     char *name   = qs_get_attr_name(doc,attr);
5185     char *value  = qs_get_attr_value(doc,attr);
5186     if (STRCASEEQ('t','T',"type",name)) {
5187       if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
5188         attr_type = value;
5189       }
5190     }
5191     else if (STRCASEEQ('s','S',"style", name) && value && *value) {
5192       attr_style = value;
5193     }
5194   }
5195   if (IS_CSS_ON(jxhtml->entryp)) {
5196     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
5197     if (style) {
5198       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5199       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5200       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
5201       css_property_t *cur;
5202       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5203         if (cur->value && *cur->value) {
5204           attr_color = apr_pstrdup(doc->pool, cur->value);
5205         }
5206       }
5207       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
5208         if (cur->value && *cur->value) {
5209           attr_type = apr_pstrdup(doc->pool, cur->value);
5210         }
5211       }
5212       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5213         if (cur->value && *cur->value) {
5214           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5215             attr_size = apr_pstrdup(doc->pool, cur->value);
5216           }
5217           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5218             attr_size = apr_pstrdup(doc->pool, cur->value);
5219           }
5220           else if (STRCASEEQ('s','S',"small",cur->value)) {
5221             attr_size = apr_pstrdup(doc->pool, cur->value);
5222           }
5223           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5224             attr_size = apr_pstrdup(doc->pool, cur->value);
5225           }
5226           else if (STRCASEEQ('l','L',"large",cur->value)) {
5227             attr_size = apr_pstrdup(doc->pool, cur->value);
5228           }
5229           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5230             attr_size = apr_pstrdup(doc->pool, cur->value);
5231           }
5232           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5233             attr_size = apr_pstrdup(doc->pool, cur->value);
5234           }
5235         }
5236       }
5237     }
5238   }
5239   W_L("<menu");
5240   if (attr_type || attr_color || attr_size) {
5241     W_L(" style=\"");
5242     if (attr_type) {
5243       W_L("list-style-type:");
5244       W_V(attr_type);
5245       W_L(";");
5246     }
5247     if (attr_color) {
5248       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5249       W_L("color:");
5250       W_V(attr_color);
5251       W_L(";");
5252     }
5253     if (attr_size) {
5254       W_L("font-size:");
5255       W_V(attr_size);
5256       W_L(";");
5257     }
5258     W_L("\"");
5259   }
5260   W_L(">");
5261   return jxhtml->out;
5262 }
5263
5264
5265 /**
5266  * It is a handler who processes the MENU tag.
5267  *
5268  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5269  *                     destination is specified.
5270  * @param node   [i]   The MENU tag node is specified.
5271  * @return The conversion result is returned.
5272  */
5273 static char *
5274 s_jxhtml_end_menu_tag(void *pdoc, Node *UNUSED(child))
5275 {
5276   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5277   Doc *doc = jxhtml->doc;
5278   W_L("</menu>");
5279   if (IS_CSS_ON(jxhtml->entryp)) {
5280     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5281   }
5282   return jxhtml->out;
5283 }
5284
5285
5286 /**
5287  * It is a handler who processes the PLAINTEXT tag.
5288  *
5289  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5290  *                     destination is specified.
5291  * @param node   [i]   The PLAINTEXT tag node is specified.
5292  * @return The conversion result is returned.
5293  */
5294 static char *
5295 s_jxhtml_start_plaintext_tag(void *pdoc, Node *node)
5296 {
5297   jxhtml_t *jxhtml;
5298   Doc *doc;
5299
5300   jxhtml = GET_JXHTML(pdoc);
5301   doc     = jxhtml->doc;
5302   W_L("<plaintext>");
5303   s_jxhtml_start_plaintext_tag_inner(pdoc,node);
5304   return jxhtml->out;
5305 }
5306
5307 static char *
5308 s_jxhtml_start_plaintext_tag_inner(void *pdoc, Node *node)
5309 {
5310   jxhtml_t *jxhtml;
5311   Doc *doc;
5312   Node *child;
5313   jxhtml = GET_JXHTML(pdoc);
5314   doc     = jxhtml->doc;
5315   for (child = qs_get_child_node(doc, node);
5316        child;
5317        child = qs_get_next_node(doc, child)) {
5318     W_V(child->otext);
5319     s_jxhtml_start_plaintext_tag_inner(pdoc, child);
5320   }
5321   return jxhtml->out;
5322 }
5323
5324
5325 /**
5326  * It is a handler who processes the PLAINTEXT tag.
5327  *
5328  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5329  *                     destination is specified.
5330  * @param node   [i]   The PLAINTEXT tag node is specified.
5331  * @return The conversion result is returned.
5332  */
5333 static char *
5334 s_jxhtml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
5335 {
5336   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5337   return jxhtml->out;
5338 }
5339
5340
5341 /**
5342  * It is a handler who processes the BLINK tag.
5343  *
5344  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5345  *                     destination is specified.
5346  * @param node   [i]   The BLINK tag node is specified.
5347  * @return The conversion result is returned.
5348  */
5349 static char *
5350 s_jxhtml_start_blink_tag(void *pdoc, Node *node)
5351 {
5352   jxhtml_t *jxhtml      = GET_JXHTML(pdoc);
5353   Doc       *doc        = jxhtml->doc;
5354   Attr      *attr;
5355   char      *attr_style = NULL;
5356   char      *attr_color = NULL;
5357   char      *attr_size  = NULL;
5358   for (attr = qs_get_attr(doc,node);
5359        attr;
5360        attr = qs_get_next_attr(doc,attr)) {
5361     char *name   = qs_get_attr_name(doc,attr);
5362     char *value  = qs_get_attr_value(doc,attr);
5363     if (STRCASEEQ('s','S',"style", name) && value && *value) {
5364       attr_style = value;
5365     }
5366   }
5367   if (IS_CSS_ON(jxhtml->entryp)) {
5368     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
5369     if (style) {
5370       css_property_t *color_prop           = chxj_css_get_property_value(doc, style, "color");
5371       css_property_t *size_prop            = chxj_css_get_property_value(doc, style, "font-size");
5372       css_property_t *cur;
5373       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5374         if (cur->value && *cur->value) {
5375           attr_color = apr_pstrdup(doc->pool, cur->value);
5376         }
5377       }
5378       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5379         if (cur->value && *cur->value) {
5380           if (STRCASEEQ('x','X',"xx-small",cur->value)) {
5381             attr_size = apr_pstrdup(doc->pool, cur->value);
5382           }
5383           else if (STRCASEEQ('x','X',"x-small",cur->value)) {
5384             attr_size = apr_pstrdup(doc->pool, cur->value);
5385           }
5386           else if (STRCASEEQ('s','S',"small",cur->value)) {
5387             attr_size = apr_pstrdup(doc->pool, cur->value);
5388           }
5389           else if (STRCASEEQ('m','M',"medium",cur->value)) {
5390             attr_size = apr_pstrdup(doc->pool, cur->value);
5391           }
5392           else if (STRCASEEQ('l','L',"large",cur->value)) {
5393             attr_size = apr_pstrdup(doc->pool, cur->value);
5394           }
5395           else if (STRCASEEQ('x','X',"x-large",cur->value)) {
5396             attr_size = apr_pstrdup(doc->pool, cur->value);
5397           }
5398           else if (STRCASEEQ('x','X',"xx-large",cur->value)) {
5399             attr_size = apr_pstrdup(doc->pool, cur->value);
5400           }
5401         }
5402       }
5403     }
5404   }
5405   W_L("<blink");
5406   if (attr_color || attr_size) {
5407     W_L(" style=\"");
5408     if (attr_color) {
5409       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5410       W_L("color:");
5411       W_V(attr_color);
5412       W_L(";");
5413     }
5414     if (attr_size) {
5415       W_L("font-size:");
5416       W_V(attr_size);
5417       W_L(";");
5418     }
5419     W_L("\"");
5420   }
5421   W_L(">");
5422   return jxhtml->out;
5423 }
5424
5425
5426 /**
5427  * It is a handler who processes the BLINK tag.
5428  *
5429  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5430  *                     destination is specified.
5431  * @param node   [i]   The BLINK tag node is specified.
5432  * @return The conversion result is returned.
5433  */
5434 static char *
5435 s_jxhtml_end_blink_tag(void *pdoc, Node *UNUSED(child))
5436 {
5437   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5438   Doc      *doc = jxhtml->doc;
5439   W_L("</blink>");
5440   if (IS_CSS_ON(jxhtml->entryp)) {
5441     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5442   }
5443   return jxhtml->out;
5444 }
5445
5446
5447 /**
5448  * It is a handler who processes the MARQUEE tag.
5449  *
5450  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5451  *                     destination is specified.
5452  * @param node   [i]   The MARQUEE tag node is specified.
5453  * @return The conversion result is returned.
5454  */
5455 static char *
5456 s_jxhtml_start_marquee_tag(void *pdoc, Node *node)
5457 {
5458   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5459   Doc       *doc = jxhtml->doc;
5460   Attr      *attr;
5461   char      *attr_direction = NULL;
5462   char      *attr_style     = NULL;
5463   char      *attr_color     = NULL;
5464   char      *attr_size      = NULL;
5465   char      *attr_bgcolor   = NULL;
5466   /*--------------------------------------------------------------------------*/
5467   /* Get Attributes                                                           */
5468   /*--------------------------------------------------------------------------*/
5469   for (attr = qs_get_attr(doc,node);
5470        attr;
5471        attr = qs_get_next_attr(doc,attr)) {
5472     char *name   = qs_get_attr_name(doc,attr);
5473     char *value  = qs_get_attr_value(doc,attr);
5474     if (STRCASEEQ('d','D',"direction", name)) {
5475       if (value) {
5476         if (STRCASEEQ('l','L',"left",value)) {
5477           attr_direction = "rtl";
5478         }
5479         else if (STRCASEEQ('r','R',"right",value)) {
5480           attr_direction = "ltr";
5481         }
5482       }
5483     }
5484     else if (STRCASEEQ('b','B',"behavior",name)) {
5485       /* ignore */
5486     }
5487     else if (STRCASEEQ('l','L',"loop",name)) {
5488       /* ignore */
5489     }
5490     else if (STRCASEEQ('b','B',"bgcolor",name)) {
5491       if (value && *value) {
5492         attr_bgcolor = value;
5493       }
5494     }
5495     else if (STRCASEEQ('s','S',"style",name) && value && *value) {
5496       attr_style = value;
5497     }
5498   }
5499   if (IS_CSS_ON(jxhtml->entryp)) {
5500     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
5501     if (style) {
5502       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5503       css_property_t *size_prop  = chxj_css_get_property_value(doc, style, "font-size");
5504       css_property_t *bgcolor_prop  = chxj_css_get_property_value(doc, style, "background-color");
5505       css_property_t *direction_prop  = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5506       css_property_t *cur;
5507       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5508         if (cur->value && *cur->value) {
5509           attr_color = apr_pstrdup(doc->pool, cur->value);
5510         }
5511       }
5512       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
5513         if (cur->value && *cur->value) {
5514           attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
5515         }
5516       }
5517       for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
5518         if (cur->value && *cur->value) {
5519           attr_direction = apr_pstrdup(doc->pool, cur->value);
5520         }
5521       }
5522       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5523         if (cur->value && *cur->value) {
5524           if ( STRCASEEQ('x','X',"xx-small",cur->value)
5525             || STRCASEEQ('x','X',"x-small", cur->value)
5526             || STRCASEEQ('s','S',"small",   cur->value)
5527             || STRCASEEQ('m','M',"medium",  cur->value)
5528             || STRCASEEQ('l','L',"large",   cur->value)
5529             || STRCASEEQ('x','X',"x-large", cur->value)
5530             || STRCASEEQ('x','X',"xx-large",cur->value)) {
5531             attr_size = apr_pstrdup(doc->pool, cur->value);
5532           }
5533         }
5534       }
5535     }
5536   }
5537   W_L("<marquee");
5538   if (attr_color || attr_size || attr_direction || attr_bgcolor) {
5539     W_L(" style=\"");
5540     if (attr_direction) {
5541       W_L("-wap-marquee-dir:");
5542       W_V(attr_direction);
5543       W_L(";");
5544     }
5545     if (attr_bgcolor) {
5546       attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
5547       W_L("background-color:");
5548       W_V(attr_bgcolor);
5549       W_L(";");
5550     }
5551     if (attr_color) {
5552       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5553       W_L("color:");
5554       W_V(attr_color);
5555       W_L(";");
5556     }
5557     if (attr_size) {
5558       W_L("font-size:");
5559       W_V(attr_size);
5560       W_L(";");
5561     }
5562     W_L("\"");
5563   }
5564   W_L(">");
5565
5566   return jxhtml->out;
5567 }
5568
5569
5570 /**
5571  * It is a handler who processes the MARQUEE tag.
5572  *
5573  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5574  *                     destination is specified.
5575  * @param node   [i]   The MARQUEE tag node is specified.
5576  * @return The conversion result is returned.
5577  */
5578 static char *
5579 s_jxhtml_end_marquee_tag(void *pdoc, Node *UNUSED(node))
5580 {
5581   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5582   Doc      *doc     = jxhtml->doc;
5583   W_L("</marquee>");
5584   if (IS_CSS_ON(jxhtml->entryp)) {
5585     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5586   }
5587   return jxhtml->out;
5588 }
5589
5590
5591 /**
5592  * It is handler who processes the New Line Code.
5593  */
5594 static char *
5595 s_jxhtml_newline_mark(void *pdoc, Node *UNUSED(node))
5596 {
5597   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5598   if (jxhtml->start_html_flag) {
5599     Doc *doc = jxhtml->doc;
5600     W_NLCODE();
5601   }
5602   return jxhtml->out;
5603 }
5604
5605
5606 /**
5607  * It is a handler who processes the LINK tag.
5608  *
5609  * @param pdoc  [i/o] The pointer to the JXHTML structure at the output
5610  *                     destination is specified.
5611  * @param node   [i]   The LINK tag node is specified.
5612  * @return The conversion result is returned.
5613  */
5614 static char *
5615 s_jxhtml_link_tag(void *pdoc, Node *node)
5616 {
5617   jxhtml_t      *jxhtml;
5618   Doc           *doc;
5619   Attr          *attr;
5620   char          *rel  = NULL;
5621   char          *href = NULL;
5622   char          *type = NULL;
5623
5624   jxhtml = GET_JXHTML(pdoc);
5625   doc    = jxhtml->doc;
5626
5627   if (! IS_CSS_ON(jxhtml->entryp)) {
5628     return jxhtml->out;
5629   }
5630
5631   for (attr = qs_get_attr(doc,node);
5632        attr;
5633        attr = qs_get_next_attr(doc,attr)) {
5634     char *name  = qs_get_attr_name(doc,attr);
5635     char *value = qs_get_attr_value(doc,attr);
5636     if (STRCASEEQ('r','R',"rel", name)) {
5637       if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
5638         rel = value;
5639       }
5640     }
5641     else if (STRCASEEQ('h','H',"href", name)) {
5642       if (value && *value) {
5643         href = value;
5644       }
5645     }
5646     else if (STRCASEEQ('t','T',"type", name)) {
5647       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5648         type = value;
5649       }
5650     }
5651   }
5652
5653   if (rel && href && type) {
5654     DBG(doc->r, "start load CSS. url:[%s]", href);
5655     jxhtml->style = chxj_css_parse_from_uri(doc->r, doc->pool, jxhtml->style, href);
5656     DBG(doc->r, "end load CSS. url:[%s]", href);
5657   }
5658
5659   return jxhtml->out;
5660 }
5661
5662
5663 static css_prop_list_t *
5664 s_jxhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5665 {
5666   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5667   Doc *doc = jxhtml->doc;
5668   css_prop_list_t *last_css = NULL;
5669   if (IS_CSS_ON(jxhtml->entryp)) {
5670     css_prop_list_t *dup_css;
5671     css_selector_t  *selector;
5672
5673     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
5674     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5675     selector = chxj_css_find_selector(doc, jxhtml->style, node);
5676     if (selector) {
5677       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5678     }
5679     chxj_css_push_prop_list(jxhtml->css_prop_stack, dup_css);
5680     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
5681
5682     if (style_attr_value) {
5683       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));
5684       if (ssheet) {
5685         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5686       }
5687     }
5688   }
5689   return last_css;
5690 }
5691
5692
5693 static css_prop_list_t *
5694 s_jxhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5695 {
5696   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5697   Doc *doc = jxhtml->doc;
5698   css_prop_list_t *last_css = NULL;
5699   if (IS_CSS_ON(jxhtml->entryp)) {
5700     css_prop_list_t *dup_css;
5701     css_selector_t  *selector;
5702
5703     last_css = chxj_css_get_last_prop_list(jxhtml->css_prop_stack);
5704     dup_css  = chxj_dup_css_prop_list(doc, last_css);
5705     selector = chxj_css_find_selector(doc, jxhtml->style, node);
5706     if (selector) {
5707       chxj_css_prop_list_merge_property(doc, dup_css, selector);
5708     }
5709     last_css = dup_css;
5710
5711     if (style_attr_value) {
5712       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));
5713       if (ssheet) {
5714         chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5715       }
5716     }
5717   }
5718   return last_css;
5719 }
5720
5721
5722 /**
5723  * It is a handler who processes the SPAN tag.
5724  *
5725  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5726  *                     destination is specified.
5727  * @param node   [i]   The SPAN tag node is specified.
5728  * @return The conversion result is returned.
5729  */
5730 static char *
5731 s_jxhtml_start_span_tag(void *pdoc, Node *node)
5732 {
5733   jxhtml_t *jxhtml;
5734   Doc *doc;
5735   Attr *attr;
5736   char *attr_style = NULL;
5737   char *attr_color = NULL;
5738   char *attr_size = NULL;
5739   char *attr_align = NULL;
5740   char *attr_blink = NULL;
5741   char *attr_marquee = NULL;
5742   char *attr_marquee_dir = NULL;
5743   char *attr_marquee_style = NULL;
5744   char *attr_marquee_loop = NULL;
5745   char *css_bgcolor        = NULL;
5746
5747   jxhtml = GET_JXHTML(pdoc);
5748   doc     = jxhtml->doc;
5749
5750   for (attr = qs_get_attr(doc,node);
5751        attr;
5752        attr = qs_get_next_attr(doc,attr)) {
5753     char *nm  = qs_get_attr_name(doc,attr);
5754     char *val = qs_get_attr_value(doc,attr);
5755     if (val && STRCASEEQ('s','S',"style", nm)) {
5756       attr_style = val;
5757     }
5758   }
5759   if (IS_CSS_ON(jxhtml->entryp)) {
5760     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
5761     if (style) {
5762       css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5763       css_property_t *size_prop = chxj_css_get_property_value(doc, style, "font-size");
5764       css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
5765       css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
5766       css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
5767       css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5768       css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5769       css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5770       css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
5771       
5772       css_property_t *cur;
5773       for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5774         attr_color = apr_pstrdup(doc->pool, cur->value);
5775       }
5776       for (cur = size_prop->next; cur != size_prop; cur = cur->next) {
5777         if (cur->value && *cur->value) {
5778           if ( STRCASEEQ('x','X',"xx-small",cur->value)
5779             || STRCASEEQ('x','X',"x-small", cur->value)
5780             || STRCASEEQ('s','S',"small",   cur->value)
5781             || STRCASEEQ('m','M',"medium",  cur->value)
5782             || STRCASEEQ('l','L',"large",   cur->value)
5783             || STRCASEEQ('x','X',"x-large", cur->value)
5784             || STRCASEEQ('x','X',"xx-large",cur->value)) {
5785             attr_size = apr_pstrdup(doc->pool, cur->value);
5786           }
5787         }
5788       }
5789       for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
5790         if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
5791           attr_blink = apr_pstrdup(doc->pool, cur->value);
5792         }
5793       }
5794       for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
5795         if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
5796           attr_marquee = apr_pstrdup(doc->pool, cur->value);
5797         }
5798       }
5799       for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
5800         if (cur->value && *cur->value) {
5801           if ( STRCASEEQ('l','L',"ltr",cur->value)
5802             || STRCASEEQ('r','R',"rtl",cur->value)) {
5803             attr_marquee_dir = apr_pstrdup(doc->pool, cur->value);
5804           }
5805         }
5806       }
5807       for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
5808         if (cur->value && *cur->value) {
5809           if ( STRCASEEQ('s','S',"scroll",cur->value)
5810             || STRCASEEQ('s','S',"slide",cur->value)
5811             || STRCASEEQ('a','A',"alternate",cur->value)) {
5812             attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
5813           }
5814         }
5815       }
5816       for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
5817         if (cur->value && *cur->value) {
5818           if(strcmp(cur->value,"0") == 0 || strcmp(cur->value,"-1") == 0){
5819             attr_marquee_loop = "infinite";
5820           }
5821           else{
5822             attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
5823           }
5824         }
5825       }
5826       for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
5827         if (STRCASEEQ('l','L',"left", cur->value)) {
5828           attr_align = apr_pstrdup(doc->pool, "left");
5829         }
5830         else if (STRCASEEQ('c','C',"center",cur->value)) {
5831           attr_align = apr_pstrdup(doc->pool, "center");
5832         }
5833         else if (STRCASEEQ('r','R',"right",cur->value)) {
5834           attr_align = apr_pstrdup(doc->pool, "right");
5835         }
5836       }
5837       for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
5838         if (cur->value && *cur->value) {
5839           css_bgcolor = apr_pstrdup(doc->pool, cur->value);
5840         }
5841       }
5842     }
5843   }
5844
5845   W_L("<span");
5846   if (attr_color || attr_size || attr_align || attr_blink || attr_marquee || css_bgcolor) {
5847     W_L(" style=\"");
5848     if (attr_color) {
5849       attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5850       W_L("color:");
5851       W_V(attr_color);
5852       W_L(";");
5853     }
5854     if (attr_size) {
5855       W_L("font-size:");
5856       W_V(attr_size);
5857       W_L(";");
5858     }
5859     if (attr_align) {
5860       W_L("text-align:");
5861       W_V(attr_align);
5862       W_L(";");
5863     }
5864     if (attr_blink) {
5865       W_L("text-decoration:");
5866       W_V("blink");
5867       W_L(";");
5868     }
5869     if (attr_marquee) {
5870       W_L("display:-wap-marquee;");
5871       if (attr_marquee_dir) {
5872         W_L("-wap-marquee-dir:");
5873         W_V(attr_marquee_dir);
5874         W_L(";");
5875       }
5876       if (attr_marquee_style) {
5877         W_L("-wap-marquee-style:");
5878         W_V(attr_marquee_style);
5879         W_L(";");
5880       }
5881       if (attr_marquee_loop) {
5882         W_L("-wap-marquee-loop:");
5883         W_V(attr_marquee_loop);
5884         W_L(";");
5885       }
5886     }
5887     if(css_bgcolor){
5888       W_L("background-color:");
5889       W_V(css_bgcolor);
5890       W_L(";");
5891     }
5892     W_L("\"");
5893   }
5894   W_L(">");
5895   return jxhtml->out;
5896 }
5897
5898
5899 /**
5900  * It is a handler who processes the SPAN tag.
5901  *
5902  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
5903  *                     destination is specified.
5904  * @param node   [i]   The SPAN tag node is specified.
5905  * @return The conversion result is returned.
5906  */
5907 static char *
5908 s_jxhtml_end_span_tag(void *pdoc, Node *UNUSED(node))
5909 {
5910   jxhtml_t *jxhtml = GET_JXHTML(pdoc);
5911   Doc *doc = jxhtml->doc;
5912
5913   W_L("</span>");
5914   if (IS_CSS_ON(jxhtml->entryp)) {
5915     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
5916   }
5917   return jxhtml->out;
5918 }
5919
5920
5921 /**
5922  * It is a handler who processes the STYLE tag.
5923  *
5924  * @param pdoc  [i/o] The pointer to the SoftBank XHTML structure at the output
5925  *                     destination is specified.
5926  * @param node   [i]   The STYLE tag node is specified.
5927  * @return The conversion result is returned.
5928  */
5929 static char *
5930 s_jxhtml_style_tag(void *pdoc, Node *node)
5931 {
5932   jxhtml_t     *jxhtml;
5933   Doc           *doc;
5934   Attr          *attr;
5935   char          *type = NULL;
5936
5937   jxhtml = GET_JXHTML(pdoc);
5938   doc     = jxhtml->doc;
5939
5940   if (! IS_CSS_ON(jxhtml->entryp)) {
5941     return jxhtml->out;
5942   }
5943
5944   for (attr = qs_get_attr(doc,node);
5945        attr;
5946        attr = qs_get_next_attr(doc,attr)) {
5947     char *name  = qs_get_attr_name(doc,attr);
5948     char *value = qs_get_attr_value(doc,attr);
5949     if (STRCASEEQ('t','T',"type", name)) {
5950       if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5951         type = value;
5952       }
5953     }
5954   }
5955
5956   Node *child = qs_get_child_node(doc, node);
5957   if (type && child) {
5958     char *name  = qs_get_node_name(doc, child);
5959     if (STRCASEEQ('t','T',"text", name)) {
5960       char *value = qs_get_node_value(doc, child);
5961       DBG(doc->r, "start load CSS. buf:[%s]", value);
5962       jxhtml->style = chxj_css_parse_style_value(doc, jxhtml->style, value);
5963       DBG(doc->r, "end load CSS. value:[%s]", value);
5964     }
5965   }
5966   return jxhtml->out;
5967 }
5968 /*
5969  * vim:ts=2 et
5970  */