OSDN Git Service

* Bug with wrong treatment of QUERY_STRING when POST is done to another site.
[modchxj/mod_chxj.git] / src / chxj_chtml10.c
index 69afe62..5482b65 100644 (file)
 #include "chxj_qr_code.h"
 #include "chxj_cookie.h"
 #include "chxj_encoding.h"
+#include "chxj_str_util.h"
+#include "chxj_buffered_write.h"
 
 #define GET_CHTML10(X) ((chtml10_t*)(X))
-
-static char* s_chtml10_start_html_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_html_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_meta_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_meta_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_textarea_tag (void* pdoc, Node* node);
-static char* s_chtml10_end_textarea_tag   (void* pdoc, Node* node);
-static char* s_chtml10_start_p_tag        (void* pdoc, Node* node);
-static char* s_chtml10_end_p_tag          (void* pdoc, Node* node);
-static char* s_chtml10_start_pre_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_pre_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_ul_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_ul_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_li_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_li_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_ol_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_ol_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h1_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h1_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h2_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h2_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h3_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h3_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h4_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h4_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h5_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h5_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_h6_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_h6_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_head_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_head_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_title_tag    (void* pdoc, Node* node);
-static char* s_chtml10_end_title_tag      (void* pdoc, Node* node);
-static char* s_chtml10_start_base_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_base_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_body_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_body_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_a_tag        (void* pdoc, Node* node);
-static char* s_chtml10_end_a_tag          (void* pdoc, Node* node);
-static char* s_chtml10_start_br_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_br_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_tr_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_tr_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_font_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_font_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_input_tag    (void* pdoc, Node* node);
-static char* s_chtml10_end_input_tag      (void* pdoc, Node* node);
-static char* s_chtml10_start_form_tag     (void* pdoc, Node* node);
-static char* s_chtml10_end_form_tag       (void* pdoc, Node* node);
-static char* s_chtml10_start_center_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_center_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_hr_tag       (void* pdoc, Node* node);
-static char* s_chtml10_end_hr_tag         (void* pdoc, Node* node);
-static char* s_chtml10_start_img_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_img_tag        (void* pdoc, Node* node);
-static char* s_chtml10_start_select_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_select_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_option_tag   (void* pdoc, Node* node);
-static char* s_chtml10_end_option_tag     (void* pdoc, Node* node);
-static char* s_chtml10_start_div_tag      (void* pdoc, Node* node);
-static char* s_chtml10_end_div_tag        (void* pdoc, Node* node);
-
-static void  s_init_chtml10(chtml10_t* chtml, Doc* doc, request_rec* r, device_table* spec);
-
-static int   s_chtml10_search_emoji(chtml10_t* chtml, char* txt, char** rslt);
-static char* s_chtml10_chxjif_tag        (void* pdoc, Node* node);
-static char* s_chtml10_text              (void* pdoc, Node* node);
+#define W10_L(X)          do { chtml10->out = BUFFERED_WRITE_LITERAL(chtml10->out, &doc->buf, (X)); } while(0)
+#define W10_V(X)          do { chtml10->out = (X) ? BUFFERED_WRITE_VALUE(chtml10->out, &doc->buf, (X))  \
+                                                  : BUFFERED_WRITE_LITERAL(chtml10->out, &doc->buf, ""); } while(0)
+
+static char *s_chtml10_start_html_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_html_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_meta_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_meta_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_textarea_tag (void *pdoc, Node *node);
+static char *s_chtml10_end_textarea_tag   (void *pdoc, Node *node);
+static char *s_chtml10_start_p_tag        (void *pdoc, Node *node);
+static char *s_chtml10_end_p_tag          (void *pdoc, Node *node);
+static char *s_chtml10_start_pre_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_pre_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_ul_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_ul_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_li_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_li_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_ol_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_ol_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h1_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h1_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h2_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h2_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h3_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h3_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h4_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h4_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h5_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h5_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_h6_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_h6_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_head_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_head_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_title_tag    (void *pdoc, Node *node);
+static char *s_chtml10_end_title_tag      (void *pdoc, Node *node);
+static char *s_chtml10_start_base_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_base_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_body_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_body_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_a_tag        (void *pdoc, Node *node);
+static char *s_chtml10_end_a_tag          (void *pdoc, Node *node);
+static char *s_chtml10_start_br_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_br_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_tr_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_tr_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_font_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_font_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_input_tag    (void *pdoc, Node *node);
+static char *s_chtml10_end_input_tag      (void *pdoc, Node *node);
+static char *s_chtml10_start_form_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_form_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_center_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_center_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_hr_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_hr_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_img_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_img_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_select_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_select_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_option_tag   (void *pdoc, Node *node);
+static char *s_chtml10_end_option_tag     (void *pdoc, Node *node);
+static char *s_chtml10_start_div_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_div_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_blockquote_tag(void *pdoc, Node *node);
+static char *s_chtml10_end_blockquote_tag (void *pdoc, Node *node);
+static char *s_chtml10_start_dir_tag      (void *pdoc, Node *node);
+static char *s_chtml10_end_dir_tag        (void *pdoc, Node *node);
+static char *s_chtml10_start_dl_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dl_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_dt_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dt_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_dd_tag       (void *pdoc, Node *node);
+static char *s_chtml10_end_dd_tag         (void *pdoc, Node *node);
+static char *s_chtml10_start_menu_tag     (void *pdoc, Node *node);
+static char *s_chtml10_end_menu_tag       (void *pdoc, Node *node);
+static char *s_chtml10_start_plaintext_tag(void *pdoc, Node *node);
+static char *s_chtml10_start_plaintext_tag_inner(void  *pdoc, Node *node);
+static char *s_chtml10_end_plaintext_tag  (void *pdoc, Node *node);
+
+static void  s_init_chtml10(chtml10_t *chtml, Doc *doc, request_rec *r, device_table *spec);
+
+static int   s_chtml10_search_emoji(chtml10_t *chtml, char *txt, char **rslt);
+static char *s_chtml10_chxjif_tag        (void *pdoc, Node *node);
+static char *s_chtml10_text              (void *pdoc, Node *node);
 
 tag_handler chtml10_handler[] = {
   /* tagHTML */
@@ -304,8 +324,8 @@ tag_handler chtml10_handler[] = {
   },
   /* tagDT */
   {
-    NULL,
-    NULL,
+    s_chtml10_start_dt_tag,
+    s_chtml10_end_dt_tag,
   },
   /* tagLEGEND */
   {
@@ -317,6 +337,46 @@ tag_handler chtml10_handler[] = {
     NULL,
     NULL,
   },
+  /* tagBLOCKQUOTE */
+  {
+    s_chtml10_start_blockquote_tag,
+    s_chtml10_end_blockquote_tag,
+  },
+  /* tagDIR */
+  {
+    s_chtml10_start_dir_tag,
+    s_chtml10_end_dir_tag,
+  },
+  /* tagDL */
+  {
+    s_chtml10_start_dl_tag,
+    s_chtml10_end_dl_tag,
+  },
+  /* tagDD */
+  {
+    s_chtml10_start_dd_tag,
+    s_chtml10_end_dd_tag,
+  },
+  /* tagMENU */
+  {
+    s_chtml10_start_menu_tag,
+    s_chtml10_end_menu_tag,
+  },
+  /* tagPLAINTEXT */
+  {
+    s_chtml10_start_plaintext_tag,
+    s_chtml10_end_plaintext_tag,
+  },
+  /* tagBLINK */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagMARQUEE */
+  {
+    NULL,
+    NULL,
+  },
 };
 
 
@@ -329,25 +389,27 @@ tag_handler chtml10_handler[] = {
  * @param src   [i]   The character string before the converting is appointed.
  * @return The character string after the converting is returned.
  */
-char*
+char *
 chxj_exchange_chtml10(
-  request_rec*        r,
-  device_table*       spec,
-  const char*         src,
+  request_rec         *r,
+  device_table        *spec,
+  const char          *src,
   apr_size_t          srclen,
-  apr_size_t*         dstlen,
-  chxjconvrule_entryentryp,
+  apr_size_t          *dstlen,
+  chxjconvrule_entry  *entryp,
   cookie_t*           cookie
 )
 {
-  char*     dst;
-  char*     ss;
+  char      *dst;
+  char      *ss;
   chtml10_t chtml10;
   Doc       doc;
+  apr_time_t t;
 
   dst = NULL;
 
-  DBG1(r, "start chxj_exchange_chtml10() cookie_id=[%s]", (cookie) ? cookie->cookie_id : "");
+  t = apr_time_now();
+  DBG(r, "start chxj_exchange_chtml10() cookie_id=[%s]", (cookie) ? cookie->cookie_id : "");
 
   /*--------------------------------------------------------------------------*/
   /* If qrcode xml                                                            */
@@ -367,7 +429,7 @@ chxj_exchange_chtml10(
   chtml10.entryp    = entryp;
   chtml10.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.                           */
@@ -385,17 +447,20 @@ chxj_exchange_chtml10(
 
   qs_parse_string(&doc,ss, strlen(ss));
 
+  chxj_buffered_write_init(r->pool, &doc.buf);
   /*--------------------------------------------------------------------------*/
   /* It converts it from CHTML to CHTML.                                      */
   /*--------------------------------------------------------------------------*/
   chxj_node_exchange(spec,r,(void*)&chtml10, &doc, qs_get_root(&doc), 0);
-  dst = chtml10.out;
-
+  chtml10.out = chxj_buffered_write_flush(chtml10.out, &doc.buf);
+  dst = apr_pstrdup(r->pool, chtml10.out);
+  chxj_buffered_write_terminate(&doc.buf);
 
   qs_all_free(&doc,QX_LOGMARK);
 
-  if (!dst)
+  if (!dst) {
     return apr_pstrdup(r->pool,ss);
+  }
 
   if (strlen(dst) == 0) {
     dst = apr_psprintf(r->pool, "\n");
@@ -406,7 +471,7 @@ chxj_exchange_chtml10(
   chxj_dump_out("[dst] CHTML -> CHTML1.0", dst, *dstlen);
 #endif
 
-  DBG1(r, "end   chxj_exchange_chtml10() cookie_id=[%s]", (cookie) ? cookie->cookie_id : "");
+  DBG(r, "end   chxj_exchange_chtml10() cookie_id=[%s] time=[%" APR_INT64_T_FMT  "]", (cookie) ? cookie->cookie_id : "", apr_time_now() - t);
 
   return dst;
 }
@@ -424,10 +489,10 @@ chxj_exchange_chtml10(
  */
 static void
 s_init_chtml10(
-  chtml10_t*    chtml10, 
-  Doc*          doc, 
-  request_rec*  r, 
-  device_tablespec)
+  chtml10_t     *chtml10, 
+  Doc           *doc, 
+  request_rec   *r, 
+  device_table  *spec)
 {
   memset(doc,     0, sizeof(Doc));
   memset(chtml10, 0, sizeof(chtml10_t));
@@ -436,7 +501,7 @@ s_init_chtml10(
   chtml10->doc  = doc;
   chtml10->spec = spec;
   chtml10->out  = qs_alloc_zero_byte_string(r);
-  chtml10->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
+  chtml10->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
   chtml10->doc->parse_mode = PARSE_MODE_CHTML;
 }
 
@@ -453,11 +518,11 @@ s_init_chtml10(
  * @return When corresponding EMOJI exists, it returns it excluding 0. 
  */
 static int
-s_chtml10_search_emoji(chtml10_t* chtml10, char* txt, char** rslt)
+s_chtml10_search_emoji(chtml10_t *chtml10, char *txt, char **rslt)
 {
-  emoji_t*      ee;
-  request_rec*  r;
-  device_tablespec;
+  emoji_t       *ee;
+  request_rec   *r;
+  device_table  *spec;
   int           len;
 
   spec = chtml10->spec;
@@ -506,12 +571,12 @@ s_chtml10_search_emoji(chtml10_t* chtml10, char* txt, char** rslt)
  * @param node   [i]   The HTML tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_html_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_html_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -520,7 +585,7 @@ s_chtml10_start_html_tag(void* pdoc, Node* UNUSED(node))
   /*--------------------------------------------------------------------------*/
   /* start HTML tag                                                           */
   /*--------------------------------------------------------------------------*/
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<html>\n", NULL);
+  W10_L("<html>");
 
   return chtml10->out;
 }
@@ -534,19 +599,19 @@ s_chtml10_start_html_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The HTML tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_html_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_html_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</html>\n", NULL);
+  W10_L("</html>");
 
   return chtml10->out;
 }
@@ -560,12 +625,10 @@ s_chtml10_end_html_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The META tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_meta_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_meta_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_t* chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* ignore */
 
@@ -581,12 +644,10 @@ s_chtml10_start_meta_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The META tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_meta_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t* chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -600,18 +661,18 @@ s_chtml10_end_meta_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The HEAD tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_head_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_head_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<head>\r\n", NULL);
+  W10_L("<head>");
 
   return chtml10->out;
 }
@@ -625,18 +686,18 @@ s_chtml10_start_head_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The HEAD tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_head_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_head_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</head>\r\n", NULL);
+  W10_L("</head>");
 
   return chtml10->out;
 }
@@ -650,18 +711,18 @@ s_chtml10_end_head_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_ol_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_ol_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<ol>\r\n", NULL);
+  W10_L("<ol>");
 
   return chtml10->out;
 }
@@ -675,18 +736,18 @@ s_chtml10_start_ol_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The OL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_ol_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</ol>\r\n", NULL);
+  W10_L("</ol>");
 
   return chtml10->out;
 }
@@ -700,18 +761,18 @@ s_chtml10_end_ol_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The UL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_ul_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10    = GET_CHTML10(pdoc);
   doc        = chtml10->doc;
   r          = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<ul>\r\n", NULL);
+  W10_L("<ul>");
 
   return chtml10->out;
 }
@@ -725,18 +786,18 @@ s_chtml10_start_ul_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The UL tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_ul_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_ul_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</ul>\r\n", NULL);
+  W10_L("</ul>");
 
   return chtml10->out;
 }
@@ -750,18 +811,18 @@ s_chtml10_end_ul_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_li_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_li_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<li>\r\n", NULL);
+  W10_L("<li>");
 
   return chtml10->out;
 }
