OSDN Git Service

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