OSDN Git Service

* Added test code of the <ol> tag for SoftBank HTML converter.
[modchxj/mod_chxj.git] / src / chxj_chtml30.c
index e1d5f87..6feb851 100644 (file)
@@ -1,6 +1,6 @@
 /*
+ * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
- * Copyright (C) 2005 Atsushi Konno All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <apr_time.h>
 #include "chxj_chtml30.h"
 #include "chxj_hdml.h"
 #include "chxj_str_util.h"
 #include "chxj_encoding.h"
 
 #define GET_CHTML30(X) ((chtml30_t*)(X))
-
-static char* s_chtml30_start_html_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_html_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_meta_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_meta_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_textarea_tag (void* pdoc, Node* node);
-static char* s_chtml30_end_textarea_tag   (void* pdoc, Node* node);
-static char* s_chtml30_start_p_tag        (void* pdoc, Node* node);
-static char* s_chtml30_end_p_tag          (void* pdoc, Node* node);
-static char* s_chtml30_start_pre_tag      (void* pdoc, Node* node);
-static char* s_chtml30_end_pre_tag        (void* pdoc, Node* node);
-static char* s_chtml30_start_h1_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h1_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_h2_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h2_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_h3_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h3_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_h4_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h4_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_h5_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h5_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_h6_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_h6_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_ul_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_ul_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_ol_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_ol_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_li_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_li_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_head_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_head_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_title_tag    (void* pdoc, Node* node);
-static char* s_chtml30_end_title_tag      (void* pdoc, Node* node);
-static char* s_chtml30_start_base_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_base_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_body_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_body_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_a_tag        (void* pdoc, Node* node);
-static char* s_chtml30_end_a_tag          (void* pdoc, Node* node);
-static char* s_chtml30_start_br_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_br_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_tr_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_tr_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_font_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_font_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_form_tag     (void* pdoc, Node* node);
-static char* s_chtml30_end_form_tag       (void* pdoc, Node* node);
-static char* s_chtml30_start_input_tag    (void* pdoc, Node* node);
-static char* s_chtml30_end_input_tag      (void* pdoc, Node* node);
-static char* s_chtml30_start_center_tag   (void* pdoc, Node* node);
-static char* s_chtml30_end_center_tag     (void* pdoc, Node* node);
-static char* s_chtml30_start_hr_tag       (void* pdoc, Node* node);
-static char* s_chtml30_end_hr_tag         (void* pdoc, Node* node);
-static char* s_chtml30_start_img_tag      (void* pdoc, Node* node);
-static char* s_chtml30_end_img_tag        (void* pdoc, Node* node);
-static char* s_chtml30_start_select_tag   (void* pdoc, Node* node);
-static char* s_chtml30_end_select_tag     (void* pdoc, Node* node);
-static char* s_chtml30_start_option_tag   (void* pdoc, Node* node);
-static char* s_chtml30_end_option_tag     (void* pdoc, Node* node);
-static char* s_chtml30_start_div_tag      (void* pdoc, Node* node);
-static char* s_chtml30_end_div_tag        (void* pdoc, Node* node);
-static char* s_chtml30_chxjif_tag         (void* pdoc, Node* node); 
-static char* s_chtml30_text_tag           (void* pdoc, Node* node);
-
-static void  s_init_chtml30(chtml30_t* chtml, Doc* doc, request_rec* r, device_table* spec);
-
-static int   s_chtml30_search_emoji(chtml30_t* chtml, char* txt, char** rslt);
+#undef W_L
+#undef W_V
+#define W_L(X)          do { chtml30->out = BUFFERED_WRITE_LITERAL(chtml30->out, &doc->buf, (X)); } while(0)
+#define W_V(X)          do { chtml30->out = (X) ? BUFFERED_WRITE_VALUE(chtml30->out, &doc->buf, (X))  \
+                                                : BUFFERED_WRITE_LITERAL(chtml30->out, &doc->buf, ""); } while(0)
+extern tag_handler chtml20_handler[];
+
+static char *s_chtml30_start_html_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_html_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_meta_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_meta_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_textarea_tag (void *pdoc, Node *node);
+static char *s_chtml30_end_textarea_tag   (void *pdoc, Node *node);
+static char *s_chtml30_start_p_tag        (void *pdoc, Node *node);
+static char *s_chtml30_end_p_tag          (void *pdoc, Node *node);
+static char *s_chtml30_start_pre_tag      (void *pdoc, Node *node);
+static char *s_chtml30_end_pre_tag        (void *pdoc, Node *node);
+static char *s_chtml30_start_h1_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h1_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_h2_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h2_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_h3_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h3_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_h4_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h4_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_h5_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h5_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_h6_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_h6_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_ul_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_ul_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_ol_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_ol_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_li_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_li_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_head_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_head_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_title_tag    (void *pdoc, Node *node);
+static char *s_chtml30_end_title_tag      (void *pdoc, Node *node);
+static char *s_chtml30_start_base_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_base_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_body_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_body_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_a_tag        (void *pdoc, Node *node);
+static char *s_chtml30_end_a_tag          (void *pdoc, Node *node);
+static char *s_chtml30_start_br_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_br_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_tr_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_tr_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_font_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_font_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_form_tag     (void *pdoc, Node *node);
+static char *s_chtml30_end_form_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_input_tag    (void *pdoc, Node *node);
+static char *s_chtml30_end_input_tag      (void *pdoc, Node *node);
+static char *s_chtml30_start_center_tag   (void *pdoc, Node *node);
+static char *s_chtml30_end_center_tag     (void *pdoc, Node *node);
+static char *s_chtml30_start_hr_tag       (void *pdoc, Node *node);
+static char *s_chtml30_end_hr_tag         (void *pdoc, Node *node);
+static char *s_chtml30_start_img_tag      (void *pdoc, Node *node);
+static char *s_chtml30_end_img_tag        (void *pdoc, Node *node);
+static char *s_chtml30_start_select_tag   (void *pdoc, Node *node);
+static char *s_chtml30_end_select_tag     (void *pdoc, Node *node);
+static char *s_chtml30_start_option_tag   (void *pdoc, Node *node);
+static char *s_chtml30_end_option_tag     (void *pdoc, Node *node);
+static char *s_chtml30_start_div_tag      (void *pdoc, Node *node);
+static char *s_chtml30_end_div_tag        (void *pdoc, Node *node);
+static char *s_chtml30_chxjif_tag         (void *pdoc, Node *node); 
+static char *s_chtml30_text_tag           (void *pdoc, Node *node);
+static char *s_chtml30_start_blockquote_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_blockquote_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_dir_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_dir_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_dl_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_dl_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_dt_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_dt_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_dd_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_dd_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_marquee_tag(void *pdoc, Node *node);
+static char *s_chtml30_end_marquee_tag  (void *pdoc, Node *node);
+static char *s_chtml30_start_blink_tag  (void *pdoc, Node *node);
+static char *s_chtml30_end_blink_tag    (void *pdoc, Node *node);
+static char *s_chtml30_start_menu_tag   (void *pdoc, Node *node);
+static char *s_chtml30_end_menu_tag     (void *pdoc, Node *node);
+static char *s_chtml30_start_plaintext_tag       (void *pdoc, Node *node);
+static char *s_chtml30_start_plaintext_tag_inner (void *pdoc, Node *node);
+static char *s_chtml30_end_plaintext_tag         (void *pdoc, Node *node);
+
+static void  s_init_chtml30(chtml30_t *chtml, Doc *doc, request_rec *r, device_table *spec);
+
+static int   s_chtml30_search_emoji(chtml30_t *chtml, char *txt, char **rslt);
 
 
 tag_handler chtml30_handler[] = {
@@ -303,6 +329,61 @@ tag_handler chtml30_handler[] = {
     NULL,
     NULL,
   },
+  /* tagDT */
+  {
+    s_chtml30_start_dt_tag,
+    s_chtml30_end_dt_tag,
+  },
+  /* tagLEGEND */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagLABEL */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagBLOCKQUOTE */
+  {
+    s_chtml30_start_blockquote_tag,
+    s_chtml30_end_blockquote_tag,
+  },
+  /* tagDIR */
+  {
+    s_chtml30_start_dir_tag,
+    s_chtml30_end_dir_tag,
+  },
+  /* tagDL */
+  {
+    s_chtml30_start_dl_tag,
+    s_chtml30_end_dl_tag,
+  },
+  /* tagDD */
+  {
+    s_chtml30_start_dd_tag,
+    s_chtml30_end_dd_tag,
+  },
+  /* tagMENU */
+  {
+    s_chtml30_start_menu_tag,
+    s_chtml30_end_menu_tag,
+  },
+  /* tagPLAINTEXT */
+  {
+    s_chtml30_start_plaintext_tag,
+    s_chtml30_end_plaintext_tag,
+  },
+  /* tagBLINK */
+  {
+    s_chtml30_start_blink_tag,
+    s_chtml30_end_blink_tag,
+  },
+  /* tagMARQUEE */
+  {
+    s_chtml30_start_marquee_tag,
+    s_chtml30_end_marquee_tag,
+  },
 };
 
 