@@ -775,19 +836,10 @@ s_chtml10_start_li_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The LI tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_li_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_li_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
-
-  chtml10 = GET_CHTML10(pdoc);
-  doc     = chtml10->doc;
-  r       = doc->r;
-
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</li>\r\n", NULL);
-
+  chtml10_t  *chtml10 = GET_CHTML10(pdoc);
   return chtml10->out;
 }
 
@@ -800,18 +852,34 @@ s_chtml10_end_li_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H1 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h1_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_h1_tag(void *pdoc, Node *node
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h1>\r\n", NULL);
+  W10_L("<h1");
+  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('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -825,18 +893,18 @@ s_chtml10_start_h1_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H1 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h1_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h1>\r\n", NULL);
+  W10_L("</h1>");
 
   return chtml10->out;
 }
@@ -850,18 +918,36 @@ s_chtml10_end_h1_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h2_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_h2_tag(void *pdoc, Node *node
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  Attr          *attr;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h2>\r\n", NULL);
+  W10_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))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -875,18 +961,18 @@ s_chtml10_start_h2_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H2 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h2_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h2>\r\n", NULL);
+  W10_L("</h2>");
 
   return chtml10->out;
 }
@@ -900,18 +986,34 @@ s_chtml10_end_h2_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H3 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h3_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_h3_tag(void *pdoc, Node *node
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  Attr          *attr;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h3>\r\n", NULL);
+  W10_L("<h3");
+  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('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -925,18 +1027,18 @@ s_chtml10_start_h3_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H3 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h3_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h3>\r\n", NULL);
+  W10_L("</h3>");
 
   return chtml10->out;
 }
@@ -950,18 +1052,36 @@ s_chtml10_end_h3_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H4 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h4_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_h4_tag(void *pdoc, Node *node)
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t     *chtml10;
+  Attr          *attr;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h4>\r\n", NULL);
+  W10_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))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -975,18 +1095,18 @@ s_chtml10_start_h4_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H4 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h4_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10  = GET_CHTML10(pdoc);
   doc      = chtml10->doc;
   r        = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h4>\r\n", NULL);
