OSDN Git Service

* Added test code of the <li> tag for SoftBank HTML converter.
[modchxj/mod_chxj.git] / src / chxj_jhtml.c
1 /*
2  * Copyright (C) 2005-2008 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_jhtml.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
26
27 #define GET_JHTML(X) ((jhtml_t *)(X))
28 #undef W_L
29 #undef W_V
30 #define W_L(X)          do { jhtml->out = BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, (X)); } while(0)
31 #define W_V(X)          do { jhtml->out = (X) ? BUFFERED_WRITE_VALUE(jhtml->out, &doc->buf, (X))  \
32                                                : BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, ""); } while(0)
33
34 static char *s_jhtml_start_html_tag     (void *pdoc, Node *node);
35 static char *s_jhtml_end_html_tag       (void *pdoc, Node *node);
36 static char *s_jhtml_start_meta_tag     (void *pdoc, Node *node);
37 static char *s_jhtml_end_meta_tag       (void *pdoc, Node *node);
38 static char *s_jhtml_start_head_tag     (void *pdoc, Node *node);
39 static char *s_jhtml_end_head_tag       (void *pdoc, Node *node);
40 static char *s_jhtml_start_title_tag    (void *pdoc, Node *node);
41 static char *s_jhtml_end_title_tag      (void *pdoc, Node *node);
42 static char *s_jhtml_start_base_tag     (void *pdoc, Node *node);
43 static char *s_jhtml_end_base_tag       (void *pdoc, Node *node);
44 static char *s_jhtml_start_body_tag     (void *pdoc, Node *node);
45 static char *s_jhtml_end_body_tag       (void *pdoc, Node *node);
46 static char *s_jhtml_start_a_tag        (void *pdoc, Node *node);
47 static char *s_jhtml_end_a_tag          (void *pdoc, Node *node);
48 static char *s_jhtml_start_pre_tag      (void *pdoc, Node *node);
49 static char *s_jhtml_end_pre_tag        (void *pdoc, Node *node);
50 static char *s_jhtml_start_p_tag        (void *pdoc, Node *node);
51 static char *s_jhtml_end_p_tag          (void *pdoc, Node *node);
52 static char *s_jhtml_start_ul_tag       (void *pdoc, Node *node);
53 static char *s_jhtml_end_ul_tag         (void *pdoc, Node *node);
54 static char *s_jhtml_start_ol_tag       (void *pdoc, Node *node);
55 static char *s_jhtml_end_ol_tag         (void *pdoc, Node *node);
56 static char *s_jhtml_start_li_tag       (void *pdoc, Node *node);
57 static char *s_jhtml_end_li_tag         (void *pdoc, Node *node);
58 static char *s_jhtml_start_br_tag       (void *pdoc, Node *node);
59 static char *s_jhtml_end_br_tag         (void *pdoc, Node *node);
60 static char *s_jhtml_start_tr_tag       (void *pdoc, Node *node);
61 static char *s_jhtml_end_tr_tag         (void *pdoc, Node *node);
62 static char *s_jhtml_start_font_tag     (void *pdoc, Node *node);
63 static char *s_jhtml_end_font_tag       (void *pdoc, Node *node);
64 static char *s_jhtml_start_form_tag     (void *pdoc, Node *node);
65 static char *s_jhtml_end_form_tag       (void *pdoc, Node *node);
66 static char *s_jhtml_start_input_tag    (void *pdoc, Node *node);
67 static char *s_jhtml_end_input_tag      (void *pdoc, Node *node);
68 static char *s_jhtml_start_center_tag   (void *pdoc, Node *node);
69 static char *s_jhtml_end_center_tag     (void *pdoc, Node *node);
70 static char *s_jhtml_start_hr_tag       (void *pdoc, Node *node);
71 static char *s_jhtml_end_hr_tag         (void *pdoc, Node *node);
72 static char *s_jhtml_start_img_tag      (void *pdoc, Node *node);
73 static char *s_jhtml_end_img_tag        (void *pdoc, Node *node);
74 static char *s_jhtml_start_select_tag   (void *pdoc, Node *node);
75 static char *s_jhtml_end_select_tag     (void *pdoc, Node *node);
76 static char *s_jhtml_start_option_tag   (void *pdoc, Node *node);
77 static char *s_jhtml_end_option_tag     (void *pdoc, Node *node);
78 static char *s_jhtml_start_div_tag      (void *pdoc, Node *node);
79 static char *s_jhtml_end_div_tag        (void *pdoc, Node *node);
80 static char *s_jhtml_start_textarea_tag (void *pdoc, Node *node);
81 static char *s_jhtml_end_textarea_tag   (void *pdoc, Node *node);
82 static char *s_jhtml_start_b_tag        (void *pdoc, Node *node);
83 static char *s_jhtml_end_b_tag          (void *pdoc, Node *node);
84 static char *s_jhtml_chxjif_tag         (void *pdoc, Node *node); 
85 static char *s_jhtml_text_tag           (void *pdoc, Node *node);
86 static char *s_jhtml_start_blockquote_tag(void *pdoc, Node *node);
87 static char *s_jhtml_end_blockquote_tag  (void *pdoc, Node *node);
88 static char *s_jhtml_start_dir_tag      (void *pdoc, Node *node);
89 static char *s_jhtml_end_dir_tag        (void *pdoc, Node *node);
90 static char *s_jhtml_start_dl_tag       (void *pdoc, Node *node);
91 static char *s_jhtml_end_dl_tag         (void *pdoc, Node *node);
92 static char *s_jhtml_start_dt_tag       (void *pdoc, Node *node);
93 static char *s_jhtml_end_dt_tag         (void *pdoc, Node *node);
94 static char *s_jhtml_start_dd_tag       (void *pdoc, Node *node);
95 static char *s_jhtml_end_dd_tag         (void *pdoc, Node *node);
96 static char *s_jhtml_start_h1_tag       (void *pdoc, Node *node);
97 static char *s_jhtml_end_h1_tag         (void *pdoc, Node *node);
98 static char *s_jhtml_start_h2_tag       (void *pdoc, Node *node);
99 static char *s_jhtml_end_h2_tag         (void *pdoc, Node *node);
100 static char *s_jhtml_start_h3_tag       (void *pdoc, Node *node);
101 static char *s_jhtml_end_h3_tag         (void *pdoc, Node *node);
102 static char *s_jhtml_start_h4_tag       (void *pdoc, Node *node);
103 static char *s_jhtml_end_h4_tag         (void *pdoc, Node *node);
104 static char *s_jhtml_start_h5_tag       (void *pdoc, Node *node);
105 static char *s_jhtml_end_h5_tag         (void *pdoc, Node *node);
106 static char *s_jhtml_start_h6_tag       (void *pdoc, Node *node);
107 static char *s_jhtml_end_h6_tag         (void *pdoc, Node *node);
108
109 static void  s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec);
110
111 static int   s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt);
112
113 static char *chxj_istyle_to_mode(apr_pool_t *p, const char *s);
114
115
116
117 tag_handler jhtml_handler[] = {
118   /* tagHTML */
119   {
120     s_jhtml_start_html_tag,
121     s_jhtml_end_html_tag,
122   },
123   /* tagMETA */
124   {
125     s_jhtml_start_meta_tag,
126     s_jhtml_end_meta_tag,
127   },
128   /* tagTEXTAREA */
129   {
130     s_jhtml_start_textarea_tag,
131     s_jhtml_end_textarea_tag,
132   },
133   /* tagP */
134   {
135     s_jhtml_start_p_tag,
136     s_jhtml_end_p_tag,
137   },
138   /* tagPRE */
139   {
140     s_jhtml_start_pre_tag,
141     s_jhtml_end_pre_tag,
142   },
143   /* tagUL */
144   {
145     s_jhtml_start_ul_tag,
146     s_jhtml_end_ul_tag,
147   },
148   /* tagLI */
149   {
150     s_jhtml_start_li_tag,
151     s_jhtml_end_li_tag,
152   },
153   /* tagOL */
154   {
155     s_jhtml_start_ol_tag,
156     s_jhtml_end_ol_tag,
157   },
158   /* tagH1 */
159   {
160     s_jhtml_start_h1_tag,
161     s_jhtml_end_h1_tag,
162   },
163   /* tagH2 */
164   {
165     s_jhtml_start_h2_tag,
166     s_jhtml_end_h2_tag,
167   },
168   /* tagH3 */
169   {
170     s_jhtml_start_h3_tag,
171     s_jhtml_end_h3_tag,
172   },
173   /* tagH4 */
174   {
175     s_jhtml_start_h4_tag,
176     s_jhtml_end_h4_tag,
177   },
178   /* tagH5 */
179   {
180     s_jhtml_start_h5_tag,
181     s_jhtml_end_h5_tag,
182   },
183   /* tagH6 */
184   {
185     s_jhtml_start_h6_tag,
186     s_jhtml_end_h6_tag,
187   },
188   /* tagHEAD */
189   {
190     s_jhtml_start_head_tag,
191     s_jhtml_end_head_tag,
192   },
193   /* tagTITLE */
194   {
195     s_jhtml_start_title_tag,
196     s_jhtml_end_title_tag,
197   },
198   /* tagBASE */
199   {
200     s_jhtml_start_base_tag,
201     s_jhtml_end_base_tag,
202   },
203   /* tagBODY */
204   {
205     s_jhtml_start_body_tag,
206     s_jhtml_end_body_tag,
207   },
208   /* tagA */
209   {
210     s_jhtml_start_a_tag,
211     s_jhtml_end_a_tag,
212   },
213   /* tagBR */
214   {
215     s_jhtml_start_br_tag,
216     s_jhtml_end_br_tag,
217   },
218   /* tagTABLE */
219   {
220     NULL,
221     NULL,
222   },
223   /* tagTR */
224   {
225     s_jhtml_start_tr_tag,
226     s_jhtml_end_tr_tag,
227   },
228   /* tagTD */
229   {
230     NULL,
231     NULL,
232   },
233   /* tagTBODY */
234   {
235     NULL,
236     NULL,
237   },
238   /* tagFONT */
239   {
240     s_jhtml_start_font_tag,
241     s_jhtml_end_font_tag,
242   },
243   /* tagFORM */
244   {
245     s_jhtml_start_form_tag,
246     s_jhtml_end_form_tag,
247   },
248   /* tagINPUT */
249   {
250     s_jhtml_start_input_tag,
251     s_jhtml_end_input_tag,
252   },
253   /* tagCENTER */
254   {
255     s_jhtml_start_center_tag,
256     s_jhtml_end_center_tag,
257   },
258   /* tagHR */
259   {
260     s_jhtml_start_hr_tag,
261     s_jhtml_end_hr_tag,
262   },
263   /* tagIMG */
264   {
265     s_jhtml_start_img_tag,
266     s_jhtml_end_img_tag,
267   },
268   /* tagSELECT */
269   {
270     s_jhtml_start_select_tag,
271     s_jhtml_end_select_tag,
272   },
273   /* tagOPTION */
274   {
275     s_jhtml_start_option_tag,
276     s_jhtml_end_option_tag,
277   },
278   /* tagDIV */
279   {
280     s_jhtml_start_div_tag,
281     s_jhtml_end_div_tag,
282   },
283   /* tagCHXJIF */
284   {
285     s_jhtml_chxjif_tag,
286     NULL,
287   },
288   /* tagNOBR */
289   {
290     NULL,
291     NULL,
292   },
293   /* tagSMALL */
294   {
295     NULL,
296     NULL,
297   },
298   /* tagSTYLE */
299   {
300     NULL,
301     NULL,
302   },
303   /* tagSPAN */
304   {
305     NULL,
306     NULL,
307   },
308   /* tagTEXT */
309   {
310     s_jhtml_text_tag,
311     NULL,
312   },
313   /* tagTH */
314   {
315     NULL,
316     NULL,
317   },
318   /* tagB */
319   {
320     s_jhtml_start_b_tag,
321     s_jhtml_end_b_tag,
322   },
323   /* tagFIELDSET */
324   {
325     NULL,
326     NULL,
327   },
328   /* tagDT */
329   {
330     s_jhtml_start_dt_tag,
331     s_jhtml_end_dt_tag,
332   },
333   /* tagLEGEND */
334   {
335     NULL,
336     NULL,
337   },
338   /* tagLABEL */
339   {
340     NULL,
341     NULL,
342   },
343   /* tagBLOCKQUOTE */
344   {
345     s_jhtml_start_blockquote_tag,
346     s_jhtml_end_blockquote_tag,
347   },
348   /* tagDIR */
349   {
350     s_jhtml_start_dir_tag,
351     s_jhtml_end_dir_tag,
352   },
353   /* tagDL */
354   {
355     s_jhtml_start_dl_tag,
356     s_jhtml_end_dl_tag,
357   },
358   /* tagDD */
359   {
360     s_jhtml_start_dd_tag,
361     s_jhtml_end_dd_tag,
362   },
363   /* tagMENU */
364   {
365     NULL,
366     NULL,
367   },
368   /* tagPLAINTEXT */
369   {
370     NULL,
371     NULL,
372   },
373   /* tagBLINK */
374   {
375     NULL,
376     NULL,
377   },
378   /* tagMARQUEE */
379   {
380     NULL,
381     NULL,
382   },
383 };
384
385
386 /**
387  * converts from CHTML5.0 to JHTML.
388  *
389  * @param r     [i]   Requet_rec is appointed.
390  * @param spec  [i]   The result of the device specification processing which 
391  *                    was done in advance is appointed.
392  * @param src   [i]   The character string before the converting is appointed.
393  * @return The character string after the converting is returned.
394  */
395 char*
396 chxj_exchange_jhtml(
397   request_rec         *r,
398   device_table        *spec,
399   const char          *src,
400   apr_size_t          srclen,
401   apr_size_t          *dstlen,
402   chxjconvrule_entry  *entryp,
403   cookie_t            *cookie
404 )
405 {
406   char      *dst;
407   char      *ss;
408   jhtml_t   jhtml;
409   Doc       doc;
410
411   dst = NULL;
412
413   /*--------------------------------------------------------------------------*/
414   /* If qrcode xml                                                            */
415   /*--------------------------------------------------------------------------*/
416   *dstlen = srclen;
417   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
418   if (dst) {
419     DBG(r,"I found qrcode xml");
420     return dst;
421   }
422   DBG(r,"not found qrcode xml");
423
424   /*--------------------------------------------------------------------------*/
425   /* The CHTML structure is initialized.                                      */
426   /*--------------------------------------------------------------------------*/
427   s_init_jhtml(&jhtml, &doc, r, spec);
428
429   jhtml.entryp = entryp;
430   jhtml.cookie = cookie;
431
432   chxj_set_content_type(r, "text/html; charset=Windows-31J");
433
434   /*--------------------------------------------------------------------------*/
435   /* The character string of the input is analyzed.                           */
436   /*--------------------------------------------------------------------------*/
437   qs_init_malloc(&doc);
438   qs_init_root_node(&doc);
439
440   ss = apr_pcalloc(r->pool, srclen + 1);
441
442   memset(ss,   0, srclen + 1);
443   memcpy(ss, src, srclen);
444
445 #ifdef DUMP_LOG
446   chxj_dump_out("[src] CHTML -> JHTML", ss, srclen);
447 #endif
448
449   qs_parse_string(&doc,ss,strlen(ss));
450
451   chxj_buffered_write_init(r->pool, &doc.buf);
452   /*--------------------------------------------------------------------------*/
453   /* It converts it from CHTML to JHTML.                                      */
454   /*--------------------------------------------------------------------------*/
455   chxj_node_exchange(spec,r,(void*)&jhtml, &doc, qs_get_root(&doc), 0);
456   jhtml.out = chxj_buffered_write_flush(jhtml.out, &doc.buf);
457   dst = apr_pstrdup(r->pool, jhtml.out);
458   chxj_buffered_write_terminate(&doc.buf);
459
460
461   qs_all_free(&doc,QX_LOGMARK);
462
463   if (! dst) 
464     return apr_pstrdup(r->pool,ss);
465
466   if (! strlen(dst)) 
467     dst = apr_psprintf(r->pool, "\n");
468
469   *dstlen = strlen(dst);
470
471 #ifdef DUMP_LOG
472   chxj_dump_out("[dst] CHTML -> JHTML", dst, *dstlen);
473 #endif
474
475   return dst;
476 }
477
478
479 /**
480  * The CHTML structure is initialized.
481  *
482  * @param jhtml [i/o] The pointer to the JHTML structure that wants to be
483  *                   initialized is specified.
484  * @param doc   [i]   The Doc structure that should be set to the initialized
485  *                   JHTML structure is specified.
486  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
487  * @param spec  [i]   The pointer to the device_table
488  */
489 static void
490 s_init_jhtml(jhtml_t* jhtml, Doc* doc, request_rec* r, device_table* spec)
491 {
492   memset(doc,   0, sizeof(Doc));
493   memset(jhtml, 0, sizeof(jhtml_t));
494
495   doc->r      = r;
496   jhtml->doc  = doc;
497   jhtml->spec = spec;
498   jhtml->out  = qs_alloc_zero_byte_string(r);
499   jhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
500   jhtml->doc->parse_mode = PARSE_MODE_CHTML;
501 }
502
503
504 /**
505  * Corresponding EMOJI to a current character-code is retrieved. 
506  * The substitution character string is stored in the rslt pointer if agreeing.
507  *
508  * @param jhtml   [i]   The pointer to the CHTML structure is specified. 
509  * @param txt     [i]   The character string to want to examine whether it is 
510  *                      EMOJI is specified. 
511  * @param rslt    [o]   The pointer to the pointer that stores the result is 
512  *                      specified. 
513  * @return When corresponding EMOJI exists, it returns it excluding 0. 
514  */
515 static int
516 s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt)
517 {
518   emoji_t       *ee;
519   request_rec   *r;
520   device_table  *spec;
521   int           len;
522
523   spec = jhtml->spec;
524
525   len = strlen(txt);
526   r = jhtml->doc->r;
527
528   if (! spec) DBG(r,"spec is NULL");
529
530   for (ee = jhtml->conf->emoji;
531        ee;
532        ee = ee->next) {
533
534     unsigned char hex1byte;
535     unsigned char hex2byte;
536
537     if (! ee->imode) { 
538       DBG(r,"emoji->imode is NULL");
539       continue;
540     }
541
542     hex1byte = ee->imode->hex1byte & 0xff;
543     hex2byte = ee->imode->hex2byte & 0xff;
544
545     if (ee->imode->string
546     &&  strlen(ee->imode->string) > 0
547     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
548       if (spec == NULL || spec->emoji_type == NULL) {
549         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
550         return strlen(ee->imode->string);
551       }
552
553       return 0;
554     }
555
556     if (len >= 2
557     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
558     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
559       if (spec == NULL || spec->emoji_type == NULL) {
560         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
561         return 2;
562       }
563
564       return 0;
565     }
566   }
567
568   return 0;
569 }
570
571
572 /**
573  * It is a handler who processes the HTML tag.
574  *
575  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
576  *                     destination is specified.
577  * @param node   [i]   The HTML tag node is specified.
578  * @return The conversion result is returned.
579  */
580 static char *
581 s_jhtml_start_html_tag(void *pdoc, Node *UNUSED(node)) 
582 {
583   jhtml_t       *jhtml;
584   Doc           *doc;
585   request_rec   *r;
586
587
588   jhtml  = GET_JHTML(pdoc);
589   doc    = jhtml->doc;
590   r      = doc->r;
591   DBG(r, "start s_jhtml_start_html_tag()");
592
593   /*--------------------------------------------------------------------------*/
594   /* start HTML tag                                                           */
595   /*--------------------------------------------------------------------------*/
596   W_L("<html>");
597
598   DBG(r, "end s_jhtml_start_html_tag()");
599
600   return jhtml->out;
601 }
602
603
604 /**
605  * It is a handler who processes the HTML tag.
606  *
607  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
608  *                     destination is specified.
609  * @param node   [i]   The HTML tag node is specified.
610  * @return The conversion result is returned.
611  */
612 static char *
613 s_jhtml_end_html_tag(void *pdoc, Node *UNUSED(child)) 
614 {
615   jhtml_t       *jhtml = GET_JHTML(pdoc);
616   Doc           *doc = jhtml->doc;
617
618   W_L("</html>");
619
620   return jhtml->out;
621 }
622
623
624 /**
625  * It is a handler who processes the META tag.
626  *
627  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
628  *                     destination is specified.
629  * @param node   [i]   The META tag node is specified.
630  * @return The conversion result is returned.
631  */
632 static char *
633 s_jhtml_start_meta_tag(void *pdoc, Node *node) 
634 {
635   jhtml_t      *jhtml;
636   Doc          *doc;
637   request_rec  *r;
638   Attr         *attr;
639   int          content_type_flag;
640   int          refresh_flag;
641
642   jhtml             = GET_JHTML(pdoc);
643   doc               = jhtml->doc;
644   r                 = doc->r;
645   refresh_flag      = 0;
646   content_type_flag = 0;
647
648   W_L("<meta");
649   /*--------------------------------------------------------------------------*/
650   /* Get Attributes                                                           */
651   /*--------------------------------------------------------------------------*/
652   for (attr = qs_get_attr(doc,node);
653        attr;
654        attr = qs_get_next_attr(doc,attr)) {
655     char *name   = qs_get_attr_name(doc,attr);
656     char *value  = qs_get_attr_value(doc,attr);
657     switch(*name) {
658     case 'h':
659     case 'H':
660       if (strcasecmp(name, "http-equiv") == 0) {
661         /*----------------------------------------------------------------------*/
662         /* CHTML 2.0                                                            */
663         /*----------------------------------------------------------------------*/
664         W_L(" http-equiv=\"");
665         W_V(value);
666         W_L("\"");
667         if (STRCASEEQ('c','C',"content-type",value)) {
668           content_type_flag = 1;
669         }
670         if (STRCASEEQ('r','R',"refresh",value)) {
671           refresh_flag = 1;
672         }
673       }
674       break;
675
676     case 'c':
677     case 'C':
678       if (strcasecmp(name, "content") == 0) {
679         /*----------------------------------------------------------------------*/
680         /* CHTML 2.0                                                            */
681         /*----------------------------------------------------------------------*/
682         if (content_type_flag)  {
683           W_L(" ");
684           W_V(name);
685           W_L("=\"");
686           W_L("text/html; charset=Windows-31J");
687           W_L("\"");
688         }
689         else
690         if (refresh_flag) {
691           char *buf;
692           char *sec;
693           char *url;
694   
695           buf = apr_pstrdup(r->pool, value);
696   
697           url = strchr(buf, ';');
698           if (url) {
699             sec = apr_pstrdup(r->pool, buf);
700             sec[url-buf] = 0;
701             url++;
702             url = chxj_encoding_parameter(r, url);
703             url = chxj_add_cookie_parameter(r, url, jhtml->cookie);
704             W_L(" ");
705             W_V(name);
706             W_L("=\"");
707             W_V(sec);
708             W_L(";");
709             W_V(url);
710             W_L("\"");
711           }
712         }
713         else {
714           W_L(" ");
715           W_V(name);
716           W_L("=\"");
717           W_V(value);
718           W_L("\"");
719         }
720       }
721       break;
722     
723     default:
724       break;
725     }
726   }
727   W_L(">");
728   return jhtml->out;
729 }
730
731
732 /**
733  * It is a handler who processes the META tag.
734  *
735  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
736  *                     destination is specified.
737  * @param node   [i]   The META tag node is specified.
738  * @return The conversion result is returned.
739  */
740 static char *
741 s_jhtml_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
742 {
743   jhtml_t *jhtml = GET_JHTML(pdoc);
744
745   return jhtml->out;
746 }
747
748
749 /**
750  * It is a handler who processes the HEAD tag.
751  *
752  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
753  *                     destination is specified.
754  * @param node   [i]   The HEAD tag node is specified.
755  * @return The conversion result is returned.
756  */
757 static char *
758 s_jhtml_start_head_tag(void *pdoc, Node *UNUSED(node)) 
759 {
760   jhtml_t       *jhtml;
761   Doc           *doc;
762   request_rec   *r;
763
764   jhtml = GET_JHTML(pdoc);
765   doc   = jhtml->doc;
766   r     = doc->r;
767
768   W_L("<head>");
769   return jhtml->out;
770 }
771
772
773 /**
774  * It is a handler who processes the HEAD tag.
775  *
776  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
777  *                     destination is specified.
778  * @param node   [i]   The HEAD tag node is specified.
779  * @return The conversion result is returned.
780  */
781 static char *
782 s_jhtml_end_head_tag(void *pdoc, Node *UNUSED(child)) 
783 {
784   jhtml_t       *jhtml;
785   Doc           *doc;
786   request_rec   *r;
787
788   jhtml = GET_JHTML(pdoc);
789   doc   = jhtml->doc;
790   r     = doc->r;
791
792   W_L("</head>");
793   return jhtml->out;
794 }
795
796
797 /**
798  * It is a handler who processes the TITLE tag.
799  *
800  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
801  *                     destination is specified.
802  * @param node   [i]   The TITLE tag node is specified.
803  * @return The conversion result is returned.
804  */
805 static char *
806 s_jhtml_start_title_tag(void *pdoc, Node *UNUSED(node)) 
807 {
808   jhtml_t      *jhtml;
809   Doc          *doc;
810   request_rec  *r;
811
812   jhtml = GET_JHTML(pdoc);
813   doc   = jhtml->doc;
814   r     = doc->r;
815
816   W_L("<title>");
817   return jhtml->out;
818 }
819
820
821 /**
822  * It is a handler who processes the TITLE tag.
823  *
824  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
825  *                     destination is specified.
826  * @param node   [i]   The TITLE tag node is specified.
827  * @return The conversion result is returned.
828  */
829 static char *
830 s_jhtml_end_title_tag(void *pdoc, Node *UNUSED(child)) 
831 {
832   jhtml_t       *jhtml;
833   Doc           *doc;
834   request_rec   *r;
835
836   jhtml = GET_JHTML(pdoc);
837   doc   = jhtml->doc;
838   r     = doc->r;
839
840   W_L("</title>");
841   return jhtml->out;
842 }
843
844
845 /**
846  * It is a handler who processes the BASE tag.
847  *
848  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
849  *                     destination is specified.
850  * @param node   [i]   The BASE tag node is specified.
851  * @return The conversion result is returned.
852  */
853 static char *
854 s_jhtml_start_base_tag(void *pdoc, Node *node) 
855 {
856   jhtml_t       *jhtml;
857   Attr          *attr;
858   Doc           *doc;
859   request_rec   *r;
860
861   jhtml = GET_JHTML(pdoc);
862   doc   = jhtml->doc;
863   r     = doc->r;
864
865   W_L("<base");
866   /*--------------------------------------------------------------------------*/
867   /* Get Attributes                                                           */
868   /*--------------------------------------------------------------------------*/
869   for (attr = qs_get_attr(doc,node);
870        attr;
871        attr = qs_get_next_attr(doc,attr)) {
872     char *name  = qs_get_attr_name(doc,attr);
873     char *value = qs_get_attr_value(doc,attr);
874     if (STRCASEEQ('h','H',"href",name)) {
875       W_L(" href=\"");
876       W_V(value);
877       W_L("\"");
878     }
879   }
880   W_L(">");
881   return jhtml->out;
882 }
883
884
885 /**
886  * It is a handler who processes the BASE tag.
887  *
888  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
889  *                     destination is specified.
890  * @param node   [i]   The BASE tag node is specified.
891  * @return The conversion result is returned.
892  */
893 static char *
894 s_jhtml_end_base_tag(void *pdoc, Node *UNUSED(child)) 
895 {
896   jhtml_t *jhtml = GET_JHTML(pdoc);
897   return jhtml->out;
898 }
899
900
901 /**
902  * It is a handler who processes the BODY tag.
903  *
904  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
905  *                     destination is specified.
906  * @param node   [i]   The BODY tag node is specified.
907  * @return The conversion result is returned.
908  */
909 static char *
910 s_jhtml_start_body_tag(void *pdoc, Node *node) 
911 {
912   jhtml_t      *jhtml;
913   Doc          *doc;
914   request_rec  *r;
915   Attr         *attr;
916
917   jhtml = GET_JHTML(pdoc);
918   doc   = jhtml->doc;
919   r     = doc->r;
920
921   W_L("<body");
922   /*--------------------------------------------------------------------------*/
923   /* Get Attributes                                                           */
924   /*--------------------------------------------------------------------------*/
925   for (attr = qs_get_attr(doc,node);
926        attr;
927        attr = qs_get_next_attr(doc,attr)) {
928     char *name   = qs_get_attr_name(doc,attr);
929     char *value  = qs_get_attr_value(doc,attr);
930     if (STRCASEEQ('b','B',"bgcolor",name) && value && *value) {
931       /*----------------------------------------------------------------------*/
932       /* CHTML 2.0                                                            */
933       /*----------------------------------------------------------------------*/
934       W_L(" bgcolor=\"");
935       W_V(value);
936       W_L("\"");
937     }
938     else if (STRCASEEQ('t','T',"text",name) && value && *value) {
939       /*----------------------------------------------------------------------*/
940       /* CHTML 2.0                                                            */
941       /*----------------------------------------------------------------------*/
942       W_L(" text=\"");
943       W_V(value);
944       W_L("\"");
945     }
946     else if (STRCASEEQ('l','L',"link",name) && value && *value) {
947       /*----------------------------------------------------------------------*/
948       /* CHTML 2.0                                                            */
949       /*----------------------------------------------------------------------*/
950       W_L(" link=\"");
951       W_V(value);
952       W_L("\"");
953     }
954     else if (STRCASEEQ('a','A',"alink",name)) {
955       /*----------------------------------------------------------------------*/
956       /* CHTML 4.0                                                            */
957       /*----------------------------------------------------------------------*/
958       /* ignore */
959     }
960     else if (STRCASEEQ('v','V',"vlink",name) && value && *value) {
961       /*----------------------------------------------------------------------*/
962       /* CHTML 4.0                                                            */
963       /*----------------------------------------------------------------------*/
964       W_L(" vlink=\"");
965       W_V(value);
966       W_L("\"");
967     }
968   }
969   W_L(">");
970   return jhtml->out;
971 }
972
973
974 /**
975  * It is a handler who processes the BODY tag.
976  *
977  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
978  *                     destination is specified.
979  * @param node   [i]   The BODY tag node is specified.
980  * @return The conversion result is returned.
981  */
982 static char *
983 s_jhtml_end_body_tag(void *pdoc, Node *UNUSED(child)) 
984 {
985   jhtml_t       *jhtml;
986   Doc           *doc;
987   request_rec   *r;
988
989   jhtml = GET_JHTML(pdoc);
990   doc   = jhtml->doc;
991   r     = doc->r;
992
993   W_L("</body>");
994   return jhtml->out;
995 }
996
997
998 /**
999  * It is a handler who processes the A tag.
1000  *
1001  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1002  *                     destination is specified.
1003  * @param node   [i]   The A tag node is specified.
1004  * @return The conversion result is returned.
1005  */
1006 static char *
1007 s_jhtml_start_a_tag(void *pdoc, Node *node) 
1008 {
1009   jhtml_t       *jhtml;
1010   Doc           *doc;
1011   request_rec   *r;
1012   Attr          *attr;
1013
1014   jhtml = GET_JHTML(pdoc);
1015   doc   = jhtml->doc;
1016   r     = doc->r;
1017
1018   W_L("<a");
1019   /*--------------------------------------------------------------------------*/
1020   /* Get Attributes                                                           */
1021   /*--------------------------------------------------------------------------*/
1022   for (attr = qs_get_attr(doc,node);
1023        attr; 
1024        attr = qs_get_next_attr(doc,attr)) {
1025     char *name  = qs_get_attr_name(doc,attr);
1026     char *value = qs_get_attr_value(doc,attr);
1027     if (STRCASEEQ('n','N',"name",name)) {
1028       /*----------------------------------------------------------------------*/
1029       /* CHTML1.0                                                             */
1030       /*----------------------------------------------------------------------*/
1031       W_L(" name=\"");
1032       W_V(value);
1033       W_L("\"");
1034     }
1035     else if (STRCASEEQ('h','H',"href",name)) {
1036       /*----------------------------------------------------------------------*/
1037       /* CHTML1.0                                                             */
1038       /*----------------------------------------------------------------------*/
1039       value = chxj_encoding_parameter(r, value);
1040       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1041       W_L(" href=\"");
1042       W_V(value);
1043       W_L("\"");
1044     }
1045     else if (STRCASEEQ('a','A',"accesskey",name)) {
1046       /*----------------------------------------------------------------------*/
1047       /* CHTML1.0                                                             */
1048       /*----------------------------------------------------------------------*/
1049       W_L(" accesskey=\"");
1050       W_V(value);
1051       W_L("\"");
1052     }
1053     else if (STRCASEEQ('c','C',"cti",name)) {
1054       /*----------------------------------------------------------------------*/
1055       /* CHTML 2.0                                                            */
1056       /*----------------------------------------------------------------------*/
1057       W_L(" cti=\"");
1058       W_V(value);
1059       W_L("\"");
1060     }
1061     else if (STRCASEEQ('i','I',"ijam",name)) {
1062       /*----------------------------------------------------------------------*/
1063       /* CHTML 3.0                                                            */
1064       /*----------------------------------------------------------------------*/
1065       /* ignore */
1066     }
1067     else if (STRCASEEQ('u','U',"utn",name)) {
1068       /*----------------------------------------------------------------------*/
1069       /* CHTML 3.0                                                            */
1070       /* It is special only for CHTML.                                        */
1071       /*----------------------------------------------------------------------*/
1072       W_L(" utn ");
1073     }
1074     else if (STRCASEEQ('t','T',"telbook",name)) {
1075       /*----------------------------------------------------------------------*/
1076       /* CHTML 3.0                                                            */
1077       /*----------------------------------------------------------------------*/
1078       /* not support */
1079     }
1080     else if (STRCASEEQ('k','K',"kana",name)) {
1081       /*----------------------------------------------------------------------*/
1082       /* CHTML 3.0                                                            */
1083       /*----------------------------------------------------------------------*/
1084       /* not support */
1085     }
1086     else if (STRCASEEQ('e','E',"email",name)) {
1087       /*----------------------------------------------------------------------*/
1088       /* CHTML 3.0                                                            */
1089       /*----------------------------------------------------------------------*/
1090       /* not support */
1091     }
1092     else if (STRCASEEQ('i','I',"ista",name)) {
1093       /*----------------------------------------------------------------------*/
1094       /* CHTML 4.0                                                            */
1095       /*----------------------------------------------------------------------*/
1096       /* ignore */
1097     }
1098     else if (STRCASEEQ('i','I',"ilet",name)) {
1099       /*----------------------------------------------------------------------*/
1100       /* CHTML 5.0                                                            */
1101       /*----------------------------------------------------------------------*/
1102       /* ignore */
1103     }
1104     else if (STRCASEEQ('i','I',"iswf",name)) {
1105       /*----------------------------------------------------------------------*/
1106       /* CHTML 5.0                                                            */
1107       /*----------------------------------------------------------------------*/
1108       /* ignore */
1109     }
1110     else if (STRCASEEQ('i','I',"irst",name)) {
1111       /*----------------------------------------------------------------------*/
1112       /* CHTML 5.0                                                            */
1113       /*----------------------------------------------------------------------*/
1114       /* ignore */
1115     }
1116   }
1117   W_L(">");
1118   return jhtml->out;
1119 }
1120
1121
1122 /**
1123  * It is a handler who processes the A tag.
1124  *
1125  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1126  *                     destination is specified.
1127  * @param node   [i]   The A tag node is specified.
1128  * @return The conversion result is returned.
1129  */
1130 static char *
1131 s_jhtml_end_a_tag(void *pdoc, Node *UNUSED(child)) 
1132 {
1133   jhtml_t      *jhtml;
1134   Doc          *doc;
1135   request_rec  *r;
1136
1137   jhtml = GET_JHTML(pdoc);
1138   doc   = jhtml->doc;
1139   r     = doc->r;
1140
1141   W_L("</a>");
1142   return jhtml->out;
1143 }
1144
1145
1146 /**
1147  * It is a handler who processes the BR tag.
1148  *
1149  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1150  *                     destination is specified.
1151  * @param node   [i]   The BR tag node is specified.
1152  * @return The conversion result is returned.
1153  */
1154 static char *
1155 s_jhtml_start_br_tag(void *pdoc, Node *node)
1156 {
1157   jhtml_t      *jhtml;
1158   Doc          *doc;
1159   request_rec  *r;
1160   Attr         *attr;
1161
1162   jhtml = GET_JHTML(pdoc);
1163   doc   = jhtml->doc;
1164   r     = doc->r;
1165
1166   W_L("<br");
1167   /*--------------------------------------------------------------------------*/
1168   /* Get Attributes                                                           */
1169   /*--------------------------------------------------------------------------*/
1170   for (attr = qs_get_attr(doc,node);
1171        attr;
1172        attr = qs_get_next_attr(doc,attr)) {
1173     char *name  = qs_get_attr_name(doc,attr);
1174     char *value = qs_get_attr_value(doc,attr);
1175     if (STRCASEEQ('c','C',"clear",name)) {
1176       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1177         W_L(" clear=\"");
1178         W_V(value);
1179         W_L("\"");
1180       }
1181     }
1182   }
1183   W_L(">");
1184   return jhtml->out;
1185 }
1186
1187
1188 /**
1189  * It is a handler who processes the BR tag.
1190  *
1191  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1192  *                     destination is specified.
1193  * @param node   [i]   The BR tag node is specified.
1194  * @return The conversion result is returned.
1195  */
1196 static char *
1197 s_jhtml_end_br_tag(void *pdoc, Node *UNUSED(child)) 
1198 {
1199   jhtml_t *jhtml = GET_JHTML(pdoc);
1200   return jhtml->out;
1201 }
1202
1203
1204 /**
1205  * It is a handler who processes the TR tag.
1206  *
1207  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1208  *                     destination is specified.
1209  * @param node   [i]   The TR tag node is specified.
1210  * @return The conversion result is returned.
1211  */
1212 static char *
1213 s_jhtml_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
1214 {
1215   jhtml_t      *jhtml;
1216   Doc          *doc;
1217   request_rec  *r;
1218
1219   jhtml = GET_JHTML(pdoc);
1220   doc   = jhtml->doc;
1221   r     = doc->r;
1222
1223   W_L("<br>\r\n");
1224   return jhtml->out;
1225 }
1226
1227
1228 /**
1229  * It is a handler who processes the TR tag.
1230  *
1231  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1232  *                     destination is specified.
1233  * @param node   [i]   The TR tag node is specified.
1234  * @return The conversion result is returned.
1235  */
1236 static char *
1237 s_jhtml_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
1238 {
1239   jhtml_t *jhtml = GET_JHTML(pdoc);
1240   return jhtml->out;
1241 }
1242
1243
1244 /**
1245  * It is a handler who processes the FONT tag.
1246  *
1247  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1248  *                     destination is specified.
1249  * @param node   [i]   The FONT tag node is specified.
1250  * @return The conversion result is returned.
1251  */
1252 static char *
1253 s_jhtml_start_font_tag(void *pdoc, Node *node) 
1254 {
1255   jhtml_t       *jhtml;
1256   Doc           *doc;
1257   request_rec   *r;
1258   Attr          *attr;
1259
1260   jhtml = GET_JHTML(pdoc);
1261   doc   = jhtml->doc;
1262   r     = doc->r;
1263
1264   W_L("<font");
1265   /*--------------------------------------------------------------------------*/
1266   /* Get Attributes                                                           */
1267   /*--------------------------------------------------------------------------*/
1268   for (attr = qs_get_attr(doc,node);
1269        attr; 
1270        attr = qs_get_next_attr(doc,attr)) {
1271     char *name  = qs_get_attr_name(doc,attr);
1272     char *value = qs_get_attr_value(doc,attr);
1273     if (STRCASEEQ('c','C',"color",name)) {
1274       W_L(" color=\"");
1275       W_V(value);
1276       W_L("\"");
1277     }
1278     else if (STRCASEEQ('s','S',"size",name)) {
1279       /*----------------------------------------------------------------------*/
1280       /* CHTML 5.0                                                            */
1281       /*----------------------------------------------------------------------*/
1282       /* ignore */
1283     }
1284   }
1285   W_L(">");
1286   return jhtml->out;
1287 }
1288
1289
1290 /**
1291  * It is a handler who processes the FONT tag.
1292  *
1293  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1294  *                     destination is specified.
1295  * @param node   [i]   The FONT tag node is specified.
1296  * @return The conversion result is returned.
1297  */
1298 static char *
1299 s_jhtml_end_font_tag(void *pdoc, Node *UNUSED(child)) 
1300 {
1301   jhtml_t      *jhtml;
1302   request_rec  *r;
1303   Doc          *doc;
1304
1305   jhtml = GET_JHTML(pdoc);
1306   doc   = jhtml->doc;
1307   r     = jhtml->doc->r;
1308
1309   W_L("</font>");
1310   return jhtml->out;
1311 }
1312
1313
1314 /**
1315  * It is a handler who processes the FORM tag.
1316  *
1317  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1318  *                     destination is specified.
1319  * @param node   [i]   The FORM tag node is specified.
1320  * @return The conversion result is returned.
1321  */
1322 static char *
1323 s_jhtml_start_form_tag(void *pdoc, Node *node) 
1324 {
1325   jhtml_t      *jhtml;
1326   Doc          *doc;
1327   request_rec  *r;
1328   Attr         *attr;
1329   int          dcflag = 0;
1330   char         *dc = NULL;
1331
1332   jhtml = GET_JHTML(pdoc);
1333   doc   = jhtml->doc;
1334   r     = doc->r;
1335
1336   W_L("<form");
1337   /*--------------------------------------------------------------------------*/
1338   /* Get Attributes                                                           */
1339   /*--------------------------------------------------------------------------*/
1340   for (attr = qs_get_attr(doc,node);
1341        attr;
1342        attr = qs_get_next_attr(doc,attr)) {
1343     char *name  = qs_get_attr_name(doc,attr);
1344     char *value = qs_get_attr_value(doc,attr);
1345     if (STRCASEEQ('a','A',"action",name)) {
1346       /*----------------------------------------------------------------------*/
1347       /* CHTML 1.0                                                            */
1348       /*----------------------------------------------------------------------*/
1349       W_L(" action=\"");
1350       W_V(value);
1351       W_L("\"");
1352       dc = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1353       if (strcmp(dc, value)) {
1354         dcflag = 1;
1355       } 
1356     }
1357     else if (STRCASEEQ('m','M',"method",name)) {
1358       /*----------------------------------------------------------------------*/
1359       /* CHTML 1.0                                                            */
1360       /*----------------------------------------------------------------------*/
1361       W_L(" method=\"");
1362       W_V(value);
1363       W_L("\"");
1364     }
1365     else if (STRCASEEQ('u','U',"utn",name)) {
1366       /*----------------------------------------------------------------------*/
1367       /* CHTML 3.0                                                            */
1368       /* It is special only for CHTML.                                        */
1369       /*----------------------------------------------------------------------*/
1370       /* ignore */
1371     }
1372   }
1373   W_L(">");
1374   /*-------------------------------------------------------------------------*/
1375   /* ``action=""''                                                           */
1376   /*-------------------------------------------------------------------------*/
1377   if (! dc) {
1378     dcflag = 1;
1379   }
1380   /*-------------------------------------------------------------------------*/
1381   /* Add cookie parameter                                                    */
1382   /*-------------------------------------------------------------------------*/
1383   if (jhtml->cookie && jhtml->cookie->cookie_id && dcflag == 1) {
1384     char *vv = apr_psprintf(doc->buf.pool, "%s<input type='hidden' name='%s' value='%s'>",
1385                             jhtml->out, 
1386                             CHXJ_COOKIE_PARAM,
1387                             chxj_url_decode(r, jhtml->cookie->cookie_id));
1388     W_V(vv);
1389   }
1390   return jhtml->out;
1391 }
1392
1393
1394 /**
1395  * It is a handler who processes the FORM tag.
1396  *
1397  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1398  *                     destination is specified.
1399  * @param node   [i]   The FORM tag node is specified.
1400  * @return The conversion result is returned.
1401  */
1402 static char *
1403 s_jhtml_end_form_tag(void *pdoc, Node *UNUSED(child)) 
1404 {
1405   jhtml_t *jhtml = GET_JHTML(pdoc);
1406   Doc     *doc   = jhtml->doc;
1407   W_L("</form>");
1408   return jhtml->out;
1409 }
1410
1411
1412 /**
1413  * It is a handler who processes the INPUT tag.
1414  *
1415  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1416  *                     destination is specified.
1417  * @param node   [i]   The INPUT tag node is specified.
1418  * @return The conversion result is returned.
1419  */
1420 static char *
1421 s_jhtml_start_input_tag(void *pdoc, Node *node) 
1422 {
1423   jhtml_t       *jhtml;
1424   Doc           *doc;
1425   request_rec   *r;
1426   char          *max_length;
1427   char          *type;
1428   char          *name;
1429   char          *value;
1430   char          *istyle;
1431   char          *size;
1432   char          *checked;
1433   char          *accesskey;
1434
1435   jhtml       = GET_JHTML(pdoc);
1436   doc         = jhtml->doc;
1437   r           = doc->r;
1438   max_length  = NULL;
1439   type        = NULL;
1440   name        = NULL;
1441   value       = NULL;
1442   istyle      = NULL;
1443   size        = NULL;
1444   checked     = NULL;
1445   accesskey   = NULL;
1446
1447   W_L("<input");
1448   /*--------------------------------------------------------------------------*/
1449   /* Get Attributes                                                           */
1450   /*--------------------------------------------------------------------------*/
1451   type       = qs_get_type_attr(doc, node, r);
1452   name       = qs_get_name_attr(doc, node, r);
1453   value      = qs_get_value_attr(doc,node,r);
1454   istyle     = qs_get_istyle_attr(doc,node,r);
1455   max_length = qs_get_maxlength_attr(doc,node,r);
1456   checked    = qs_get_checked_attr(doc,node,r);
1457   accesskey  = qs_get_accesskey_attr(doc, node, r);
1458   size       = qs_get_size_attr(doc, node, r);
1459
1460   if (type) {
1461     if (type && (STRCASEEQ('t','T',"text",    type) ||
1462                  STRCASEEQ('p','P',"password",type) ||
1463                  STRCASEEQ('c','C',"checkbox",type) ||
1464                  STRCASEEQ('r','R',"radio",   type) ||
1465                  STRCASEEQ('h','H',"hidden",  type) ||
1466                  STRCASEEQ('s','S',"submit",  type) ||
1467                  STRCASEEQ('r','R',"reset",   type))) {
1468       W_L(" type=\"");
1469       W_V(type);
1470       W_L("\"");
1471     }
1472   }
1473   if (size && *size) {
1474     W_L(" size=\"");
1475     W_V(size);
1476     W_L("\"");
1477   }
1478   if (name && *name) {
1479     W_L(" name=\"");
1480     W_V(name);
1481     W_L("\"");
1482   }
1483   if (value && *value) {
1484     W_L(" value=\"");
1485     W_V(value);
1486     W_L("\"");
1487   }
1488   if (accesskey && *accesskey) {
1489     W_L(" accesskey=\"");
1490     W_V(accesskey);
1491     W_L("\"");
1492   }
1493   if (istyle && (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4')) {
1494     /*------------------------------------------------------------------------*/
1495     /* CHTML 2.0                                                              */
1496     /*------------------------------------------------------------------------*/
1497     if (type && STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1498       W_L(" mode=\"");
1499       W_L("numeric");
1500       W_L("\"");
1501     }
1502     else {
1503       char *vv = chxj_istyle_to_mode(doc->buf.pool,istyle);
1504       W_L(" mode=\"");
1505       W_V(vv);
1506       W_L("\"");
1507     }
1508   }
1509   else if (type && STRCASEEQ('p','P',"password",type)) {
1510     W_L(" mode=\"");
1511     W_L("numeric");
1512     W_L("\"");
1513   }
1514   /*--------------------------------------------------------------------------*/
1515   /* The figure is default for the password.                                  */
1516   /*--------------------------------------------------------------------------*/
1517   if (max_length && *max_length) {
1518     if (chxj_chk_numeric(max_length) == 0) {
1519       W_L(" maxlength=\"");
1520       W_V(max_length);
1521       W_L("\"");
1522     }
1523   }
1524
1525   if (checked) {
1526     W_L(" checked");
1527   }
1528   W_L(">");
1529   return jhtml->out;
1530 }
1531
1532
1533 /**
1534  * It is a handler who processes the INPUT tag.
1535  *
1536  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1537  *                     destination is specified.
1538  * @param node   [i]   The INPUT tag node is specified.
1539  * @return The conversion result is returned.
1540  */
1541 static char *
1542 s_jhtml_end_input_tag(void *pdoc, Node *UNUSED(child)) 
1543 {
1544   jhtml_t *jhtml = GET_JHTML(pdoc);
1545   return jhtml->out;
1546 }
1547
1548
1549 /**
1550  * It is a handler who processes the CENTER tag.
1551  *
1552  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1553  *                     destination is specified.
1554  * @param node   [i]   The CENTER tag node is specified.
1555  * @return The conversion result is returned.
1556  */
1557 static char *
1558 s_jhtml_start_center_tag(void *pdoc, Node *UNUSED(node)) 
1559 {
1560   jhtml_t *jhtml = GET_JHTML(pdoc);
1561   Doc     *doc   = jhtml->doc;
1562   W_L("<center>");
1563   return jhtml->out;
1564 }
1565
1566
1567 /**
1568  * It is a handler who processes the CENTER tag.
1569  *
1570  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1571  *                     destination is specified.
1572  * @param node   [i]   The CENTER tag node is specified.
1573  * @return The conversion result is returned.
1574  */
1575 static char *
1576 s_jhtml_end_center_tag(void *pdoc, Node *UNUSED(child)) 
1577 {
1578   jhtml_t     *jhtml;
1579   Doc         *doc;
1580   request_rec *r;
1581
1582   jhtml = GET_JHTML(pdoc);
1583   doc   = jhtml->doc;
1584   r     = doc->r;
1585
1586   W_L("</center>");
1587   return jhtml->out;
1588 }
1589
1590
1591 /**
1592  * It is a handler who processes the li tag.
1593  *
1594  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1595  *                     destination is specified.
1596  * @param node   [i]   The li tag node is specified.
1597  * @return The conversion result is returned.
1598  */
1599 static char *
1600 s_jhtml_start_li_tag(void *pdoc, Node *node)
1601 {
1602   jhtml_t       *jhtml;
1603   Doc           *doc;
1604   request_rec   *r;
1605   Attr          *attr;
1606
1607   jhtml = GET_JHTML(pdoc);
1608   doc   = jhtml->doc;
1609   r     = doc->r;
1610
1611   W_L("<li");
1612   /*--------------------------------------------------------------------------*/
1613   /* Get Attributes                                                           */
1614   /*--------------------------------------------------------------------------*/
1615   for (attr = qs_get_attr(doc,node);
1616        attr;
1617        attr = qs_get_next_attr(doc,attr)) {
1618     char *name = qs_get_attr_name(doc,attr);
1619     char *value = qs_get_attr_value(doc,attr);
1620     if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1621       W_L(" type=\"");
1622       W_V(value);
1623       W_L("\"");
1624     }
1625     else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1626       W_L(" value=\"");
1627       W_V(value);
1628       W_L("\"");
1629     }
1630   }
1631   W_L(">");
1632   return jhtml->out;
1633 }
1634
1635
1636 /**
1637  * It is a handler who processes the li tag.
1638  *
1639  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1640  *                     destination is specified.
1641  * @param node   [i]   The li tag node is specified.
1642  * @return The conversion result is returned.
1643  */
1644 static char *
1645 s_jhtml_end_li_tag(void *pdoc, Node *UNUSED(child)) 
1646 {
1647   jhtml_t     *jhtml;
1648   Doc         *doc;
1649   request_rec *r;
1650
1651   jhtml = GET_JHTML(pdoc);
1652   doc   = jhtml->doc;
1653   r     = doc->r;
1654
1655   W_L("</li>");
1656   return jhtml->out;
1657 }
1658
1659
1660 /**
1661  * It is a handler who processes the OL tag.
1662  *
1663  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1664  *                     destination is specified.
1665  * @param node   [i]   The OL tag node is specified.
1666  * @return The conversion result is returned.
1667  */
1668 static char *
1669 s_jhtml_start_ol_tag(void *pdoc, Node *UNUSED(node)) 
1670 {
1671   jhtml_t     *jhtml;
1672   Doc         *doc;
1673   request_rec *r;
1674
1675   jhtml = GET_JHTML(pdoc);
1676   doc   = jhtml->doc;
1677   r     = doc->r;
1678
1679   W_L("<ol>");
1680   return jhtml->out;
1681 }
1682
1683
1684 /**
1685  * It is a handler who processes the OL tag.
1686  *
1687  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1688  *                     destination is specified.
1689  * @param node   [i]   The OL tag node is specified.
1690  * @return The conversion result is returned.
1691  */
1692 static char *
1693 s_jhtml_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
1694 {
1695   jhtml_t     *jhtml;
1696   Doc         *doc;
1697   request_rec *r;
1698
1699   jhtml = GET_JHTML(pdoc);
1700   doc   = jhtml->doc;
1701   r     = doc->r;
1702
1703   W_L("</ol>");
1704   return jhtml->out;
1705 }
1706
1707
1708 /**
1709  * It is a handler who processes the P tag.
1710  *
1711  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1712  *                     destination is specified.
1713  * @param node   [i]   The P tag node is specified.
1714  * @return The conversion result is returned.
1715  */
1716 static char *
1717 s_jhtml_start_p_tag(void *pdoc, Node *UNUSED(node)) 
1718 {
1719   jhtml_t     *jhtml;
1720   Doc         *doc;
1721   request_rec *r;
1722
1723   jhtml = GET_JHTML(pdoc);
1724   doc   = jhtml->doc;
1725   r     = doc->r;
1726
1727   W_L("<p>");
1728   return jhtml->out;
1729 }
1730
1731
1732 /**
1733  * It is a handler who processes the P tag.
1734  *
1735  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1736  *                     destination is specified.
1737  * @param node   [i]   The P tag node is specified.
1738  * @return The conversion result is returned.
1739  */
1740 static char *
1741 s_jhtml_end_p_tag(void *pdoc, Node *UNUSED(child)) 
1742 {
1743   jhtml_t   *jhtml = GET_JHTML(pdoc);
1744   Doc       *doc   = jhtml->doc;
1745
1746   W_L("</p>");
1747   return jhtml->out;
1748 }
1749
1750
1751 /**
1752  * It is a handler who processes the PRE tag.
1753  *
1754  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1755  *                     destination is specified.
1756  * @param node   [i]   The PRE tag node is specified.
1757  * @return The conversion result is returned.
1758  */
1759 static char *
1760 s_jhtml_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
1761 {
1762   jhtml_t  *jhtml = GET_JHTML(pdoc);
1763   Doc      *doc   = jhtml->doc;
1764
1765   jhtml->pre_flag++;
1766   W_L("<pre>");
1767   return jhtml->out;
1768 }
1769
1770
1771 /**
1772  * It is a handler who processes the PRE tag.
1773  *
1774  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1775  *                     destination is specified.
1776  * @param node   [i]   The PRE tag node is specified.
1777  * @return The conversion result is returned.
1778  */
1779 static char *
1780 s_jhtml_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
1781 {
1782   jhtml_t *jhtml = GET_JHTML(pdoc);
1783   Doc     *doc   = jhtml->doc;
1784
1785   W_L("</pre>");
1786   jhtml->pre_flag--;
1787
1788   return jhtml->out;
1789 }
1790
1791
1792 /**
1793  * It is a handler who processes the UL tag.
1794  *
1795  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1796  *                     destination is specified.
1797  * @param node   [i]   The UL tag node is specified.
1798  * @return The conversion result is returned.
1799  */
1800 static char *
1801 s_jhtml_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
1802 {
1803   jhtml_t *jhtml = GET_JHTML(pdoc);
1804   Doc     *doc   = jhtml->doc;
1805
1806   W_L("<ul>");
1807   return jhtml->out;
1808 }
1809
1810
1811 /**
1812  * It is a handler who processes the UL tag.
1813  *
1814  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1815  *                     destination is specified.
1816  * @param node   [i]   The UL tag node is specified.
1817  * @return The conversion result is returned.
1818  */
1819 static char *
1820 s_jhtml_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
1821 {
1822   jhtml_t *jhtml = GET_JHTML(pdoc);
1823   Doc     *doc   = jhtml->doc;
1824
1825   W_L("</ul>");
1826   return jhtml->out;
1827 }
1828
1829
1830 /**
1831  * It is a handler who processes the HR tag.
1832  *
1833  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1834  *                     destination is specified.
1835  * @param node   [i]   The HR tag node is specified.
1836  * @return The conversion result is returned.
1837  */
1838 static char *
1839 s_jhtml_start_hr_tag(void *pdoc, Node *node) 
1840 {
1841   jhtml_t *jhtml = GET_JHTML(pdoc);
1842   Doc     *doc   = jhtml->doc;
1843   Attr    *attr;
1844
1845   W_L("<hr");
1846   for (attr = qs_get_attr(doc,node);
1847        attr; 
1848        attr = qs_get_next_attr(doc,attr)) {
1849     char *name = qs_get_attr_name(doc,attr);
1850     char *value = qs_get_attr_value(doc,attr);
1851     if (STRCASEEQ('a','A',"align",name)) {
1852       /*----------------------------------------------------------------------*/
1853       /* CHTML 1.0                                                            */
1854       /*----------------------------------------------------------------------*/
1855       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1856         W_L(" align=\"");
1857         W_V(value);
1858         W_L("\"");
1859       }
1860     }
1861     else if (STRCASEEQ('s','S',"size",name) && value && *value) {
1862       /*----------------------------------------------------------------------*/
1863       /* CHTML 1.0                                                            */
1864       /*----------------------------------------------------------------------*/
1865       W_L(" size=\"");
1866       W_V(value);
1867       W_L("\"");
1868     }
1869     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
1870       /*----------------------------------------------------------------------*/
1871       /* CHTML 1.0                                                            */
1872       /*----------------------------------------------------------------------*/
1873       W_L(" width=\"");
1874       W_V(value);
1875       W_L("\"");
1876     }
1877     else if (STRCASEEQ('n','N',"noshade",name)) {
1878       /*----------------------------------------------------------------------*/
1879       /* CHTML 1.0                                                            */
1880       /*----------------------------------------------------------------------*/
1881       W_L(" noshade");
1882     }
1883     else if (STRCASEEQ('c','C',"color",name) && value && *value) {
1884       /*----------------------------------------------------------------------*/
1885       /* CHTML 4.0                                                            */
1886       /*----------------------------------------------------------------------*/
1887       W_L(" color=\"");
1888       W_V(value);
1889       W_L("\"");
1890     }
1891   }
1892   W_L(">");
1893   return jhtml->out;
1894 }
1895
1896
1897 /**
1898  * It is a handler who processes the HR tag.
1899  *
1900  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1901  *                     destination is specified.
1902  * @param node   [i]   The HR tag node is specified.
1903  * @return The conversion result is returned.
1904  */
1905 static char *
1906 s_jhtml_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
1907 {
1908   jhtml_t *jhtml = GET_JHTML(pdoc);
1909   return jhtml->out;
1910 }
1911
1912
1913 /**
1914  * It is a handler who processes the IMG tag.
1915  *
1916  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
1917  *                     destination is specified.
1918  * @param node   [i]   The IMG tag node is specified.
1919  * @return The conversion result is returned.
1920  */
1921 static char *
1922 s_jhtml_start_img_tag(void *pdoc, Node *node) 
1923 {
1924   jhtml_t       *jhtml = GET_JHTML(pdoc);
1925   Doc           *doc   = jhtml->doc;
1926   request_rec   *r     = doc->r;
1927   Attr          *attr;
1928 #ifndef IMG_NOT_CONVERT_FILENAME
1929   device_table  *spec = jhtml->spec;
1930 #endif
1931
1932   W_L("<img");
1933   /*--------------------------------------------------------------------------*/
1934   /* Get Attributes                                                           */
1935   /*--------------------------------------------------------------------------*/
1936   for (attr = qs_get_attr(doc,node);
1937        attr;
1938        attr = qs_get_next_attr(doc,attr)) {
1939     char *name  = qs_get_attr_name(doc,attr);
1940     char *value = qs_get_attr_value(doc,attr);
1941     if (STRCASEEQ('s','S',"src",name)) {
1942       /*----------------------------------------------------------------------*/
1943       /* CHTML 1.0                                                            */
1944       /*----------------------------------------------------------------------*/
1945 #ifdef IMG_NOT_CONVERT_FILENAME
1946       value = chxj_encoding_parameter(r, value);
1947       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1948       if (value) {
1949         value = apr_psprintf(r->pool,
1950                              "%s%c%s=true",
1951                              value,
1952                              (strchr(value, '?')) ? '&' : '?',
1953                              CHXJ_COOKIE_NOUPDATE_PARAM);
1954       }
1955       W_L(" src=\"");
1956       W_V(value);
1957       W_L("\"");
1958 #else
1959       value = chxj_img_conv(r, spec, value);
1960       value = chxj_encoding_parameter(r, value);
1961       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1962       if (value) {
1963         value = apr_psprintf(r->pool,
1964                              "%s%c%s=true",
1965                              value,
1966                              (strchr(value, '?')) ? '&' : '?',
1967                              CHXJ_COOKIE_NOUPDATE_PARAM);
1968       }
1969       W_L(" src=\"");
1970       W_V(value);
1971       W_L("\"");
1972 #endif
1973     }
1974     else if (STRCASEEQ('a','A',"align",name)) {
1975       /*----------------------------------------------------------------------*/
1976       /* CHTML 1.0                                                            */
1977       /*----------------------------------------------------------------------*/
1978       if (value && (STRCASEEQ('t','T',"top",   value) ||
1979                     STRCASEEQ('m','M',"middle",value) ||
1980                     STRCASEEQ('b','B',"bottom",value) ||
1981                     STRCASEEQ('l','L',"left",  value) ||
1982                     STRCASEEQ('r','R',"right", value))) {
1983         W_L(" align=\"");
1984         W_V(value);
1985         W_L("\"");
1986       }
1987     }
1988     else if (STRCASEEQ('w','W',"width",name) && value && *value) {
1989       /*----------------------------------------------------------------------*/
1990       /* CHTML 1.0                                                            */
1991       /*----------------------------------------------------------------------*/
1992       W_L(" width=\"");
1993       W_V(value);
1994       W_L("\"");
1995     }
1996     else if (STRCASEEQ('h','H',"height",name) && value && *value) {
1997       /*----------------------------------------------------------------------*/
1998       /* CHTML 1.0                                                            */
1999       /*----------------------------------------------------------------------*/
2000       W_L(" height=\"");
2001       W_V(value);
2002       W_L("\"");
2003     }
2004     else if (STRCASEEQ('h','H',"hspace",name)) {
2005       /*----------------------------------------------------------------------*/
2006       /* CHTML 1.0                                                            */
2007       /*----------------------------------------------------------------------*/
2008       /* ignore */
2009     }
2010     else if (STRCASEEQ('v','V',"vspace",name)) {
2011       /*----------------------------------------------------------------------*/
2012       /* CHTML 1.0                                                            */
2013       /*----------------------------------------------------------------------*/
2014       /* ignore */
2015     }
2016     else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2017       /*----------------------------------------------------------------------*/
2018       /* CHTML 1.0                                                            */
2019       /*----------------------------------------------------------------------*/
2020       W_L(" alt=\"");
2021       W_V(value);
2022       W_L("\"");
2023     }
2024   }
2025   W_L(">");
2026   return jhtml->out;
2027 }
2028
2029
2030 /**
2031  * It is a handler who processes the IMG tag.
2032  *
2033  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2034  *                     destination is specified.
2035  * @param node   [i]   The IMG tag node is specified.
2036  * @return The conversion result is returned.
2037  */
2038 static char *
2039 s_jhtml_end_img_tag(void *pdoc, Node *UNUSED(child)) 
2040 {
2041   jhtml_t *jhtml = GET_JHTML(pdoc);
2042   return jhtml->out;
2043 }
2044
2045
2046 /**
2047  * It is a handler who processes the SELECT tag.
2048  *
2049  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2050  *                     destination is specified.
2051  * @param node   [i]   The SELECT tag node is specified.
2052  * @return The conversion result is returned.
2053  */
2054 static char *
2055 s_jhtml_start_select_tag(void *pdoc, Node *child)
2056 {
2057   jhtml_t *jhtml = GET_JHTML(pdoc);
2058   Doc     *doc   = jhtml->doc;
2059   Attr    *attr;
2060
2061   char *size      = NULL;
2062   char *name      = NULL;
2063
2064   W_L("<select");
2065   for (attr = qs_get_attr(doc,child);
2066        attr;
2067        attr = qs_get_next_attr(doc,attr)) {
2068     char *nm  = qs_get_attr_name(doc,attr);
2069     char *val = qs_get_attr_value(doc,attr);
2070     if (STRCASEEQ('s','S',"size",nm)) {
2071       /*----------------------------------------------------------------------*/
2072       /* CHTML 1.0 version 2.0                                                */
2073       /*----------------------------------------------------------------------*/
2074       size = apr_pstrdup(doc->buf.pool, val);
2075     }
2076     else if (STRCASEEQ('n','N',"name",nm)) {
2077       /*----------------------------------------------------------------------*/
2078       /* CHTML 1.0 version 2.0                                                */
2079       /*----------------------------------------------------------------------*/
2080       name = apr_pstrdup(doc->buf.pool, val);
2081     }
2082     else if (STRCASEEQ('m','M',"multiple",nm)) {
2083       /*----------------------------------------------------------------------*/
2084       /* CHTML 1.0 version 2.0                                                */
2085       /*----------------------------------------------------------------------*/
2086       /* not support */
2087     }
2088   }
2089
2090   if (size) {
2091     W_L(" size=\"");
2092     W_V(size);
2093     W_L("\"");
2094   }
2095
2096   if (name) {
2097     W_L(" name=\"");
2098     W_V(name);
2099     W_L("\"");
2100   }
2101   W_L(">");
2102   return jhtml->out;
2103 }
2104
2105 /**
2106  * It is a handler who processes the SELECT tag.
2107  *
2108  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2109  *                     destination is specified.
2110  * @param node   [i]   The SELECT tag node is specified.
2111  * @return The conversion result is returned.
2112  */
2113 static char *
2114 s_jhtml_end_select_tag(void *pdoc, Node *UNUSED(child))
2115 {
2116   jhtml_t *jhtml = GET_JHTML(pdoc);
2117   Doc     *doc   = jhtml->doc;
2118
2119   W_L("</select>");
2120   return jhtml->out;
2121 }
2122
2123 /**
2124  * It is a handler who processes the OPTION tag.
2125  *
2126  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2127  *                     destination is specified.
2128  * @param node   [i]   The OPTION tag node is specified.
2129  * @return The conversion result is returned.
2130  */
2131 static char *
2132 s_jhtml_start_option_tag(void *pdoc, Node *child)
2133 {
2134   jhtml_t *jhtml = GET_JHTML(pdoc);
2135   Doc     *doc   = jhtml->doc;
2136   Attr    *attr;
2137
2138   char *selected   = NULL;
2139   char *value      = NULL;
2140
2141   W_L("<option");
2142   for (attr = qs_get_attr(doc,child);
2143        attr;
2144        attr = qs_get_next_attr(doc,attr)) {
2145     char *nm  = qs_get_attr_name(doc,attr);
2146     char *val = qs_get_attr_value(doc,attr);
2147     if (STRCASEEQ('s','S',"selected",nm)) {
2148       /*----------------------------------------------------------------------*/
2149       /* CHTML 1.0 version 2.0                                                */
2150       /*----------------------------------------------------------------------*/
2151       selected = apr_pstrdup(doc->buf.pool, val);
2152     }
2153     else if (STRCASEEQ('v','V',"value",nm)) {
2154       /*----------------------------------------------------------------------*/
2155       /* CHTML 1.0 version 2.0                                                */
2156       /*----------------------------------------------------------------------*/
2157       value = apr_pstrdup(doc->buf.pool, val);
2158     }
2159   }
2160
2161   if (value) {
2162     W_L(" value=\"");
2163     W_V(value);
2164     W_L("\"");
2165   }
2166   else {
2167     W_L(" value=\"\"");
2168   }
2169
2170   if (selected) {
2171     W_L(" selected ");
2172   }
2173   W_L(">");
2174   return jhtml->out;
2175 }
2176
2177
2178 /**
2179  * It is a handler who processes the OPTION tag.
2180  *
2181  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2182  *                     destination is specified.
2183  * @param node   [i]   The OPTION tag node is specified.
2184  * @return The conversion result is returned.
2185  */
2186 static char *
2187 s_jhtml_end_option_tag(void *pdoc, Node *UNUSED(child))
2188 {
2189   jhtml_t *jhtml = GET_JHTML(pdoc);
2190   /* Don't close */
2191   return jhtml->out;
2192 }
2193
2194
2195 /**
2196  * It is a handler who processes the DIV tag.
2197  *
2198  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2199  *                     destination is specified.
2200  * @param node   [i]   The DIV tag node is specified.
2201  * @return The conversion result is returned.
2202  */
2203 static char *
2204 s_jhtml_start_div_tag(void *pdoc, Node *child)
2205 {
2206   jhtml_t      *jhtml;
2207   Doc          *doc;
2208   request_rec  *r;
2209   Attr         *attr;
2210   char         *align = NULL;
2211
2212   jhtml = GET_JHTML(pdoc);
2213   doc   = jhtml->doc;
2214   r     = doc->r;
2215
2216   W_L("<div");
2217   for (attr = qs_get_attr(doc,child);
2218        attr;
2219        attr = qs_get_next_attr(doc,attr)) {
2220     char *nm  = qs_get_attr_name(doc,attr);
2221     char *val = qs_get_attr_value(doc,attr);
2222     if (STRCASEEQ('a','A',"align",nm)) {
2223       /*----------------------------------------------------------------------*/
2224       /* CHTML 1.0 (W3C version 3.2)                                          */
2225       /*----------------------------------------------------------------------*/
2226       if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2227         align = apr_pstrdup(doc->buf.pool, val);
2228       }
2229     }
2230   }
2231   if (align) {
2232     W_L(" align=\"");
2233     W_V(align);
2234     W_L("\"");
2235   }
2236   W_L(">");
2237   return jhtml->out;
2238 }
2239
2240
2241 /**
2242  * It is a handler who processes the DIV tag.
2243  *
2244  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2245  *                     destination is specified.
2246  * @param node   [i]   The DIV tag node is specified.
2247  * @return The conversion result is returned.
2248  */
2249 static char *
2250 s_jhtml_end_div_tag(void *pdoc, Node *UNUSED(child))
2251 {
2252   jhtml_t      *jhtml;
2253   Doc          *doc;
2254   request_rec  *r;
2255
2256   jhtml = GET_JHTML(pdoc);
2257   doc   = jhtml->doc;
2258   r     = doc->r;
2259
2260   W_L("</div>");
2261   return jhtml->out;
2262 }
2263
2264
2265 static char *
2266 chxj_istyle_to_mode(apr_pool_t *p, const char *s)
2267 {
2268   char *tmp;
2269
2270   if (s) {
2271     switch (s[0]) {
2272     case '1': return apr_psprintf(p, "hiragana");
2273     case '2': return apr_psprintf(p, "hankakukana");
2274     case '3': return apr_psprintf(p, "alphabet");
2275     case '4': return apr_psprintf(p, "numeric");
2276     default: 
2277       tmp = apr_palloc(p, 1);
2278       tmp[0] = '\0';
2279       return apr_pstrdup(p, tmp);
2280     }
2281   }
2282
2283   tmp = apr_palloc(p, 1);
2284   tmp[0] = '\0';
2285   return apr_pstrdup(p,tmp);
2286 }
2287
2288
2289 static char *
2290 s_jhtml_chxjif_tag(void *pdoc, Node *node)
2291 {
2292   jhtml_t *jhtml;
2293   Doc     *doc;
2294   Node    *child;
2295   request_rec *r;
2296
2297   jhtml = GET_JHTML(pdoc);
2298   doc   = jhtml->doc;
2299   r     = doc->r;
2300
2301   for (child = qs_get_child_node(doc, node);
2302        child;
2303        child = qs_get_next_node(doc, child)) {
2304     W_V(child->otext);
2305     s_jhtml_chxjif_tag(jhtml, child);
2306   }
2307   return NULL;
2308 }
2309
2310
2311 /**
2312  * It is a handler who processes the TEXTARE tag.
2313  *
2314  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2315  *                     destination is specified.
2316  * @param node   [i]   The TEXTAREA tag node is specified.
2317  * @return The conversion result is returned.
2318  */
2319 static char*
2320 s_jhtml_start_textarea_tag(void* pdoc, Node* node) 
2321 {
2322   jhtml_t*      jhtml;
2323   Doc*          doc;
2324   request_rec*  r;
2325   Attr*         attr;
2326
2327   jhtml = GET_JHTML(pdoc);
2328   doc   = jhtml->doc;
2329   r     = doc->r;
2330
2331   jhtml->textarea_flag++;
2332   W_L("<textarea ");
2333   for (attr = qs_get_attr(doc,node);
2334        attr;
2335        attr = qs_get_next_attr(doc,attr)) {
2336
2337     char* name;
2338     char* value;
2339
2340     name  = qs_get_attr_name(doc,attr);
2341     value = qs_get_attr_value(doc,attr);
2342
2343     if (STRCASEEQ('n','N',"name",name)) {
2344       W_L(" name=\"");
2345       W_V(value);
2346       W_L("\"");
2347     }
2348     else if (STRCASEEQ('r','R',"rows",name)) {
2349       W_L(" rows=\"");
2350       W_V(value);
2351       W_L("\"");
2352     }
2353     else if (STRCASEEQ('c','C',"cols",name)) {
2354       W_L(" cols=\"");
2355       W_V(value);
2356       W_L("\"");
2357     }
2358   }
2359   W_L(">\r\n");
2360   return jhtml->out;
2361 }
2362
2363
2364 /**
2365  * It is a handler who processes the TEXTAREA tag.
2366  *
2367  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2368  *                     destination is specified.
2369  * @param node   [i]   The TEXTAREA tag node is specified.
2370  * @return The conversion result is returned.
2371  */
2372 static char*
2373 s_jhtml_end_textarea_tag(void* pdoc, Node* UNUSED(child)) 
2374 {
2375   jhtml_t*      jhtml;
2376   Doc*          doc;
2377   request_rec*  r;
2378
2379   jhtml = GET_JHTML(pdoc);
2380   doc   = jhtml->doc;
2381   r     = doc->r;
2382
2383   W_L("</textarea>\r\n");
2384   jhtml->textarea_flag--;
2385
2386   return jhtml->out;
2387 }
2388
2389
2390 /**
2391  * It is a handler who processes the B tag.
2392  *
2393  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2394  *                     destination is specified.
2395  * @param node   [i]   The B tag node is specified.
2396  * @return The conversion result is returned.
2397  */
2398 static char*
2399 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node)) 
2400 {
2401   jhtml_t*      jhtml;
2402   Doc*          doc;
2403   request_rec*  r;
2404
2405   jhtml = GET_JHTML(pdoc);
2406   doc   = jhtml->doc;
2407   r     = doc->r;
2408
2409   W_L("<b>");
2410   return jhtml->out;
2411 }
2412
2413
2414 /**
2415  * It is a handler who processes the B tag.
2416  *
2417  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
2418  *                     destination is specified.
2419  * @param node   [i]   The B tag node is specified.
2420  * @return The conversion result is returned.
2421  */
2422 static char*
2423 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child)) 
2424 {
2425   jhtml_t*      jhtml = GET_JHTML(pdoc);
2426   Doc*          doc   = jhtml->doc;
2427
2428   W_L("</b>\r\n");
2429   return jhtml->out;
2430 }
2431
2432 static char*
2433 s_jhtml_text_tag(void* pdoc, Node* child)
2434 {
2435   jhtml_t*     jhtml;
2436   Doc*         doc;
2437   char*        textval;
2438   char*        tmp;
2439   char*        tdst;
2440   char         one_byte[2];
2441   int          ii;
2442   int          tdst_len;
2443   request_rec* r;
2444
2445   jhtml = GET_JHTML(pdoc);
2446   doc   = jhtml->doc;
2447   r     = doc->r;
2448
2449   textval = qs_get_node_value(doc,child);
2450   textval = qs_trim_string(doc->buf.pool, textval);
2451   if (strlen(textval) == 0)
2452     return jhtml->out;
2453
2454   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2455   memset(tmp, 0, qs_get_node_size(doc,child)+1);
2456
2457   tdst     = qs_alloc_zero_byte_string(r);
2458   memset(one_byte, 0, sizeof(one_byte));
2459   tdst_len = 0;
2460
2461   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2462     char* out;
2463     int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2464     if (rtn) {
2465       tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2466       ii+=(rtn - 1);
2467       continue;
2468     }
2469
2470     if (is_sjis_kanji(textval[ii])) {
2471       one_byte[0] = textval[ii+0];
2472       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2473       one_byte[0] = textval[ii+1];
2474       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2475       ii++;
2476     }
2477     else 
2478     if (jhtml->pre_flag) {
2479       one_byte[0] = textval[ii+0];
2480       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2481     }
2482     else
2483     if (jhtml->textarea_flag) {
2484       one_byte[0] = textval[ii+0];
2485       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2486     }
2487     else {
2488       if (textval[ii] != '\r' && textval[ii] != '\n') {
2489         one_byte[0] = textval[ii+0];
2490         tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2491       }
2492     }
2493   }
2494   W_V(tdst);
2495   return jhtml->out;
2496 }
2497
2498
2499 /**
2500  * It is a handler who processes the BLOCKQUOTE tag.
2501  *
2502  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2503  *                     destination is specified.
2504  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2505  * @return The conversion result is returned.
2506  */
2507 static char *
2508 s_jhtml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
2509 {
2510   jhtml_t *jhtml = GET_JHTML(pdoc);
2511   Doc     *doc   = jhtml->doc;
2512   W_L("<blockquote>");
2513   return jhtml->out;
2514 }
2515
2516
2517 /**
2518  * It is a handler who processes the BLOCKQUOTE tag.
2519  *
2520  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2521  *                     destination is specified.
2522  * @param node   [i]   The BLOCKQUOTE tag node is specified.
2523  * @return The conversion result is returned.
2524  */
2525 static char *
2526 s_jhtml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
2527 {
2528   jhtml_t *jhtml = GET_JHTML(pdoc);
2529   Doc     *doc   = jhtml->doc;
2530   W_L("</blockquote>");
2531   return jhtml->out;
2532 }
2533
2534
2535 /**
2536  * It is a handler who processes the DIR tag.
2537  *
2538  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2539  *                     destination is specified.
2540  * @param node   [i]   The DIR tag node is specified.
2541  * @return The conversion result is returned.
2542  */
2543 static char *
2544 s_jhtml_start_dir_tag(void *pdoc, Node *UNUSED(child))
2545 {
2546   jhtml_t *jhtml = GET_JHTML(pdoc);
2547   Doc *doc = jhtml->doc;
2548   W_L("<dir>");
2549   return jhtml->out;
2550 }
2551
2552
2553 /**
2554  * It is a handler who processes the DIR tag.
2555  *
2556  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2557  *                     destination is specified.
2558  * @param node   [i]   The DIR tag node is specified.
2559  * @return The conversion result is returned.
2560  */
2561 static char *
2562 s_jhtml_end_dir_tag(void *pdoc, Node *UNUSED(child))
2563 {
2564   jhtml_t *jhtml = GET_JHTML(pdoc);
2565   Doc *doc = jhtml->doc;
2566   W_L("</dir>");
2567   return jhtml->out;
2568 }
2569
2570
2571 /**
2572  * It is a handler who processes the DL tag.
2573  *
2574  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2575  *                     destination is specified.
2576  * @param node   [i]   The DL tag node is specified.
2577  * @return The conversion result is returned.
2578  */
2579 static char *
2580 s_jhtml_start_dl_tag(void *pdoc, Node *UNUSED(child))
2581 {
2582   jhtml_t *jhtml = GET_JHTML(pdoc);
2583   Doc *doc = jhtml->doc;
2584   W_L("<dl>");
2585   return jhtml->out;
2586 }
2587
2588
2589 /**
2590  * It is a handler who processes the DL tag.
2591  *
2592  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2593  *                     destination is specified.
2594  * @param node   [i]   The DL tag node is specified.
2595  * @return The conversion result is returned.
2596  */
2597 static char *
2598 s_jhtml_end_dl_tag(void *pdoc, Node *UNUSED(child))
2599 {
2600   jhtml_t *jhtml = GET_JHTML(pdoc);
2601   Doc *doc = jhtml->doc;
2602   W_L("</dl>");
2603   return jhtml->out;
2604 }
2605
2606
2607 /**
2608  * It is a handler who processes the DT tag.
2609  *
2610  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2611  *                     destination is specified.
2612  * @param node   [i]   The DT tag node is specified.
2613  * @return The conversion result is returned.
2614  */
2615 static char *
2616 s_jhtml_start_dt_tag(void *pdoc, Node *UNUSED(child))
2617 {
2618   jhtml_t *jhtml = GET_JHTML(pdoc);
2619   Doc     *doc   = jhtml->doc;
2620   W_L("<dt>");
2621   return jhtml->out;
2622 }
2623
2624
2625 /**
2626  * It is a handler who processes the DT tag.
2627  *
2628  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2629  *                     destination is specified.
2630  * @param node   [i]   The DT tag node is specified.
2631  * @return The conversion result is returned.
2632  */
2633 static char *
2634 s_jhtml_end_dt_tag(void *pdoc, Node *UNUSED(child))
2635 {
2636   jhtml_t *jhtml = GET_JHTML(pdoc);
2637   return jhtml->out;
2638 }
2639
2640
2641 /**
2642  * It is a handler who processes the DD tag.
2643  *
2644  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2645  *                     destination is specified.
2646  * @param node   [i]   The DD tag node is specified.
2647  * @return The conversion result is returned.
2648  */
2649 static char *
2650 s_jhtml_start_dd_tag(void *pdoc, Node *UNUSED(child))
2651 {
2652   jhtml_t *jhtml = GET_JHTML(pdoc);
2653   Doc *doc = jhtml->doc;
2654   W_L("<dd>");
2655   return jhtml->out;
2656 }
2657
2658
2659 /**
2660  * It is a handler who processes the DD tag.
2661  *
2662  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2663  *                     destination is specified.
2664  * @param node   [i]   The DD tag node is specified.
2665  * @return The conversion result is returned.
2666  */
2667 static char *
2668 s_jhtml_end_dd_tag(void *pdoc, Node *UNUSED(child))
2669 {
2670   jhtml_t *jhtml = GET_JHTML(pdoc);
2671   return jhtml->out;
2672 }
2673
2674
2675 /**
2676  * It is a handler who processes the H1 tag.
2677  *
2678  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2679  *                     destination is specified.
2680  * @param node   [i]   The H1 tag node is specified.
2681  * @return The conversion result is returned.
2682  */
2683 static char *
2684 s_jhtml_start_h1_tag(void *pdoc, Node *node)
2685 {
2686   jhtml_t       *jhtml;
2687   Doc           *doc;
2688   request_rec   *r;
2689   Attr          *attr;
2690   char          *align = NULL;
2691
2692   jhtml   = GET_JHTML(pdoc);
2693   doc     = jhtml->doc;
2694   r       = doc->r;
2695
2696   for (attr = qs_get_attr(doc,node);
2697        attr;
2698        attr = qs_get_next_attr(doc,attr)) {
2699     char* name;
2700     char* value;
2701     name  = qs_get_attr_name(doc,attr);
2702     value = qs_get_attr_value(doc,attr);
2703     if (STRCASEEQ('a','A',"align", name)) {
2704       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2705         jhtml->h1_align_flag++;
2706         align = apr_pstrdup(doc->buf.pool, value);
2707         break;
2708       }
2709     }
2710   }
2711   if (align) {
2712     W_L("<div align=\"");
2713     W_V(align);
2714     W_L("\">");
2715   }
2716   return jhtml->out;
2717 }
2718
2719
2720 /**
2721  * It is a handler who processes the H1 tag.
2722  *
2723  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2724  *                     destination is specified.
2725  * @param node   [i]   The H1 tag node is specified.
2726  * @return The conversion result is returned.
2727  */
2728 static char *
2729 s_jhtml_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
2730 {
2731   jhtml_t*    jhtml;
2732   Doc*          doc;
2733   request_rec*  r;
2734
2735   jhtml = GET_JHTML(pdoc);
2736   doc     = jhtml->doc;
2737   r       = doc->r;
2738   
2739   if (jhtml->h1_align_flag) {
2740     jhtml->h1_align_flag--;
2741     W_L("</div>");
2742   }
2743   return jhtml->out;
2744 }
2745
2746
2747 /**
2748  * It is a handler who processes the H2 tag.
2749  *
2750  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2751  *                     destination is specified.
2752  * @param node   [i]   The H1 tag node is specified.
2753  * @return The conversion result is returned.
2754  */
2755 static char *
2756 s_jhtml_start_h2_tag(void *pdoc, Node *node)
2757 {
2758   jhtml_t       *jhtml;
2759   Doc           *doc;
2760   request_rec   *r;
2761   Attr          *attr;
2762   char          *align = NULL;
2763
2764   jhtml   = GET_JHTML(pdoc);
2765   doc     = jhtml->doc;
2766   r       = doc->r;
2767
2768   for (attr = qs_get_attr(doc,node);
2769        attr;
2770        attr = qs_get_next_attr(doc,attr)) {
2771     char* name;
2772     char* value;
2773     name  = qs_get_attr_name(doc,attr);
2774     value = qs_get_attr_value(doc,attr);
2775     if (STRCASEEQ('a','A',"align", name)) {
2776       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2777         jhtml->h2_align_flag++;
2778         align = apr_pstrdup(doc->buf.pool, value);
2779         break;
2780       }
2781     }
2782   }
2783   if (align) {
2784     W_L("<div align=\"");
2785     W_V(align);
2786     W_L("\">");
2787   }
2788   return jhtml->out;
2789 }
2790
2791
2792 /**
2793  * It is a handler who processes the H2 tag.
2794  *
2795  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2796  *                     destination is specified.
2797  * @param node   [i]   The H1 tag node is specified.
2798  * @return The conversion result is returned.
2799  */
2800 static char *
2801 s_jhtml_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
2802 {
2803   jhtml_t*    jhtml;
2804   Doc*          doc;
2805   request_rec*  r;
2806
2807   jhtml = GET_JHTML(pdoc);
2808   doc     = jhtml->doc;
2809   r       = doc->r;
2810   
2811   if (jhtml->h2_align_flag) {
2812     jhtml->h2_align_flag--;
2813     W_L("</div>");
2814   }
2815   return jhtml->out;
2816 }
2817
2818
2819 /**
2820  * It is a handler who processes the H3 tag.
2821  *
2822  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2823  *                     destination is specified.
2824  * @param node   [i]   The H1 tag node is specified.
2825  * @return The conversion result is returned.
2826  */
2827 static char *
2828 s_jhtml_start_h3_tag(void *pdoc, Node *node)
2829 {
2830   jhtml_t       *jhtml;
2831   Doc           *doc;
2832   request_rec   *r;
2833   Attr          *attr;
2834   char          *align = NULL;
2835
2836   jhtml   = GET_JHTML(pdoc);
2837   doc     = jhtml->doc;
2838   r       = doc->r;
2839
2840   for (attr = qs_get_attr(doc,node);
2841        attr;
2842        attr = qs_get_next_attr(doc,attr)) {
2843     char* name;
2844     char* value;
2845     name  = qs_get_attr_name(doc,attr);
2846     value = qs_get_attr_value(doc,attr);
2847     if (STRCASEEQ('a','A',"align", name)) {
2848       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2849         jhtml->h3_align_flag++;
2850         align = apr_pstrdup(doc->buf.pool, value);
2851         break;
2852       }
2853     }
2854   }
2855   if (align) {
2856     W_L("<div align=\"");
2857     W_V(align);
2858     W_L("\">");
2859   }
2860   return jhtml->out;
2861 }
2862
2863
2864 /**
2865  * It is a handler who processes the H3 tag.
2866  *
2867  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2868  *                     destination is specified.
2869  * @param node   [i]   The H1 tag node is specified.
2870  * @return The conversion result is returned.
2871  */
2872 static char *
2873 s_jhtml_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
2874 {
2875   jhtml_t*    jhtml;
2876   Doc*          doc;
2877   request_rec*  r;
2878
2879   jhtml = GET_JHTML(pdoc);
2880   doc     = jhtml->doc;
2881   r       = doc->r;
2882   
2883   if (jhtml->h3_align_flag) {
2884     jhtml->h3_align_flag--;
2885     W_L("</div>");
2886   }
2887   return jhtml->out;
2888 }
2889
2890
2891 /**
2892  * It is a handler who processes the H4 tag.
2893  *
2894  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2895  *                     destination is specified.
2896  * @param node   [i]   The H1 tag node is specified.
2897  * @return The conversion result is returned.
2898  */
2899 static char *
2900 s_jhtml_start_h4_tag(void *pdoc, Node *node)
2901 {
2902   jhtml_t       *jhtml;
2903   Doc           *doc;
2904   request_rec   *r;
2905   Attr          *attr;
2906   char          *align = NULL;
2907
2908   jhtml   = GET_JHTML(pdoc);
2909   doc     = jhtml->doc;
2910   r       = doc->r;
2911
2912   for (attr = qs_get_attr(doc,node);
2913        attr;
2914        attr = qs_get_next_attr(doc,attr)) {
2915     char* name;
2916     char* value;
2917     name  = qs_get_attr_name(doc,attr);
2918     value = qs_get_attr_value(doc,attr);
2919     if (STRCASEEQ('a','A',"align", name)) {
2920       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2921         jhtml->h4_align_flag++;
2922         align = apr_pstrdup(doc->buf.pool, value);
2923         break;
2924       }
2925     }
2926   }
2927   if (align) {
2928     W_L("<div align=\"");
2929     W_V(align);
2930     W_L("\">");
2931   }
2932   return jhtml->out;
2933 }
2934
2935
2936 /**
2937  * It is a handler who processes the H4 tag.
2938  *
2939  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2940  *                     destination is specified.
2941  * @param node   [i]   The H1 tag node is specified.
2942  * @return The conversion result is returned.
2943  */
2944 static char *
2945 s_jhtml_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
2946 {
2947   jhtml_t*    jhtml;
2948   Doc*          doc;
2949   request_rec*  r;
2950
2951   jhtml = GET_JHTML(pdoc);
2952   doc     = jhtml->doc;
2953   r       = doc->r;
2954   
2955   if (jhtml->h4_align_flag) {
2956     jhtml->h4_align_flag--;
2957     W_L("</div>");
2958   }
2959   return jhtml->out;
2960 }
2961
2962
2963 /**
2964  * It is a handler who processes the H5 tag.
2965  *
2966  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
2967  *                     destination is specified.
2968  * @param node   [i]   The H1 tag node is specified.
2969  * @return The conversion result is returned.
2970  */
2971 static char *
2972 s_jhtml_start_h5_tag(void *pdoc, Node *node)
2973 {
2974   jhtml_t       *jhtml;
2975   Doc           *doc;
2976   request_rec   *r;
2977   Attr          *attr;
2978   char          *align = NULL;
2979
2980   jhtml   = GET_JHTML(pdoc);
2981   doc     = jhtml->doc;
2982   r       = doc->r;
2983
2984   for (attr = qs_get_attr(doc,node);
2985        attr;
2986        attr = qs_get_next_attr(doc,attr)) {
2987     char* name;
2988     char* value;
2989     name  = qs_get_attr_name(doc,attr);
2990     value = qs_get_attr_value(doc,attr);
2991     if (STRCASEEQ('a','A',"align", name)) {
2992       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2993         jhtml->h5_align_flag++;
2994         align = apr_pstrdup(doc->buf.pool, value);
2995         break;
2996       }
2997     }
2998   }
2999   if (align) {
3000     W_L("<div align=\"");
3001     W_V(align);
3002     W_L("\">");
3003   }
3004   return jhtml->out;
3005 }
3006
3007
3008 /**
3009  * It is a handler who processes the H5 tag.
3010  *
3011  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3012  *                     destination is specified.
3013  * @param node   [i]   The H1 tag node is specified.
3014  * @return The conversion result is returned.
3015  */
3016 static char *
3017 s_jhtml_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
3018 {
3019   jhtml_t*    jhtml;
3020   Doc*          doc;
3021   request_rec*  r;
3022
3023   jhtml = GET_JHTML(pdoc);
3024   doc     = jhtml->doc;
3025   r       = doc->r;
3026   
3027   if (jhtml->h5_align_flag) {
3028     jhtml->h5_align_flag--;
3029     W_L("</div>");
3030   }
3031   return jhtml->out;
3032 }
3033
3034
3035 /**
3036  * It is a handler who processes the H6 tag.
3037  *
3038  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3039  *                     destination is specified.
3040  * @param node   [i]   The H1 tag node is specified.
3041  * @return The conversion result is returned.
3042  */
3043 static char *
3044 s_jhtml_start_h6_tag(void *pdoc, Node *node)
3045 {
3046   jhtml_t       *jhtml;
3047   Doc           *doc;
3048   request_rec   *r;
3049   Attr          *attr;
3050   char          *align = NULL;
3051
3052   jhtml   = GET_JHTML(pdoc);
3053   doc     = jhtml->doc;
3054   r       = doc->r;
3055
3056   for (attr = qs_get_attr(doc,node);
3057        attr;
3058        attr = qs_get_next_attr(doc,attr)) {
3059     char* name;
3060     char* value;
3061     name  = qs_get_attr_name(doc,attr);
3062     value = qs_get_attr_value(doc,attr);
3063     if (STRCASEEQ('a','A',"align", name)) {
3064       if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3065         jhtml->h6_align_flag++;
3066         align = apr_pstrdup(doc->buf.pool, value);
3067         break;
3068       }
3069     }
3070   }
3071   if (align) {
3072     W_L("<div align=\"");
3073     W_V(align);
3074     W_L("\">");
3075   }
3076   return jhtml->out;
3077 }
3078
3079
3080 /**
3081  * It is a handler who processes the H6 tag.
3082  *
3083  * @param pdoc  [i/o] The pointer to the JHTML structure at the output
3084  *                     destination is specified.
3085  * @param node   [i]   The H1 tag node is specified.
3086  * @return The conversion result is returned.
3087  */
3088 static char *
3089 s_jhtml_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
3090 {
3091   jhtml_t*    jhtml;
3092   Doc*          doc;
3093   request_rec*  r;
3094
3095   jhtml = GET_JHTML(pdoc);
3096   doc     = jhtml->doc;
3097   r       = doc->r;
3098   
3099   if (jhtml->h6_align_flag) {
3100     jhtml->h6_align_flag--;
3101     W_L("</div>");
3102   }
3103   return jhtml->out;
3104 }
3105 /*
3106  * vim:ts=2 et
3107  */