@@ -331,6 +412,7 @@ chxj_exchange_chtml30(
   chtml30_t chtml30;
   Doc       doc;
 
+  DBG(r, "start chxj_exchange_chtml30()");
 
   /*--------------------------------------------------------------------------*/
   /* If qrcode xml                                                            */
@@ -339,6 +421,7 @@ chxj_exchange_chtml30(
   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
   if (dst) {
     DBG(r,"i found qrcode xml");
+    DBG(r, "end chxj_exchange_chtml30()");
     return dst;
   }
   DBG(r,"not found qrcode xml");
@@ -351,7 +434,7 @@ chxj_exchange_chtml30(
   chtml30.entryp = entryp;
   chtml30.cookie = cookie;
 
-  ap_set_content_type(r, "text/html; charset=Windows-31J");
+  chxj_set_content_type(r, "text/html; charset=Windows-31J");
 
   /*--------------------------------------------------------------------------*/
   /* The character string of the input is analyzed.                           */
@@ -366,6 +449,7 @@ chxj_exchange_chtml30(
 #ifdef DUMP_LOG
   chxj_dump_out("[src] CHTML -> CHTML3.0", ss, srclen);
 #endif
+  chxj_buffered_write_init(r->pool, &doc.buf);
 
   qs_parse_string(&doc,ss, strlen(ss));
 
@@ -373,15 +457,18 @@ chxj_exchange_chtml30(
   /* It converts it from CHTML to CHTML.                                      */
   /*--------------------------------------------------------------------------*/
   chxj_node_exchange(spec,r,(void*)&chtml30, &doc, qs_get_root(&doc), 0);
-  dst = chtml30.out;
+  chtml30.out = chxj_buffered_write_flush(chtml30.out, &doc.buf);
+  dst = apr_pstrdup(r->pool, chtml30.out);
+  chxj_buffered_write_terminate(&doc.buf);
 
   qs_all_free(&doc,QX_LOGMARK);
 
-  if (dst == NULL) 
-    return apr_pstrdup(r->pool,ss);
-
-  if (strlen(dst) == 0)
+  if (dst == NULL) {
+    dst = apr_pstrdup(r->pool,ss);
+  }
+  if (strlen(dst) == 0) {
     dst = apr_psprintf(r->pool, "\n");
+  }
 
   *dstlen = strlen(dst);
 
@@ -389,6 +476,7 @@ chxj_exchange_chtml30(
   chxj_dump_out("[src] CHTML -> CHTML3.0", dst, *dstlen);
 #endif
 
+  DBG(r, "end chxj_exchange_chtml30()");
   return dst;
 }
 
@@ -413,7 +501,7 @@ s_init_chtml30(chtml30_t* chtml30, Doc* doc, request_rec* r, device_table* spec)
   chtml30->doc  = doc;
   chtml30->spec = spec;
   chtml30->out  = qs_alloc_zero_byte_string(r);
-  chtml30->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
+  chtml30->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
   chtml30->doc->parse_mode = PARSE_MODE_CHTML;
 }
 
@@ -483,7 +571,7 @@ s_chtml30_search_emoji(chtml30_t* chtml30, char* txt, char** rslt)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_html_tag(void* pdoc, Node* node
+s_chtml30_start_html_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -496,8 +584,7 @@ s_chtml30_start_html_tag(void* pdoc, Node* node)
   /*--------------------------------------------------------------------------*/
   /* start HTML tag                                                           */
   /*--------------------------------------------------------------------------*/
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<html>\n", NULL);
-
+  W_L("<html>");
   return chtml30->out;
 }
 
@@ -511,7 +598,7 @@ s_chtml30_start_html_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_html_tag(void* pdoc, Node* child
+s_chtml30_end_html_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -521,8 +608,7 @@ s_chtml30_end_html_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</html>\n", NULL);
-
+  W_L("</html>");
   return chtml30->out;
 }
 
@@ -552,7 +638,7 @@ s_chtml30_start_meta_tag(void* pdoc, Node* node)
   content_type_flag = 0;
   refresh_flag      = 0;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<meta", NULL);
+  W_L("<meta");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -567,78 +653,72 @@ s_chtml30_start_meta_tag(void* pdoc, Node* node)
     name   = qs_get_attr_name(doc,attr);
     value  = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(name, "http-equiv") == 0) {
-      /*----------------------------------------------------------------------*/
-      /* CHTML 2.0                                                            */
-      /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " http-equiv=\"", 
-                                 value,
-                                 "\"",
-                                 NULL);
-
-      if ((*value == 'c' || *value == 'C') 
-      && strcasecmp(value, "content-type") == 0)
-        content_type_flag = 1;
-
-      if ((*value == 'r' || *value == 'R')
-      && strcasecmp(value, "refresh") == 0)
-        refresh_flag = 1;
-    }
-    else
-    if (strcasecmp(name, "content") == 0) {
-      if (content_type_flag) {
-        chtml30->out = apr_pstrcat(r->pool,
-                                   chtml30->out,
-                                   " ",
-                                   name,
-                                   "=\"",
-                                  "text/html; charset=Windows-31J",
-                                  "\"",
-                                  NULL);
+    switch(*name) {
+    case 'h':
+    case 'H':
+      if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
+        /*----------------------------------------------------------------------*/
+        /* CHTML 2.0                                                            */
+        /*----------------------------------------------------------------------*/
+        W_L(" http-equiv=\"");
+        W_V(value);
+        W_L("\"");
+        if (STRCASEEQ('c','C',"content-type", value))
+          content_type_flag = 1;
+  
+        if (STRCASEEQ('r','R',"refresh", value))
+          refresh_flag = 1;
       }
-      else
-      if (refresh_flag) {
-        char* buf;
-        char* sec;
-        char* url;
-
-        buf = apr_pstrdup(r->pool, value);
-
-        url = strchr(buf, ';');
-        if (url) {
-          sec = apr_pstrdup(r->pool, buf);
-          sec[url-buf] = 0;
-          url++;
-          url = chxj_encoding_parameter(r, url);
-          url = chxj_add_cookie_parameter(r, url, chtml30->cookie);
-          chtml30->out = apr_pstrcat(r->pool,
-                                     chtml30->out,
-                                     " ",
-                                     name,
-                                     "=\"",
-                                     sec,
-                                     ";",
-                                     url,
-                                     "\"",
-                                     NULL);
+      break;
+
+    case 'c':
+    case 'C':
+      if (strcasecmp(name, "content") == 0 && value && *value) {
+        if (content_type_flag) {
+          W_L(" ");
+          W_V(name);
+          W_L("=\"text/html; charset=Windows-31J\"");
+        }
+        else
+        if (refresh_flag) {
+          char* buf;
+          char* sec;
+          char* url;
+  
+          buf = apr_pstrdup(r->pool, value);
+  
+          url = strchr(buf, ';');
+          if (url) {
+            sec = apr_pstrdup(r->pool, buf);
+            sec[url-buf] = 0;
+            url++;
+            url = chxj_encoding_parameter(r, url);
+            url = chxj_add_cookie_parameter(r, url, chtml30->cookie);
+            W_L(" ");
+            W_V(name);
+            W_L("=\"");
+            W_V(sec);
+            W_L(";");
+            W_V(url);
+            W_L("\"");
+          }
+        }
+        else {
+          W_L(" ");
+          W_V(name);
+          W_L("=\"");
+          W_V(value);
+          W_L("\"");
         }
       }
-      else {
-        chtml30->out = apr_pstrcat(r->pool,
-                                   chtml30->out,
-                                   " ",
-                                   name,
-                                   "=\"",
-                                   value,
-                                   "\"",
-                                   NULL);
-      }
+      break;
+
+    default:
+      break;
     }
   }
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+  W_L(">");
 
   return chtml30->out;
 }
@@ -653,7 +733,7 @@ s_chtml30_start_meta_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_meta_tag(void* pdoc, Node* child
+s_chtml30_end_meta_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
 
@@ -672,7 +752,7 @@ s_chtml30_end_meta_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_head_tag(void* pdoc, Node* node
+s_chtml30_start_head_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -682,7 +762,7 @@ s_chtml30_start_head_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<head>\r\n", NULL);
+  W_L("<head>");
 
   return chtml30->out;
 }
@@ -696,8 +776,8 @@ s_chtml30_start_head_tag(void* pdoc, Node* node)
  * @param node   [i]   The HEAD tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_head_tag(void* pdoc, Node* node
+static char *
+s_chtml30_end_head_tag(void *pdoc, Node *UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -707,7 +787,7 @@ s_chtml30_end_head_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</head>\r\n", NULL);
+  W_L("</head>");
 
   return chtml30->out;
 }
@@ -722,7 +802,7 @@ s_chtml30_end_head_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_title_tag(void* pdoc, Node* node
+s_chtml30_start_title_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -732,7 +812,7 @@ s_chtml30_start_title_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<title>", NULL);
+  W_L("<title>");
 
   return chtml30->out;
 }
@@ -747,7 +827,7 @@ s_chtml30_start_title_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_title_tag(void* pdoc, Node* child
+s_chtml30_end_title_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -757,7 +837,7 @@ s_chtml30_end_title_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</title>\r\n", NULL);
+  W_L("</title>");
 
   return chtml30->out;
 }
@@ -771,45 +851,34 @@ s_chtml30_end_title_tag(void* pdoc, Node* child)
  * @param node   [i]   The BASE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_base_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_base_tag(void *pdoc, Node *node) 
 {
-  Attr*         attr;
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  Attr *attr;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<base", NULL);
-
+  W_L("<base");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-
-    char* name;
-    char* value;
-
-    name = qs_get_attr_name(doc,attr);
-    value = qs_get_attr_value(doc,attr);
-
-    if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " href=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+    char *name = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('h','H',"href", name)) {
+      W_L(" href=\"");
+      W_V(value);
+      W_L("\"");
     }
   }
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, " >\r\n", NULL);
-
+  W_L(">");
   return chtml30->out;
 }
 
@@ -823,7 +892,7 @@ s_chtml30_start_base_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_base_tag(void* pdoc, Node* child
+s_chtml30_end_base_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
 
@@ -841,85 +910,66 @@ s_chtml30_end_base_tag(void* pdoc, Node* child)
  * @param node   [i]   The BODY tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_body_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_body_tag(void *pdoc, Node *node) 
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  Attr*         attr;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<body", NULL);
 
+  W_L("<body");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name;
-    char* value;
-
-    name   = qs_get_attr_name(doc,attr);
-    value  = qs_get_attr_value(doc,attr);
-
-    if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor") == 0) {
+    char *name   = qs_get_attr_name(doc,attr);
+    char *value  = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('b','B', "bgcolor", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 2.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " bgcolor=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" bgcolor=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "text") == 0) {
+    else if (STRCASEEQ('t','T', "text", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 2.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " text=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" text=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "link") == 0) {
+    else if (STRCASEEQ('l','L',"link", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 2.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " link=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" link=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "alink") == 0) {
+    else if (STRCASEEQ('a','A',"alink", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 4.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
-    else
-    if (strcasecmp(name, "vlink") == 0) {
+    else if (STRCASEEQ('v','V',"vlink", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 4.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
   }
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">\r\n", NULL);
-
+  W_L(">");
   return chtml30->out;
 }
 
@@ -932,18 +982,18 @@ s_chtml30_start_body_tag(void* pdoc, Node* node)
  * @param node   [i]   The BODY tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_body_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_body_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</body>\r\n", NULL);
+  W_L("</body>");
 
   return chtml30->out;
 }
@@ -969,7 +1019,7 @@ s_chtml30_start_a_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<a", NULL);
+  W_L("<a");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -984,124 +1034,98 @@ s_chtml30_start_a_tag(void* pdoc, Node* node)
     name  = qs_get_attr_name(doc,attr);
     value = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(name, "name") == 0) {
+    if (STRCASEEQ('n','N',"name", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML1.0                                                             */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " name=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" name=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "href") == 0) {
+    else if (STRCASEEQ('h','H',"href", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML1.0                                                             */
       /*----------------------------------------------------------------------*/
       value = chxj_encoding_parameter(r, value);
       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " href=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" href=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "accesskey") == 0) {
+    else if (STRCASEEQ('a','A',"accesskey", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML1.0                                                             */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      " accesskey=\"", 
-                      value, 
-                      "\"", 
-                      NULL);
+      W_L(" accesskey=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "cti") == 0) {
+    else if (STRCASEEQ('c','C',"cti", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 2.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                                 " cti=\"", 
-                                 value, 
-                                 "\"", 
-                                 NULL);
+      W_L(" cti=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "ijam") == 0) {
+    else if (STRCASEEQ('i','I',"ijam", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
-    else
-    if (strcasecmp(name, "utn") == 0) {
+    else if (STRCASEEQ('u','U',"utn", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /* It is special only for CHTML.                                        */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                                 chtml30->out, 
-                      " utn ", 
-                      NULL);
+      W_L(" utn ");
     }
-    else
-    if (strcasecmp(name, "telbook") == 0) {
+    else if (STRCASEEQ('t','T',"telbook", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /*----------------------------------------------------------------------*/
       /* not support */
     }
-    else
-    if (strcasecmp(name, "kana") == 0) {
+    else if (STRCASEEQ('k','K',"kana", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /*----------------------------------------------------------------------*/
       /* not support */
     }
-    else
-    if (strcasecmp(name, "email") == 0) {
+    else if (STRCASEEQ('e','E',"email", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /*----------------------------------------------------------------------*/
       /* not support */
     }
-    else
-    if (strcasecmp(name, "ista") == 0) {
+    else if (STRCASEEQ('i','I',"ista", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 4.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
-    else
-    if (strcasecmp(name, "ilet") == 0) {
+    else if (STRCASEEQ('i','I',"ilet", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 5.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
-    else
-    if (strcasecmp(name, "iswf") == 0) {
+    else if (STRCASEEQ('i','I',"iswf", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 5.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
-    else
-    if (strcasecmp(name, "irst") == 0) {
+    else if (STRCASEEQ('i','I',"irst", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 5.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
   }
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+
+  W_L(">");
 
   return chtml30->out;
 }
@@ -1116,7 +1140,7 @@ s_chtml30_start_a_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_a_tag(void* pdoc, Node* child
+s_chtml30_end_a_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1126,7 +1150,7 @@ s_chtml30_end_a_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</a>", NULL);
+  W_L("</a>");
 
   return chtml30->out;
 }
@@ -1140,19 +1164,39 @@ s_chtml30_end_a_tag(void* pdoc, Node* child)
  * @param node   [i]   The BR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_br_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_br_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
+  W_L("<br");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name;
+    char *value;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<br>\r\n", NULL);
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
 
+    if (STRCASEEQ('c','C',"clear",name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
+        W_L(" clear=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -1165,13 +1209,10 @@ s_chtml30_start_br_tag(void* pdoc, Node* node)
  * @param node   [i]   The BR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_br_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_br_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-
-  chtml30 = GET_CHTML30(pdoc);
-
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
   return chtml30->out;
 }
 
@@ -1185,7 +1226,7 @@ s_chtml30_end_br_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_tr_tag(void* pdoc, Node* node
+s_chtml30_start_tr_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
 
@@ -1204,7 +1245,7 @@ s_chtml30_start_tr_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_tr_tag(void* pdoc, Node* child
+s_chtml30_end_tr_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1214,7 +1255,7 @@ s_chtml30_end_tr_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<br>\r\n", NULL);
+  W_L("<br>");
 
   return chtml30->out;
 }
@@ -1240,7 +1281,7 @@ s_chtml30_start_font_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<font", NULL);
+  W_L("<font");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1248,19 +1289,19 @@ s_chtml30_start_font_tag(void* pdoc, Node* node)
   for (attr = qs_get_attr(doc,node);
        attr; 
        attr = qs_get_next_attr(doc,attr)) {
-    char* name  = qs_get_attr_name(doc,attr);
-    char* value = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(name, "color") == 0) {
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      " color=\"", 
-                      value, 
-                      "\"", 
-                      NULL);
+    char* name;
+    char* value;
+
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+
+    if (STRCASEEQ('c','C',"color", name)) {
+      W_L(" color=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "size") == 0) {
+    else if (STRCASEEQ('s','S',"size", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 5.0                                                            */
       /*----------------------------------------------------------------------*/
@@ -1268,7 +1309,7 @@ s_chtml30_start_font_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+  W_L(">");
 
   return chtml30->out;
 }
@@ -1283,7 +1324,7 @@ s_chtml30_start_font_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_font_tag(void* pdoc, Node* child
+s_chtml30_end_font_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1293,7 +1334,7 @@ s_chtml30_end_font_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</font>", NULL);
+  W_L("</font>");
 
   return chtml30->out;
 }
@@ -1307,67 +1348,54 @@ s_chtml30_end_font_tag(void* pdoc, Node* child)
  * @param node   [i]   The FORM tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_form_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_form_tag(void *pdoc, Node *node) 
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  Attr*         attr;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<form", NULL);
-
+  W_L("<form");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* name = qs_get_attr_name(doc,attr);
-    charvalue = qs_get_attr_value(doc,attr);
-    if (strcasecmp(name, "action") == 0) {
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"action", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
       value = chxj_encoding_parameter(r, value);
       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      " action=\"",
-                      value,
-                      "\"", 
-                      NULL);
+      W_L(" action=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "method") == 0) {
+    else if (STRCASEEQ('m','M',"method", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      " method=\"",
-                      value,
-                      "\"", 
-                      NULL);
+      W_L(" method=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "utn") == 0) {
+    else if (STRCASEEQ('u','U',"utn", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 3.0                                                            */
       /* It is special only for CHTML.                                        */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      " utn ", 
-                      NULL);
+      W_L(" utn");
     }
   }
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
-
+  W_L(">");
   return chtml30->out;
 }
 
@@ -1381,7 +1409,7 @@ s_chtml30_start_form_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_form_tag(void* pdoc, Node* child
+s_chtml30_end_form_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1391,7 +1419,7 @@ s_chtml30_end_form_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</form>", NULL);
+  W_L("</form>");
 
   return chtml30->out;
 }
@@ -1405,32 +1433,28 @@ s_chtml30_end_form_tag(void* pdoc, Node* child)
  * @param node   [i]   The INPUT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_input_tag(void* pdoc, Node* node) 
-{
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  char*         max_length  = NULL;
-  char*         type        = NULL;
-  char*         name        = NULL;
-  char*         value       = NULL;
-  char*         istyle      = NULL;
-  char*         size        = NULL;
-  char*         checked     = NULL;
-  char*         accesskey   = NULL;
+static char *
+s_chtml30_start_input_tag(void *pdoc, Node *node) 
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  char *max_length  = NULL;
+  char *type        = NULL;
+  char *name        = NULL;
+  char *value       = NULL;
+  char *istyle      = NULL;
+  char *size        = NULL;
+  char *checked     = NULL;
+  char *accesskey   = NULL;
 
   chtml30   = GET_CHTML30(pdoc);
   doc       = chtml30->doc;
   r         = doc->r;
-
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<input", NULL);
-
+  W_L("<input");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
-
   type       = qs_get_type_attr(doc, node, r);
   name       = qs_get_name_attr(doc, node, r);
   value      = qs_get_value_attr(doc,node,r);
@@ -1440,79 +1464,71 @@ s_chtml30_start_input_tag(void* pdoc, Node* node)
   accesskey  = qs_get_accesskey_attr(doc, node, r);
   size       = qs_get_size_attr(doc, node, r);
 
-  if (type)
-    chtml30->out = apr_pstrcat(r->pool,
-                    chtml30->out, 
-                    " type=\"", 
-                    type, 
-                    "\" ", 
-                    NULL);
-
-  if (size)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, 
-                    " size=\"", 
-                    size, 
-                    "\" ", 
-                    NULL);
-  if (name)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, 
-                    " name=\"", 
-                    name, 
-                    "\" ", 
-                    NULL);
-
-  if (value)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, 
-                    " value=\"", 
-                    value, 
-                    "\" ", 
-                    NULL);
-
-  if (accesskey)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, 
-                    " accesskey=\"", 
-                    accesskey, "\" ", 
-                    NULL);
-
-  if (istyle != NULL)
+  if (type) {
+    type = qs_trim_string(doc->buf.pool, type);
+    if (type && (STRCASEEQ('t','T',"text",    type) ||
+                 STRCASEEQ('p','P',"password",type) ||
+                 STRCASEEQ('c','C',"checkbox",type) ||
+                 STRCASEEQ('r','R',"radio",   type) ||
+                 STRCASEEQ('h','H',"hidden",  type) ||
+                 STRCASEEQ('s','S',"submit",  type) ||
+                 STRCASEEQ('r','R',"reset",   type))) {
+      W_L(" type=\"");
+      W_V(type);
+      W_L("\"");
+    }
+  }
+  if (size && *size) {
+    W_L(" size=\"");
+    W_V(size);
+    W_L("\"");
+  }
+  if (name && *name) {
+    W_L(" name=\"");
+    W_V(name);
+    W_L("\"");
+  }
+  if (value && *value) {
+    W_L(" value=\"");
+    W_V(value);
+    W_L("\"");
+  }
+  if (accesskey && *accesskey) {
+    W_L(" accesskey=\"");
+    W_V(accesskey);
+    W_L("\"");
+  }
+  if (istyle) {
     /*------------------------------------------------------------------------*/
     /* CHTML 2.0                                                              */
     /*------------------------------------------------------------------------*/
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, 
-                    " istyle=\"", 
-                    istyle, "\" ", 
-                    NULL);
+    if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
+      W_L(" istyle=\"");
+      W_V(istyle);
+      W_L("\"");
+    }
+  }
 
   /*--------------------------------------------------------------------------*/
   /* The figure is default for the password.                                  */
   /*--------------------------------------------------------------------------*/
-  if (max_length) {
-    if (chxj_chk_numeric(max_length) != 0)
+  if (max_length && *max_length) {
+    if (chxj_chk_numeric(max_length) != 0) {
       max_length = apr_psprintf(r->pool, "0");
-
-    if (istyle != NULL && strcasecmp(istyle, "1") == 0)
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      apr_psprintf(r->pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2), 
-                      NULL);
-    else 
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, 
-                      apr_psprintf(r->pool, " maxlength=\"%d\"", chxj_atoi(max_length)), 
-                      NULL);
+    }
+    if (istyle != NULL && *istyle == '1') {
+      char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
+      W_V(vv);
+    }
+    else  {
+      char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
+      W_V(vv);
+    }
   }
-
-  if (checked)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, " checked ", NULL);
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, " >", NULL);
-
+  if (checked) {
+    W_L(" checked");
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -1526,7 +1542,7 @@ s_chtml30_start_input_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_input_tag(void* pdoc, Node* child
+s_chtml30_end_input_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
 
@@ -1545,7 +1561,7 @@ s_chtml30_end_input_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_center_tag(void* pdoc, Node* node
+s_chtml30_start_center_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1555,7 +1571,7 @@ s_chtml30_start_center_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<center>", NULL);
+  W_L("<center>");
 
   return chtml30->out;
 }
@@ -1570,7 +1586,7 @@ s_chtml30_start_center_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_center_tag(void* pdoc, Node* child
+s_chtml30_end_center_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1580,7 +1596,7 @@ s_chtml30_end_center_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</center>", NULL);
+  W_L("</center>");
 
   return chtml30->out;
 }
@@ -1606,57 +1622,59 @@ s_chtml30_start_hr_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<hr ", NULL);
+  W_L("<hr");
  
   for (attr = qs_get_attr(doc,node);
        attr; 
        attr = qs_get_next_attr(doc,attr)) {
     char* name = qs_get_attr_name(doc,attr);
     char* value = qs_get_attr_value(doc,attr);
-    if (strcasecmp(name, "align") == 0) {
+
+    if (STRCASEEQ('a','A',"align", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool,
-                        chtml30->out, 
-                        " align=\"", value, "\" ", NULL);
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+      }
     }
-    else
-    if (strcasecmp(name, "size") == 0) {
+    else if (STRCASEEQ('s','S',"size", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool,
-                        chtml30->out, 
-                        " size=\"", value, "\" ", NULL);
+      if (value && *value) {
+        W_L(" size=\"");
+        W_V(value);
+        W_L("\"");
+      }
     }
-    else
-    if (strcasecmp(name, "width") == 0) {
+    else if (STRCASEEQ('w','W',"width", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool,
-                        chtml30->out, 
-                        " width=\"", value, "\" ", NULL);
+      if (value && *value) {
+        W_L(" width=\"");
+        W_V(value);
+        W_L("\"");
+      }
     }
-    else
-    if (strcasecmp(name, "noshade") == 0) {
+    else if (STRCASEEQ('n','N',"noshade", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool,
-                        chtml30->out, 
-                        " noshade ", NULL);
+      W_L(" noshade");
     }
-    else
-    if (strcasecmp(name, "color") == 0) {
+    else if (STRCASEEQ('c','C',"color", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 4.0                                                            */
       /*----------------------------------------------------------------------*/
       /* ignore */
     }
   }
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, " >", NULL);
+
+  W_L(">");
 
   return chtml30->out;
 }
@@ -1671,7 +1689,7 @@ s_chtml30_start_hr_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_hr_tag(void* pdoc, Node* child
+s_chtml30_end_hr_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
 
@@ -1689,16 +1707,16 @@ s_chtml30_end_hr_tag(void* pdoc, Node* child)
  * @param node   [i]   The IMG tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_img_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_img_tag(void *pdoc, Node *node) 
 {
 #ifndef IMG_NOT_CONVERT_FILENAME
-  device_tablespec;
+  device_table *spec;
 #endif
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  Attr*         attr;
+  chtml30_t    *chtml30;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
@@ -1707,9 +1725,7 @@ s_chtml30_start_img_tag(void* pdoc, Node* node)
   spec    = chtml30->spec;
 #endif
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<img", NULL);
-
+  W_L("<img");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
@@ -1719,78 +1735,95 @@ s_chtml30_start_img_tag(void* pdoc, Node* node)
     char* name  = qs_get_attr_name(doc,attr);
     char* value = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(name, "src") == 0) {
+    if (STRCASEEQ('s','S',"src", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
 #ifdef IMG_NOT_CONVERT_FILENAME
       value = chxj_encoding_parameter(r, value);
       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
+      if (value) {
+        value = apr_psprintf(r->pool,
+                             "%s%c%s=true",
+                             value,
+                             (strchr(value, '?')) ? '&' : '?',
+                             CHXJ_COOKIE_NOUPDATE_PARAM);
+        W_L(" src=\"");
+        W_V(value);
+        W_L("\"");
+      }
 
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " src=\"",value,"\"", NULL);
 #else
       value = chxj_img_conv(r,spec,value);
       value = chxj_encoding_parameter(r, value);
       value = chxj_add_cookie_parameter(r, value, chtml30->cookie);
-
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " src=\"", 
-                      value, NULL);
-
-      chtml30->out = apr_pstrcat(r->pool, chtml30->out, "\"", NULL);
+      if (value) {
+        value = apr_psprintf(r->pool,
+                             "%s%c%s=true",
+                             value,
+                             (strchr(value, '?')) ? '&' : '?',
+                             CHXJ_COOKIE_NOUPDATE_PARAM);
+      }
+      W_L(" src=\"");
+      W_V(value);
+      W_L("\"");
 #endif
     }
-    else
-    if (strcasecmp(name, "align" ) == 0) {
+    else if (STRCASEEQ('a','A',"align", name)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " align=\"",value,"\"", NULL);
+      if (value && (STRCASEEQ('t','T',"top",   value) ||
+                    STRCASEEQ('m','M',"middle",value) ||
+                    STRCASEEQ('b','B',"bottom",value) ||
+                    STRCASEEQ('l','L',"left",  value) ||
+                    STRCASEEQ('r','R',"right", value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+      }
     }
-    else
-    if (strcasecmp(name, "width" ) == 0) {
+    else if (STRCASEEQ('w','W',"width", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " width=\"",value,"\"", NULL);
+      W_L(" width=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "height") == 0) {
+    else if (STRCASEEQ('h','H', "height", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " height=\"",value,"\"", NULL);
+      W_L(" height=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "hspace") == 0) {
+    else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " hspace=\"",value,"\"", NULL);
+      W_L(" hspace=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "vspace") == 0) {
+    else if (STRCASEEQ('v','V',"vspace", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " vspace=\"",value,"\"", NULL);
+      W_L(" vspace=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "alt"   ) == 0) {
+    else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0                                                            */
       /*----------------------------------------------------------------------*/
-      chtml30->out = apr_pstrcat(r->pool, 
-                      chtml30->out, " alt=\"",value,"\"", NULL);
+      W_L(" alt=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else
-    if (strcasecmp(name, "align" ) == 0) {
+    else if (STRCASEEQ('a','A',"align", name) && value && *value) {
       /*----------------------------------------------------------------------*/
       /* CHTML 4.0                                                            */
       /*----------------------------------------------------------------------*/
@@ -1798,7 +1831,7 @@ s_chtml30_start_img_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+  W_L(">");
 
   return chtml30->out;
 }
@@ -1813,7 +1846,7 @@ s_chtml30_start_img_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_img_tag(void* pdoc, Node* child
+s_chtml30_end_img_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
 
@@ -1834,57 +1867,53 @@ s_chtml30_end_img_tag(void* pdoc, Node* child)
 static char*
 s_chtml30_start_select_tag(void* pdoc, Node* child)
 {
+  chtml30_t   *chtml30 = GET_CHTML30(pdoc);
+  Doc         *doc     = chtml30->doc;
+  char        *size    = NULL;
+  char        *name    = NULL;
+  char        *multiple    = NULL;
+  Attr        *attr;
 
-  char*         size;
-  char*         name;
-  Attr*         attr;
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-
-  chtml30 = GET_CHTML30(pdoc);
-  doc     = chtml30->doc;
-  r       = doc->r;
-  size    = NULL;
-  name    = NULL;
+  W_L("<select");
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<select", NULL);
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
     char* nm  = qs_get_attr_name(doc,attr);
     char* val = qs_get_attr_value(doc,attr);
-
-    if (strcasecmp(nm, "size") == 0) {
+    if (STRCASEEQ('s','S',"size", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 version 2.0                                                */
       /*----------------------------------------------------------------------*/
-      size = apr_pstrdup(r->pool, val);
+      size = apr_pstrdup(doc->buf.pool, val);
     }
-    else
-    if (strcasecmp(nm, "name") == 0) {
+    else if (STRCASEEQ('n','N',"name", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 version 2.0                                                */
       /*----------------------------------------------------------------------*/
-      name = apr_pstrdup(r->pool, val);
+      name = apr_pstrdup(doc->buf.pool, val);
     }
-    else
-    if (strcasecmp(nm, "multiple") == 0) {
+    else if (STRCASEEQ('m','M',"multiple", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 version 2.0                                                */
       /*----------------------------------------------------------------------*/
-      /* not support */
+      multiple = apr_pstrdup(doc->buf.pool, val);
     }
   }
-
-  if (size)
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, " size=\"",size,"\"", NULL);
-
-  if (name)
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, " name=\"",name,"\"", NULL);
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">\n", NULL);
-
+  if (size && *size) {
+    W_L(" size=\"");
+    W_V(size);
+    W_L("\"");
+  }
+  if (name && *name) {
+    W_L(" name=\"");
+    W_V(name);
+    W_L("\"");
+  }
+  if (multiple) {
+    W_L(" multiple");
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -1898,7 +1927,7 @@ s_chtml30_start_select_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_select_tag(void* pdoc, Node* child)
+s_chtml30_end_select_tag(void* pdoc, Node* UNUSED(child))
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -1907,9 +1936,7 @@ s_chtml30_end_select_tag(void* pdoc, Node* child)
   chtml30 = GET_CHTML30(pdoc);
   doc   = chtml30->doc;
   r     = doc->r;
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</select>\n", NULL);
-
+  W_L("</select>");
   return chtml30->out;
 }
 
@@ -1922,15 +1949,15 @@ s_chtml30_end_select_tag(void* pdoc, Node* child)
  * @param node   [i]   The OPTION tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_option_tag(void* pdoc, Node* child)
+static char *
+s_chtml30_start_option_tag(void *pdoc, Node *child)
 {
-  Attr*         attr;
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  char*         selected;
-  char*         value;
+  Attr *attr;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  char *selected;
+  char *value;
 
   chtml30    = GET_CHTML30(pdoc);
   doc        = chtml30->doc;
@@ -1938,37 +1965,35 @@ s_chtml30_start_option_tag(void* pdoc, Node* child)
   selected   = NULL;
   value      = NULL;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<option", NULL);
+  W_L("<option");
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
     char* nm  = qs_get_attr_name(doc,attr);
     char* val = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(nm, "selected") == 0) {
+    if (STRCASEEQ('s','S',"selected", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 version 2.0                                                */
       /*----------------------------------------------------------------------*/
-      selected = apr_pstrdup(r->pool, val);
+      selected = apr_pstrdup(doc->buf.pool, val);
     }
-    else
-    if (strcasecmp(nm, "value") == 0) {
+    else if (STRCASEEQ('v','V',"value", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 version 2.0                                                */
       /*----------------------------------------------------------------------*/
-      value = apr_pstrdup(r->pool, val);
+      value = apr_pstrdup(doc->buf.pool, val);
     }
   }
-
-  if (value)
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, " value=\"",value,"\"", NULL);
-  else
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, " value=\"\"", NULL);
-
-  if (selected)
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, " selected ", NULL);
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+  if (value && *value) {
+    W_L(" value=\"");
+    W_V(value);
+    W_L("\"");
+  }
+  if (selected) {
+    W_L(" selected");
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -1983,7 +2008,7 @@ s_chtml30_start_option_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_option_tag(void* pdoc, Node* child)
+s_chtml30_end_option_tag(void* pdoc, Node* UNUSED(child))
 {
   chtml30_t*    chtml30;
 
@@ -2004,40 +2029,44 @@ s_chtml30_end_option_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_div_tag(void* pdoc, Node* child)
+s_chtml30_start_div_tag(void *pdoc, Node *child)
 {
-  Attr*         attr;
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-  char*         align;
+  Attr          *attr;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  char          *align;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
   align   = NULL;
 
+  W_L("<div");
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<div", NULL);
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
     char* nm  = qs_get_attr_name(doc,attr);
     char* val = qs_get_attr_value(doc,attr);
 
-    if (strcasecmp(nm, "align") == 0) {
+    if (STRCASEEQ('a','A',"align", nm)) {
       /*----------------------------------------------------------------------*/
       /* CHTML 1.0 (W3C version 3.2)                                          */
       /*----------------------------------------------------------------------*/
-      align = apr_pstrdup(r->pool, val);
+      if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
+        align = apr_pstrdup(doc->buf.pool, val);
+      }
     }
   }
 
-  if (align)
-    chtml30->out = apr_pstrcat(r->pool, 
-                    chtml30->out, " align=\"", align, "\"", NULL);
+  if (align) {
+    W_L(" align=\"");
+    W_V(align);
+    W_L("\"");
+  }
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">", NULL);
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2052,7 +2081,7 @@ s_chtml30_start_div_tag(void* pdoc, Node* child)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_div_tag(void* pdoc, Node* node)
+s_chtml30_end_div_tag(void* pdoc, Node* UNUSED(node))
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2062,7 +2091,7 @@ s_chtml30_end_div_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</div>\n", NULL);
+  W_L("</div>");
 
   return chtml30->out;
 }
@@ -2077,7 +2106,7 @@ s_chtml30_end_div_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_start_ul_tag(void* pdoc, Node* node
+s_chtml30_start_ul_tag(void* pdoc, Node* UNUSED(node)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2087,7 +2116,7 @@ s_chtml30_start_ul_tag(void* pdoc, Node* node)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<ul>", NULL);
+  W_L("<ul>");
 
   return chtml30->out;
 }
@@ -2101,18 +2130,18 @@ s_chtml30_start_ul_tag(void* pdoc, Node* node)
  * @param node   [i]   The UL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_ul_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_ul_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</ul>", NULL);
+  W_L("</ul>");
 
   return chtml30->out;
 }
@@ -2126,23 +2155,24 @@ s_chtml30_end_ul_tag(void* pdoc, Node* child)
  * @param node   [i]   The PRE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_pre_tag(void* pdoc, Node* node
+static char *
+s_chtml30_start_pre_tag(void *pdoc, Node *UNUSED(node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
   chtml30->pre_flag++;
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<pre>", NULL);
+  W_L("<pre>");
 
   return chtml30->out;
 }
 
+
 /**
  * It is a handler who processes the PRE tag.
  *
@@ -2151,18 +2181,18 @@ s_chtml30_start_pre_tag(void* pdoc, Node* node)
  * @param node   [i]   The PRE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_pre_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_pre_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</pre>", NULL);
+  W_L("</pre>");
   chtml30->pre_flag--;
 
   return chtml30->out;
@@ -2177,18 +2207,41 @@ s_chtml30_end_pre_tag(void* pdoc, Node* child)
  * @param node   [i]   The P tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_p_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_p_tag(void *pdoc, Node *node) 
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
+  char          *align = NULL;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<p>", NULL);
+  W_L("<p");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *nm  = qs_get_attr_name(doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", nm)) {
+      /*----------------------------------------------------------------------*/
+      /* CHTML 1.0 (W3C version 3.2)                                          */
+      /*----------------------------------------------------------------------*/
+      if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
+        align = apr_pstrdup(doc->buf.pool, val);
+        break;
+      }
+    }
+  }
+  if (align) {
+    W_L(" align=\"");
+    W_V(align);
+    W_L("\"");
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2203,7 +2256,7 @@ s_chtml30_start_p_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_p_tag(void* pdoc, Node* child
+s_chtml30_end_p_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2213,7 +2266,7 @@ s_chtml30_end_p_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</p>", NULL);
+  W_L("</p>");
 
   return chtml30->out;
 }
@@ -2227,18 +2280,39 @@ s_chtml30_end_p_tag(void* pdoc, Node* child)
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_ol_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_ol_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<ol>", NULL);
+  W_L("<ol");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
+      W_L(" type=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('s','S',"start",name) && value && *value) {
+      W_L(" start=\"");
+      W_V(value);
+      W_L("\"");
+    }
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2252,18 +2326,18 @@ s_chtml30_start_ol_tag(void* pdoc, Node* node)
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_ol_tag(void* pdoc, Node* node
+static char *
+s_chtml30_end_ol_tag(void *pdoc, Node *UNUSED(node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</ol>", NULL);
+  W_L("</ol>");
 
   return chtml30->out;
 }
@@ -2277,18 +2351,39 @@ s_chtml30_end_ol_tag(void* pdoc, Node* node)
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_li_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_li_tag(void *pdoc, Node *node) 
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<li>", NULL);
+  W_L("<li");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
+      W_L(" type=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('v','V',"value", name) && value && *value) {
+      W_L(" value=\"");
+      W_V(value);
+      W_L("\"");
+    }
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2302,19 +2397,11 @@ s_chtml30_start_li_tag(void* pdoc, Node* node)
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_li_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_li_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
-
+  chtml30_t     *chtml30;
   chtml30 = GET_CHTML30(pdoc);
-  doc     = chtml30->doc;
-  r       = doc->r;
-
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</li>", NULL);
-
   return chtml30->out;
 }
 
@@ -2327,18 +2414,36 @@ s_chtml30_end_li_tag(void* pdoc, Node* child)
  * @param node   [i]   The H1 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h1_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h1_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h1>\r\n", NULL);
+  W_L("<h1");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char* name;
+    char* value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2353,7 +2458,7 @@ s_chtml30_start_h1_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_h1_tag(void* pdoc, Node* child
+s_chtml30_end_h1_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2363,7 +2468,7 @@ s_chtml30_end_h1_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h1>\r\n", NULL);
+  W_L("</h1>");
 
   return chtml30->out;
 }
@@ -2377,19 +2482,36 @@ s_chtml30_end_h1_tag(void* pdoc, Node* child)
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h2_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h2_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t     *chtml30;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h2>\r\n", NULL);
-
+  W_L("<h2");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char* name;
+    char* value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -2402,18 +2524,18 @@ s_chtml30_start_h2_tag(void* pdoc, Node* node)
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_h2_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_h2_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h2>\r\n", NULL);
+  W_L("</h2>");
 
   return chtml30->out;
 }
@@ -2427,18 +2549,36 @@ s_chtml30_end_h2_tag(void* pdoc, Node* child)
  * @param node   [i]   The H3 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h3_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h3_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h3>\r\n", NULL);
+  W_L("<h3");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char* name;
+    char* value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2452,18 +2592,18 @@ s_chtml30_start_h3_tag(void* pdoc, Node* node)
  * @param node   [i]   The H3 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_h3_tag(void* pdoc, Node* child) 
+static char *
+s_chtml30_end_h3_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc   = chtml30->doc;
   r     = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h3>\r\n", NULL);
+  W_L("</h3>");
 
   return chtml30->out;
 }
@@ -2477,19 +2617,36 @@ s_chtml30_end_h3_tag(void* pdoc, Node* child)
  * @param node   [i]   The H4 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h4_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h4_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h4>\r\n", NULL);
-
+  W_L("<h4");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char* name;
+    char* value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -2502,18 +2659,18 @@ s_chtml30_start_h4_tag(void* pdoc, Node* node)
  * @param node   [i]   The H4 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_end_h4_tag(void* pdoc, Node* child
+static char *
+s_chtml30_end_h4_tag(void *pdoc, Node *UNUSED(child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h4>\r\n", NULL);
+  W_L("</h4>");
 
   return chtml30->out;
 }
@@ -2527,19 +2684,36 @@ s_chtml30_end_h4_tag(void* pdoc, Node* child)
  * @param node   [i]   The H5 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h5_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h5_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h5>\r\n", NULL);
-
+  W_L("<h5");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name;
+    char *value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -2553,7 +2727,7 @@ s_chtml30_start_h5_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_h5_tag(void* pdoc, Node* child
+s_chtml30_end_h5_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2563,7 +2737,7 @@ s_chtml30_end_h5_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h5>\r\n", NULL);
+  W_L("</h5>");
 
   return chtml30->out;
 }
@@ -2577,19 +2751,36 @@ s_chtml30_end_h5_tag(void* pdoc, Node* child)
  * @param node   [i]   The H6 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml30_start_h6_tag(void* pdoc, Node* node) 
+static char *
+s_chtml30_start_h6_tag(void *pdoc, Node *node)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
 
   chtml30 = GET_CHTML30(pdoc);
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<h6>\r\n", NULL);
-
+  W_L("<h6");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name;
+    char *value;
+    name  = qs_get_attr_name(doc,attr);
+    value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml30->out;
 }
 
@@ -2603,7 +2794,7 @@ s_chtml30_start_h6_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_h6_tag(void* pdoc, Node* child
+s_chtml30_end_h6_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2613,7 +2804,7 @@ s_chtml30_end_h6_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</h6>\r\n", NULL);
+  W_L("</h6>");
 
   return chtml30->out;
 }
@@ -2640,29 +2831,42 @@ s_chtml30_start_textarea_tag(void* pdoc, Node* node)
   r       = doc->r;
 
   chtml30->textarea_flag++;
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<textarea ", NULL);
 
+  W_L("<textarea");
   for (attr = qs_get_attr(doc,node);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
 
     char* name  = qs_get_attr_name(doc,attr);
     char* value = qs_get_attr_value(doc,attr);
-
-    if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
-      chtml30->out = apr_pstrcat(r->pool, chtml30->out, " name=\"",value,"\"", NULL);
+    if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
+      W_L(" accesskey=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
+      W_L(" istyle=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('n','N',"name", name) && value && *value) {
+      W_L(" name=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else 
-    if ((*name == 'r' || *name == 'R') && strcasecmp(name, "rows") == 0) {
-      chtml30->out = apr_pstrcat(r->pool, chtml30->out, " rows=\"",value,"\"", NULL);
+    else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
+      W_L(" rows=\"");
+      W_V(value);
+      W_L("\"");
     }
-    else 
-    if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cols") == 0) {
-      chtml30->out = apr_pstrcat(r->pool, chtml30->out, " cols=\"",value,"\"", NULL);
+    else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
+      W_L(" cols=\"");
+      W_V(value);
+      W_L("\"");
     }
   }
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, ">\r\n", NULL);
+  W_L(">");
 
   return chtml30->out;
 }
@@ -2677,7 +2881,7 @@ s_chtml30_start_textarea_tag(void* pdoc, Node* node)
  * @return The conversion result is returned.
  */
 static char*
-s_chtml30_end_textarea_tag(void* pdoc, Node* child
+s_chtml30_end_textarea_tag(void* pdoc, Node* UNUSED(child)
 {
   chtml30_t*    chtml30;
   Doc*          doc;
@@ -2687,7 +2891,7 @@ s_chtml30_end_textarea_tag(void* pdoc, Node* child)
   doc     = chtml30->doc;
   r       = doc->r;
 
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</textarea>\r\n", NULL);
+  W_L("</textarea>");
   chtml30->textarea_flag--;
 
   return chtml30->out;
@@ -2709,23 +2913,23 @@ s_chtml30_chxjif_tag(void* pdoc, Node* node)
   for (child = qs_get_child_node(doc, node);
        child;
        child = qs_get_next_node(doc, child)) {
-    chtml30->out = apr_pstrcat(r->pool, chtml30->out, child->otext, NULL);
+    W_V(child->otext);
     s_chtml30_chxjif_tag(chtml30, child);
   }
 
   return NULL;
 }
 
-static char*
-s_chtml30_text_tag(void* pdoc, Node* child)
+static char *
+s_chtml30_text_tag(void *pdoc, Node *child)
 {
-  chtml30_t*    chtml30;
-  Doc*          doc;
-  request_rec*  r;
+  chtml30_t *chtml30;
+  Doc *doc;
+  request_rec *r;
 
-  char*   textval;
-  char*   tmp;
-  char*   tdst;
+  char *textval;
+  char *tmp;
+  char *tdst;
   char    one_byte[2];
   int     ii;
   int     tdst_len;
@@ -2735,9 +2939,9 @@ s_chtml30_text_tag(void* pdoc, Node* child)
   r       = doc->r;
   
   textval = qs_get_node_value(doc,child);
-  textval = qs_trim_string(chtml30->doc->r, textval);
-  if (strlen(textval) == 0)
+  if (strlen(textval) == 0) {
     return chtml30->out;
+  }
   
   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
   memset(tmp, 0, qs_get_node_size(doc,child)+1);
@@ -2775,11 +2979,391 @@ s_chtml30_text_tag(void* pdoc, Node* child)
       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
     }
   }
-  chtml30->out = apr_pstrcat(r->pool, chtml30->out, tdst, NULL);
+  W_V(tdst);
+
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the BLOCKQUOTE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLOCKQUOTE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  W_L("<blockquote>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the BLOCKQUOTE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLOCKQUOTE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  W_L("</blockquote>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DIR tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DIR tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("<dir>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DIR tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DIR tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("</dir>");
+  return chtml30->out;
+}
+
 
+/**
+ * It is a handler who processes the DL tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DL tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_dl_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("<dl>");
   return chtml30->out;
 }
 
+
+/**
+ * It is a handler who processes the DL tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DL tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_dl_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("</dl>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_dt_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  W_L("<dt>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_dt_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30;
+  chtml30 = GET_CHTML30(pdoc);
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DD tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DD tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_dd_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("<dd>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the DD tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The DD tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_dd_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the MARQUEE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MARQUEE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_marquee_tag(void *pdoc, Node *node)
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  Attr *attr;
+  W_L("<marquee");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name   = qs_get_attr_name(doc,attr);
+    char *value  = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('d','D',"direction", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
+        W_L(" direction=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+    else if (STRCASEEQ('b','B',"behavior",name)) {
+      if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
+        W_L(" behavior=\""); 
+        W_V(value);
+        W_L("\"");
+      }
+    }
+    else if (STRCASEEQ('l','L',"loop",name)) {
+      if (value && *value) {
+        W_L(" loop=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+  }
+  W_L(">");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the MARQUEE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MARQUEE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_marquee_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("</marquee>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a hanblinker who processes the BLINK tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLINK tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_blink_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("<blink>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a hanblinker who processes the BLINK tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLINK tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_blink_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("</blink>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the MENU tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MENU tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  W_L("<menu>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the MENU tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MENU tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  Doc *doc = chtml30->doc;
+  W_L("</menu>");
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the PLAINTEXT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PLAINTEXT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_start_plaintext_tag(void *pdoc, Node *node)
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  W_L("<plaintext>");
+  s_chtml30_start_plaintext_tag_inner(pdoc,node);
+  return chtml30->out;
+}
+
+static char *
+s_chtml30_start_plaintext_tag_inner(void *pdoc, Node *node)
+{
+  chtml30_t *chtml30;
+  Doc *doc;
+  Node *child;
+  chtml30 = GET_CHTML30(pdoc);
+  doc     = chtml30->doc;
+  for (child = qs_get_child_node(doc, node);
+       child;
+       child = qs_get_next_node(doc, child)) {
+    W_V(child->otext);
+    s_chtml30_start_plaintext_tag_inner(pdoc, child);
+  }
+  return chtml30->out;
+}
+
+
+/**
+ * It is a handler who processes the PLAINTEXT tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PLAINTEXT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml30_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml30_t *chtml30 = GET_CHTML30(pdoc);
+  return chtml30->out;
+}
 /*
  * vim:ts=2 et
  */