+  W10_L("</h4>");
 
   return chtml10->out;
 }
@@ -1000,18 +1120,34 @@ s_chtml10_end_h4_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H5 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h5_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_h5_tag(void *pdoc, Node *node
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  chtml10_t    *chtml10;
+  Attr         *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h5>\r\n", NULL);
+  W10_L("<h5");
+  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('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -1025,18 +1161,18 @@ s_chtml10_start_h5_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H5 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h5_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h5>\r\n", NULL);
+  W10_L("</h5>");
 
   return chtml10->out;
 }
@@ -1050,18 +1186,34 @@ s_chtml10_end_h5_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The H6 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_h6_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_h6_tag(void *pdoc, Node *node)
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
+  Attr          *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<h6>\r\n", NULL);
+  W10_L("<h6");
+  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('a','A',"align", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+        W10_L(" align=\"");
+        W10_V(value);
+        W10_L("\"");
+        break;
+      }
+    }
+  }
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -1075,18 +1227,18 @@ s_chtml10_start_h6_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The H6 tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_h6_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</h6>\r\n", NULL);
+  W10_L("</h6>");
 
   return chtml10->out;
 }
@@ -1100,18 +1252,18 @@ s_chtml10_end_h6_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The TITLE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_title_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_title_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*         doc;
-  request_recr;
-  chtml10_t*   chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  chtml10_t    *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<title>", NULL);
+  W10_L("<title>");
 
   return chtml10->out;
 }
