OSDN Git Service

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