OSDN Git Service

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