@@ -1125,18 +1277,18 @@ s_chtml10_start_title_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The TITLE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_title_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_title_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</title>\r\n", NULL);
+  W10_L("</title>");
 
   return chtml10->out;
 }
@@ -1150,20 +1302,19 @@ s_chtml10_end_title_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The BASE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_base_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_base_tag(void *pdoc, Node *node) 
 {
-  Attr*         attr;
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  Attr          *attr;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
   
-
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<base", NULL);
+  W10_L("<base");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1171,23 +1322,16 @@ s_chtml10_start_base_tag(void* pdoc, Node* node)
   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) {
-      chtml10->out = apr_pstrcat(r->pool, 
-                      chtml10->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)) {
+      W10_L(" href=\"");
+      W10_V(value);
+      W10_L("\"");
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >\r\n", NULL);
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -1201,10 +1345,10 @@ s_chtml10_start_base_tag(void* pdoc, Node* node)
  * @param node   [i]   The BASE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_base_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_base_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -1218,19 +1362,20 @@ s_chtml10_end_base_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The BODY tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_body_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_body_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<body", NULL);
+
+  W10_L("<body");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1239,10 +1384,7 @@ s_chtml10_start_body_tag(void* pdoc, Node* node)
        attr;
        attr = qs_get_next_attr(doc,attr)) {
 
-    char* name;
-
-    name  = qs_get_attr_name(doc,attr);
-
+    char *name  = qs_get_attr_name(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -1299,7 +1441,7 @@ s_chtml10_start_body_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
+  W10_L(">");
 
   return chtml10->out;
 }
@@ -1313,18 +1455,18 @@ s_chtml10_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_chtml10_end_body_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_body_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  chtml10_t     *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</body>\r\n", NULL);
+  W10_L("</body>");
 
   return chtml10->out;
 }
@@ -1338,19 +1480,19 @@ s_chtml10_end_body_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The A tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_a_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_a_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
-  Attr*         attr;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  Attr          *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<a", NULL);
+  W10_L("<a");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1358,13 +1500,8 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
   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);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'n':
     case 'N':
@@ -1372,12 +1509,9 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML1.0                                                           */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, 
-                        " name=\"", 
-                        value, 
-                        "\"", 
-                        NULL);
+        W10_L(" name=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
 
@@ -1389,13 +1523,9 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         value = chxj_encoding_parameter(r, value);
         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
-        
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, 
-                        " href=\"", 
-                        value, 
-                        "\"", 
-                        NULL);
+        W10_L(" href=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
 
@@ -1405,12 +1535,9 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML1.0                                                           */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, 
-                        " accesskey=\"", 
-                        value, 
-                        "\"", 
-                        NULL);
+        W10_L(" accesskey=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
 
@@ -1507,8 +1634,7 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
-
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -1521,19 +1647,18 @@ s_chtml10_start_a_tag(void* pdoc, Node* node)
  * @param node   [i]   The A tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_a_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_a_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</a>", NULL);
-
+  W10_L("</a>");
   return chtml10->out;
 }
 
@@ -1546,19 +1671,37 @@ s_chtml10_end_a_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The BR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_br_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_br_tag(void *pdoc, Node *node
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_rec* r;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
+  W10_L("<br");
 
+  /*--------------------------------------------------------------------------*/
+  /* 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('c','C',"clear",name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
+        W10_L(" clear=\"");
+        W10_V(value);
+        W10_L("\"");
+      }
+    }
+  }
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -1571,10 +1714,10 @@ s_chtml10_start_br_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The BR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_br_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_br_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -1588,10 +1731,10 @@ s_chtml10_end_br_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The TR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_tr_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -1605,18 +1748,18 @@ s_chtml10_start_tr_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The TR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_tr_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<br>\r\n", NULL);
+  W10_L("<br>\r\n");
 
   return chtml10->out;
 }
@@ -1630,10 +1773,10 @@ s_chtml10_end_tr_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The FONT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_font_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_font_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* Ignore */
 
@@ -1649,10 +1792,10 @@ s_chtml10_start_font_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The FONT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_font_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_font_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* ignore */
 
@@ -1668,19 +1811,21 @@ s_chtml10_end_font_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The FORM tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_form_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_form_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_rec* r;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
+  char         *new_hidden_tag = NULL;
+  char         *attr_value = NULL;
+  char         *attr_method = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<form", NULL);
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1688,12 +1833,8 @@ s_chtml10_start_form_tag(void* pdoc, Node* node)
   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);
-
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -1701,15 +1842,8 @@ s_chtml10_start_form_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        value = chxj_encoding_parameter(r, value);
-        value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
-  
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, 
-                        " action=\"",
-                        value,
-                        "\"", 
-                        NULL);
+        attr_value = chxj_encoding_parameter(r, value);
+        attr_value = chxj_add_cookie_parameter(r, attr_value, chtml10->cookie);
       }
       break;
 
@@ -1719,12 +1853,7 @@ s_chtml10_start_form_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, 
-                        " method=\"",
-                        value,
-                        "\"", 
-                        NULL);
+        attr_method = apr_pstrdup(doc->pool, value);
       }
       break;
 
@@ -1743,7 +1872,31 @@ s_chtml10_start_form_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
+  int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
+
+  W10_L("<form");
+  if (attr_value) {
+    char *q;
+    q = strchr(attr_value, '?');
+    if (q) {
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_value, 0, post_flag);
+      if (new_hidden_tag) {
+        *q = 0;
+      }
+    }
+    W10_L(" action=\"");
+    W10_V(attr_value);
+    W10_L("\"");
+  }
+  if (attr_method) {
+    W10_L(" method=\"");
+    W10_V(attr_method);
+    W10_L("\"");
+  }
+  W10_L(">");
+  if (new_hidden_tag) {
+    W10_V(new_hidden_tag);
+  }
 
   return chtml10->out;
 }
@@ -1757,18 +1910,18 @@ s_chtml10_start_form_tag(void* pdoc, Node* node)
  * @param node   [i]   The FORM tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_form_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_form_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</form>", NULL);
+  W10_L("</form>");
 
   return chtml10->out;
 }
@@ -1782,20 +1935,20 @@ s_chtml10_end_form_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The INPUT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_input_tag(void* pdoc, Node* node) 
-{
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
-  char*         max_length;
-  char*         type;
-  char*         name;
-  char*         value;
-  char*         istyle;
-  char*         size;
-  char*         checked;
-  char*         accesskey;
+static char *
+s_chtml10_start_input_tag(void *pdoc, Node *node) 
+{
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
+  char          *max_length;
+  char          *type;
+  char          *name;
+  char          *value;
+  char          *istyle;
+  char          *size;
+  char          *checked;
+  char          *accesskey;
 
   chtml10     = GET_CHTML10(pdoc);
   doc         = chtml10->doc;
@@ -1810,7 +1963,7 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
   checked     = NULL;
   accesskey   = NULL;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<input", NULL);
+  W10_L("<input");
 
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
@@ -1825,44 +1978,44 @@ s_chtml10_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)
-    chtml10->out = apr_pstrcat(r->pool,
-                    chtml10->out, 
-                    " type=\"", 
-                    type, 
-                    "\" ", 
-                    NULL);
-
-  if (size) 
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, 
-                    " size=\"", 
-                    size, 
-                    "\" ", 
-                    NULL);
-
-  if (name)
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, 
-                    " name=\"", 
-                    name, 
-                    "\" ", 
-                    NULL);
-
-  if (value)
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, 
-                    " value=\"", 
-                    value, 
-                    "\" ", 
-                    NULL);
-
-  if (accesskey)
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, 
-                    " accesskey=\"", 
-                    accesskey, "\" ", 
-                    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))) {
+      W10_L(" type=\"");
+      W10_V(type);
+      W10_L("\"");
+    }
+  }
+
+  if (size && *size != 0) {
+    W10_L(" size=\"");
+    W10_V(size);
+    W10_L("\"");
+  }
+
+  if (name && *name != 0) {
+    W10_L(" name=\"");
+    W10_V(name);
+    W10_L("\"");
+  }
+
+  if (value && *value != 0) {
+    W10_L(" value=\"");
+    W10_V(chxj_add_slash_to_doublequote(doc->pool,value));
+    W10_L("\"");
+  }
+
+  if (accesskey && *accesskey != 0) {
+    W10_L(" accesskey=\"");
+    W10_V(accesskey);
+    W10_L("\"");
+  }
 
   if (istyle) {
     /*------------------------------------------------------------------------*/
@@ -1873,20 +2026,17 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
   /*--------------------------------------------------------------------------*/
   /* The figure is default for the password.                                  */
   /*--------------------------------------------------------------------------*/
-  if (max_length)
-    chtml10->out = apr_pstrcat(r->pool, 
-                      chtml10->out, 
-                      " maxlength=\"", 
-                      max_length, 
-                      "\"", 
-                      NULL);
-
-  if (checked)
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, " checked ", NULL);
+  if (max_length && *max_length != 0) {
+    W10_L(" maxlength=\"");
+    W10_V(max_length);
+    W10_L("\"");
+  }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
+  if (checked) {
+    W10_L(" checked");
+  }
 
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -1899,10 +2049,10 @@ s_chtml10_start_input_tag(void* pdoc, Node* node)
  * @param node   [i]   The INPUT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_input_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_input_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_tchtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -1916,18 +2066,18 @@ s_chtml10_end_input_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The CENTER tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_center_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_center_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<center>", NULL);
+  W10_L("<center>");
 
   return chtml10->out;
 }
@@ -1941,18 +2091,18 @@ s_chtml10_start_center_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The CENTER tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_center_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_center_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  request_rec   *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</center>", NULL);
+  W10_L("</center>");
 
   return chtml10->out;
 }
@@ -1966,30 +2116,25 @@ s_chtml10_end_center_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The HR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_hr_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_hr_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<hr ", NULL);
+  W10_L("<hr");
  
   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);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 'a':
     case 'A':
@@ -1997,9 +2142,11 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool,
-                          chtml10->out, 
-                          " align=\"", value, "\" ", NULL);
+        if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+          W10_L(" align=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2009,9 +2156,11 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool,
-                          chtml10->out, 
-                          " size=\"", value, "\" ", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" size=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2021,9 +2170,11 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool,
-                          chtml10->out, 
-                          " width=\"", value, "\" ", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" width=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2033,9 +2184,7 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool,
-                          chtml10->out, 
-                          " noshade ", NULL);
+        W10_L(" noshade");
       }
       break;
 
@@ -2053,9 +2202,7 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
       break;
     }
   }
-
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, " >", NULL);
-
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2068,12 +2215,11 @@ s_chtml10_start_hr_tag(void* pdoc, Node* node)
  * @param node   [i]   The HR tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_hr_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t* chtml10;
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
-  chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -2087,13 +2233,13 @@ s_chtml10_end_hr_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The IMG tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_img_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_img_tag(void *pdoc, Node *node) 
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 #ifndef IMG_NOT_CONVERT_FILENAME
   device_table *spec;
 #endif
@@ -2105,22 +2251,15 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<img", NULL);
-
+  W10_L("<img");
   /*--------------------------------------------------------------------------*/
   /* 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);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
     case 's':
     case 'S':
@@ -2132,30 +2271,29 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
         value = chxj_encoding_parameter(r, value);
         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
         if (value) {
-          value = apr_psprintf(r->pool, 
+          value = apr_psprintf(doc->buf.pool, 
                                "%s%c%s=true", 
                                value, 
                                (strchr(value, '?')) ? '&' : '?',
                                CHXJ_COOKIE_NOUPDATE_PARAM);
         }
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " src=\"",value,"\"", NULL);
+        W10_L(" src=\"");
+        W10_V(value);
+        W10_L("\"");
 #else
         value = chxj_img_conv(r, spec, value);
         value = chxj_encoding_parameter(r, value);
         value = chxj_add_cookie_parameter(r, value, chtml10->cookie);
         if (value) {
-          value = apr_psprintf(r->pool,
+          value = apr_psprintf(doc->buf.pool,
                                "%s%c%s=true",
                                value,
                                (strchr(value, '?')) ? '&' : '?',
                                CHXJ_COOKIE_NOUPDATE_PARAM);
         }
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " src=\"", 
-                        value, 
-                        NULL);
-        chtml10->out = apr_pstrcat(r->pool, chtml10->out, "\"", NULL);
+        W10_L(" src=\"");
+        W10_V(value);
+        W10_L("\"");
 #endif
       }
       break;
@@ -2169,16 +2307,25 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 4.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->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))) {
+          W10_L(" align=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
-      else
-      if (strcasecmp(name, "alt"   ) == 0) {
+      else if (strcasecmp(name, "alt"   ) == 0) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " alt=\"",value,"\"", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" alt=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2188,8 +2335,11 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " width=\"",value,"\"", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" width=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2199,16 +2349,22 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " height=\"",value,"\"", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" height=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       else
       if (strcasecmp(name, "hspace") == 0) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " hspace=\"",value,"\"", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" hspace=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2218,8 +2374,11 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        chtml10->out = apr_pstrcat(r->pool, 
-                        chtml10->out, " vspace=\"",value,"\"", NULL);
+        if (value && value[0] != '\0') {
+          W10_L(" vspace=\"");
+          W10_V(value);
+          W10_L("\"");
+        }
       }
       break;
 
@@ -2228,8 +2387,7 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
-
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2242,12 +2400,10 @@ s_chtml10_start_img_tag(void* pdoc, Node* node)
  * @param node   [i]   The IMG tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_img_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_img_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t* chtml10;
-
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   return chtml10->out;
 }
@@ -2261,16 +2417,16 @@ s_chtml10_end_img_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The SELECT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_select_tag(void* pdoc, Node* child)
+static char *
+s_chtml10_start_select_tag(void *pdoc, Node *child)
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
-  Attr*        attr;
+  chtml10_t    *chtml10;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 
-  char*        size;
-  char*        name;
+  char         *size;
+  char         *name;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2279,16 +2435,12 @@ s_chtml10_start_select_tag(void* pdoc, Node* child)
   size    = NULL;
   name    = NULL;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<select", NULL);
+  W10_L("<select");
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* nm;
-    char* val;
-
-    nm  = qs_get_attr_name (doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
+    char *nm  = qs_get_attr_name (doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
     switch(*nm) {
     case 's':
     case 'S':
@@ -2296,7 +2448,7 @@ s_chtml10_start_select_tag(void* pdoc, Node* child)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0 version 2.0                                              */
         /*--------------------------------------------------------------------*/
-        size = apr_pstrdup(r->pool, val);
+        size = apr_pstrdup(doc->buf.pool, val);
       }
       break;
 
@@ -2306,7 +2458,7 @@ s_chtml10_start_select_tag(void* pdoc, Node* child)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0 version 2.0                                              */
         /*--------------------------------------------------------------------*/
-        name = apr_pstrdup(r->pool, val);
+        name = apr_pstrdup(doc->buf.pool, val);
       }
       break;
 
@@ -2325,24 +2477,19 @@ s_chtml10_start_select_tag(void* pdoc, Node* child)
     }
   }
 
-  if (size)
-    chtml10->out = apr_pstrcat(r->pool, 
-                               chtml10->out, 
-                               " size=\"",
-                               size,
-                               "\"", 
-                               NULL);
-
-  if (name) 
-    chtml10->out = apr_pstrcat(r->pool, 
-                               chtml10->out, 
-                               " name=\"",
-                               name,
-                               "\"", 
-                               NULL);
+  if (size && *size != 0) {
+    W10_L(" size=\"");
+    W10_V(size);
+    W10_L("\"");
+  }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\n", NULL);
+  if (name && *name != 0) {
+    W10_L(" name=\"");
+    W10_V(name);
+    W10_L("\"");
+  }
 
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2355,19 +2502,18 @@ s_chtml10_start_select_tag(void* pdoc, Node* child)
  * @param node   [i]   The SELECT tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_select_tag(void* pdoc, Node* UNUSED(child))
+static char *
+s_chtml10_end_select_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</select>\n", NULL);
-
+  W10_L("</select>");
   return chtml10->out;
 }
 
@@ -2380,16 +2526,15 @@ s_chtml10_end_select_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The OPTION tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_option_tag(void* pdoc, Node* child)
+static char *
+s_chtml10_start_option_tag(void *pdoc, Node *child)
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_rec* r;
-  Attr*        attr;
-
-  char*        selected;
-  char*        value;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *selected;
+  char        *value;
 
   chtml10   = GET_CHTML10(pdoc);
   doc       = chtml10->doc;
@@ -2398,16 +2543,13 @@ s_chtml10_start_option_tag(void* pdoc, Node* child)
   selected  = NULL;
   value     = NULL;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<option", NULL);
+  W10_L("<option");
+
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-    char* nm;
-    char* val;
-
-    nm  = qs_get_attr_name (doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
+    char *nm  = qs_get_attr_name (doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
     switch(*nm) {
     case 's':
     case 'S':
@@ -2415,7 +2557,7 @@ s_chtml10_start_option_tag(void* pdoc, Node* child)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0 version 2.0                                              */
         /*--------------------------------------------------------------------*/
-        selected = apr_pstrdup(r->pool, val);
+        selected = apr_pstrdup(doc->buf.pool, val);
       }
       break;
 
@@ -2425,7 +2567,7 @@ s_chtml10_start_option_tag(void* pdoc, Node* child)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0 version 2.0                                              */
         /*--------------------------------------------------------------------*/
-        value = apr_pstrdup(r->pool, val);
+        value = apr_pstrdup(doc->buf.pool, val);
       }
       break;
 
@@ -2434,27 +2576,17 @@ s_chtml10_start_option_tag(void* pdoc, Node* child)
     }
   }
 
-  if (value)
-    chtml10->out = apr_pstrcat(r->pool, 
-                               chtml10->out, 
-                               " value=\"",
-                               value,
-                               "\"", 
-                               NULL);
-  else
-    chtml10->out = apr_pstrcat(r->pool, 
-                               chtml10->out, 
-                               " value=\"\"", 
-                               NULL);
-
-  if (selected)
-    chtml10->out = apr_pstrcat(r->pool, 
-                               chtml10->out, 
-                               " selected ", 
-                               NULL);
+  if (value && *value != 0) {
+    W10_L(" value=\"");
+    W10_V(value);
+    W10_L("\"");
+  }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
+  if (selected) {
+    W10_L(" selected");
+  }
 
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2467,12 +2599,10 @@ s_chtml10_start_option_tag(void* pdoc, Node* child)
  * @param node   [i]   The OPTION tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_option_tag(void* pdoc, Node* UNUSED(child))
+static char *
+s_chtml10_end_option_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t* chtml10;
-  chtml10 = GET_CHTML10(pdoc);
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
 
   /* Don't close */
 
@@ -2488,15 +2618,14 @@ s_chtml10_end_option_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The DIV tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_div_tag(void* pdoc, Node* child)
+static char *
+s_chtml10_start_div_tag(void *pdoc, Node *child)
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_rec* r;
-  Attr*        attr;
-
-  char*        align;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *align;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2504,31 +2633,29 @@ s_chtml10_start_div_tag(void* pdoc, Node* child)
 
   align   = NULL;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<div", NULL);
+  W10_L("<div");
   for (attr = qs_get_attr(doc,child);
        attr;
        attr = qs_get_next_attr(doc,attr)) {
-
-    char* nm;
-    char* val;
-
-    nm  = qs_get_attr_name(doc,attr);
-    val = qs_get_attr_value(doc,attr);
-
-    if ((*nm == 'a' || *nm == 'A') && strcasecmp(nm, "align") == 0) {
+    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)                                          */
       /*----------------------------------------------------------------------*/
-      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)
-    chtml10->out = apr_pstrcat(r->pool, 
-                    chtml10->out, " align=\"", align, "\"", NULL);
-
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">", NULL);
+  if (align) {
+    W10_L(" align=\"");
+    W10_V(align);
+    W10_L("\"");
+  }
 
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2541,19 +2668,18 @@ s_chtml10_start_div_tag(void* pdoc, Node* child)
  * @param node   [i]   The DIV tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_div_tag(void* pdoc, Node* UNUSED(child))
+static char *
+s_chtml10_end_div_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</div>\n", NULL);
-
+  W10_L("</div>");
   return chtml10->out;
 }
 
@@ -2566,13 +2692,13 @@ s_chtml10_end_div_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The CHXJ:IF tag node is specified.
  * @return The conversion result is returned.
  */
-static char
-s_chtml10_chxjif_tag(void* pdoc, Node* node)
+static char *
+s_chtml10_chxjif_tag(void *pdoc, Node *node)
 {
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  Node*        child;
-  request_recr;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  Node        *child;
+  request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2581,7 +2707,7 @@ s_chtml10_chxjif_tag(void* pdoc, Node* node)
   for (child = qs_get_child_node(doc, node);
        child;
        child = qs_get_next_node(doc, child)) {
-    chtml10->out = apr_pstrcat(r->pool, chtml10->out, child->otext, NULL);
+    W10_V(child->otext);
     s_chtml10_chxjif_tag(chtml10, child);
   }
 
@@ -2597,20 +2723,19 @@ s_chtml10_chxjif_tag(void* pdoc, Node* node)
  * @param node   [i]   The PRE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_pre_tag(void* pdoc, Node* UNUSED(node)) 
+static char *
+s_chtml10_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc         *doc;
+  request_rec *r;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
   chtml10->pre_flag++;
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<pre>", NULL);
-
+  W10_L("<pre>");
   return chtml10->out;
 }
 
@@ -2623,18 +2748,18 @@ s_chtml10_start_pre_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The PRE tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_pre_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml10_t*    chtml10;
-  Doc*          doc;
-  request_rec*  r;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</pre>", NULL);
+  W10_L("</pre>");
   chtml10->pre_flag--;
 
   return chtml10->out;
@@ -2649,19 +2774,42 @@ s_chtml10_end_pre_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The P tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_p_tag(void* pdoc, Node* UNUSED(node)
+static char *
+s_chtml10_start_p_tag(void *pdoc, Node *node
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc         *doc;
+  request_rec *r;
+  chtml10_t   *chtml10;
+  Attr        *attr;
+  char        *align = NULL;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<p>", NULL);
+  W10_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) {
+    W10_L(" align=\"");
+    W10_V(align);
+    W10_L("\"");
+  }
 
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2674,19 +2822,18 @@ s_chtml10_start_p_tag(void* pdoc, Node* UNUSED(node))
  * @param node   [i]   The P tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_p_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_p_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc         *doc;
+  request_rec *r;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</p>", NULL);
-
+  W10_L("</p>");
   return chtml10->out;
 }
 
@@ -2699,13 +2846,13 @@ s_chtml10_end_p_tag(void* pdoc, Node* UNUSED(child))
  * @param node   [i]   The TEXTAREA tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_start_textarea_tag(void* pdoc, Node* node) 
+static char *
+s_chtml10_start_textarea_tag(void *pdoc, Node *node) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
-  Attr*         attr;
+  Doc         *doc;
+  request_rec *r;
+  chtml10_t   *chtml10;
+  Attr        *attr;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
@@ -2713,52 +2860,48 @@ s_chtml10_start_textarea_tag(void* pdoc, Node* node)
 
 
   chtml10->textarea_flag++;
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "<textarea ", NULL);
+
+  W10_L("<textarea");
 
   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);
-
+    char *name  = qs_get_attr_name (doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
     switch(*name) {
+    case 'a':
+    case 'A':
+      if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
+        W10_L(" accesskey=\"");
+        W10_V(value);
+        W10_L("\"");
+      }
+      break;
+
     case 'n':
     case 'N':
-      if (strcasecmp(name, "name") == 0) {
-        chtml10->out = apr_pstrcat(r->pool, 
-                                   chtml10->out, 
-                                   " name=\"",
-                                   value,
-                                   "\"", 
-                                   NULL);
+      if (strcasecmp(name, "name") == 0 && value && *value != 0) {
+        W10_L(" name=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
 
     case 'r':
     case 'R':
-      if (strcasecmp(name, "rows") == 0) {
-        chtml10->out = apr_pstrcat(r->pool, 
-                                   chtml10->out, 
-                                   " rows=\"",
-                                     value,
-                                     "\"",
-                                     NULL);
+      if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
+        W10_L(" rows=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
 
     case 'c':
     case 'C':
-      if (strcasecmp(name, "cols") == 0) {
-        chtml10->out = apr_pstrcat(r->pool, 
-                                   chtml10->out, 
-                                   " cols=\"",
-                                   value,
-                                   "\"", 
-                                   NULL);
+      if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
+        W10_L(" cols=\"");
+        W10_V(value);
+        W10_L("\"");
       }
       break;
     
@@ -2766,9 +2909,7 @@ s_chtml10_start_textarea_tag(void* pdoc, Node* node)
       break;
     }
   }
-
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, ">\r\n", NULL);
-
+  W10_L(">");
   return chtml10->out;
 }
 
@@ -2781,46 +2922,45 @@ s_chtml10_start_textarea_tag(void* pdoc, Node* node)
  * @param node   [i]   The TEXTAREA tag node is specified.
  * @return The conversion result is returned.
  */
-static char*
-s_chtml10_end_textarea_tag(void* pdoc, Node* UNUSED(child)) 
+static char *
+s_chtml10_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc*          doc;
-  request_rec*  r;
-  chtml10_t*    chtml10;
+  Doc         *doc;
+  request_rec *r;
+  chtml10_t   *chtml10;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, "</textarea>\r\n", NULL);
+  W10_L("</textarea>");
   chtml10->textarea_flag--;
 
   return chtml10->out;
 }
 
 
-static char*
-s_chtml10_text(void* pdoc, Node* child)
+static char *
+s_chtml10_text(void *pdoc, Node *child)
 {
-  char*        textval;
-  char*        tmp;
-  char*        tdst;
-  char         one_byte[2];
-  int          ii;
-  int          tdst_len;
-  chtml10_t*   chtml10;
-  Doc*         doc;
-  request_recr;
+  char        *textval;
+  char        *tmp;
+  char        *tdst;
+  char        one_byte[2];
+  int         ii;
+  int         tdst_len;
+  chtml10_t   *chtml10;
+  Doc         *doc;
+  request_rec *r;
 
   chtml10 = GET_CHTML10(pdoc);
   doc     = chtml10->doc;
   r       = doc->r;
-  
-  textval = qs_get_node_value(doc,child);
-  textval = qs_trim_string(r, textval);
 
-  if (strlen(textval) == 0)
+  textval = qs_get_node_value(doc,child);
+  if (strlen(textval) == 0) {
     return chtml10->out;
+  }
   
   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
   memset(tmp, 0, qs_get_node_size(doc,child)+1);
@@ -2830,7 +2970,7 @@ s_chtml10_text(void* pdoc, Node* child)
   tdst_len = 0;
   
   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
-    charout;
+    char *out;
     int   rtn;
 
     rtn = s_chtml10_search_emoji(chtml10, &textval[ii], &out);
@@ -2864,8 +3004,296 @@ s_chtml10_text(void* pdoc, Node* child)
     }
   }
 
-  chtml10->out = apr_pstrcat(r->pool, chtml10->out, tdst, NULL);
+  W10_V(tdst);
+  return chtml10->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_chtml10_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<blockquote>");
+  return chtml10->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_chtml10_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("</blockquote>");
+  return chtml10->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_chtml10_start_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<dir>");
+  return chtml10->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_chtml10_end_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("</dir>");
+  return chtml10->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_chtml10_start_dl_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<dl>");
+  return chtml10->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_chtml10_end_dl_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("</dl>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a handter 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_chtml10_start_dt_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<dt>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a handter 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_chtml10_end_dt_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  chtml10 = GET_CHTML10(pdoc);
+  return chtml10->out;
+}
+
+
+/**
+ * It is a handder 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_chtml10_start_dd_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<dd>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a handder 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_chtml10_end_dd_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  chtml10 = GET_CHTML10(pdoc);
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanmenuer 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_chtml10_start_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<menu>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanmenuer 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_chtml10_end_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
+  Doc *doc = chtml10->doc;
+  W10_L("</menu>");
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanplaintexter 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_chtml10_start_plaintext_tag(void *pdoc, Node *node)
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  W10_L("<plaintext>");
+  s_chtml10_start_plaintext_tag_inner(pdoc,node);
+  return chtml10->out;
+}
+
+static char *
+s_chtml10_start_plaintext_tag_inner(void *pdoc, Node *node)
+{
+  chtml10_t *chtml10;
+  Doc *doc;
+  Node *child;
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+  for (child = qs_get_child_node(doc, node);
+       child;
+       child = qs_get_next_node(doc, child)) {
+    W10_V(child->otext);
+    s_chtml10_start_plaintext_tag_inner(pdoc, child);
+  }
+  return chtml10->out;
+}
+
+
+/**
+ * It is a hanplaintexter 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_chtml10_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml10_t *chtml10 = GET_CHTML10(pdoc);
   return chtml10->out;
 }
 /*