OSDN Git Service

* Added New Features.
[modchxj/mod_chxj.git] / src / chxj_chtml20.c
index 19d0234..1d9d8a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "mod_chxj.h"
 #include "chxj_chtml20.h"
 #include "chxj_hdml.h"
 #include "chxj_str_util.h"
 #include "chxj_qr_code.h"
 #include "chxj_encoding.h"
 #include "chxj_buffered_write.h"
+#include "chxj_header_inf.h"
+
 
 #define GET_CHTML20(X) ((chtml20_t*)(X))
-#define W_L(X)  do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
-#define W_V(X)  do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X))  \
-                                        : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
+#undef W_L
+#undef W_V
+#define W_L(X)          do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
+#define W_V(X)          do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X))  \
+                                                  : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
+#undef W_NLCODE
+#define W_NLCODE()     do { char *nlcode = TO_NLCODE(chtml20->conf); W_V(nlcode); } while (0)
 
 static char *s_chtml20_start_html_tag    (void *pdoc, Node *node);
 static char *s_chtml20_end_html_tag      (void *pdoc, Node *node);
@@ -89,20 +94,35 @@ static char *s_chtml20_start_option_tag  (void *pdoc, Node *node);
 static char *s_chtml20_end_option_tag    (void *pdoc, Node *node);
 static char *s_chtml20_start_div_tag     (void *pdoc, Node *node);
 static char *s_chtml20_end_div_tag       (void *pdoc, Node *node);
+static char *s_chtml20_start_blockquote_tag(void *pdoc, Node *node);
+static char *s_chtml20_end_blockquote_tag  (void *pdoc, Node *node);
+static char *s_chtml20_start_dir_tag     (void *pdoc, Node *node);
+static char *s_chtml20_end_dir_tag       (void *pdoc, Node *node);
 static char *s_chtml20_start_dl_tag      (void *pdoc, Node *node);
 static char *s_chtml20_end_dl_tag        (void *pdoc, Node *node);
 static char *s_chtml20_start_dt_tag      (void *pdoc, Node *node);
 static char *s_chtml20_end_dt_tag        (void *pdoc, Node *node);
 static char *s_chtml20_start_dd_tag      (void *pdoc, Node *node);
 static char *s_chtml20_end_dd_tag        (void *pdoc, Node *node);
+static char *s_chtml20_start_menu_tag    (void *pdoc, Node *node);
+static char *s_chtml20_end_menu_tag      (void *pdoc, Node *node);
+static char *s_chtml20_start_plaintext_tag       (void *pdoc, Node *node);
+static char *s_chtml20_start_plaintext_tag_inner (void *pdoc, Node *node);
+static char *s_chtml20_end_plaintext_tag         (void *pdoc, Node *node);
+static char *s_chtml20_start_blink_tag   (void *pdoc, Node *node);
+static char *s_chtml20_end_blink_tag     (void *pdoc, Node *node);
+static char *s_chtml20_start_marquee_tag   (void *pdoc, Node *node);
+static char *s_chtml20_end_marquee_tag     (void *pdoc, Node *node);
+static char *s_chtml20_newline_mark       (void *pdoc, Node *node);
 
 static void  s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
 
+static int   s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
+
 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node); 
 static char *s_chtml20_text_tag(void *pdoc, Node *node);
 
 
-
 tag_handler chtml20_handler[] = {
   /* tagHTML */
   {
@@ -329,6 +349,16 @@ tag_handler chtml20_handler[] = {
     NULL,
     NULL,
   },
+  /* tagBLOCKQUOTE */
+  {
+    s_chtml20_start_blockquote_tag,
+    s_chtml20_end_blockquote_tag,
+  },
+  /* tagDIR */
+  {
+    s_chtml20_start_dir_tag,
+    s_chtml20_end_dir_tag,
+  },
   /* tagDL */
   {
     s_chtml20_start_dl_tag,
@@ -339,6 +369,31 @@ tag_handler chtml20_handler[] = {
     s_chtml20_start_dd_tag,
     s_chtml20_end_dd_tag,
   },
+  /* tagMENU */
+  {
+    s_chtml20_start_menu_tag,
+    s_chtml20_end_menu_tag,
+  },
+  /* tagPLAINTEXT */
+  {
+    s_chtml20_start_plaintext_tag,
+    s_chtml20_end_plaintext_tag,
+  },
+  /* tagBLINK */
+  {
+    s_chtml20_start_blink_tag,
+    s_chtml20_end_blink_tag,
+  },
+  /* tagMAQUEE */
+  {
+    s_chtml20_start_marquee_tag,
+    s_chtml20_end_marquee_tag,
+  },
+  /* tagNLMARK */
+  {
+    s_chtml20_newline_mark,
+    NULL,
+  },
 };
 
 /**
@@ -352,13 +407,13 @@ tag_handler chtml20_handler[] = {
  */
 char *
 chxj_convert_chtml20(
-  request_rec         *r,
-  device_table        *spec,
-  const char          *src,
-  apr_size_t          srclen,
-  apr_size_t          *dstlen,
-  chxjconvrule_entry  *entryp,
-  cookie_t            *cookie
+  request_rec        *r,
+  device_table       *spec,
+  const char         *src,
+  apr_size_t         srclen,
+  apr_size_t         *dstlen,
+  chxjconvrule_entry *entryp,
+  cookie_t           *cookie
 )
 {
   char      *dst = NULL;
@@ -370,7 +425,7 @@ chxj_convert_chtml20(
   /* If qrcode xml                                                            */
   /*--------------------------------------------------------------------------*/
   *dstlen = srclen;
-  dst = chxj_qr_code_blob_handler(r, src, (size_t *)dstlen);
+  dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
   if (dst) {
     DBG(r,"i found qrcode xml");
     return dst;
@@ -386,12 +441,7 @@ chxj_convert_chtml20(
   chtml20.entryp = entryp;
   chtml20.cookie = cookie;
 
-  if (IS_SJIS_STRING(GET_SPEC_CHARSET(spec))) {
-    ap_set_content_type(r, "text/html; charset=Windows-31J");
-  }
-  else {
-    ap_set_content_type(r, "text/html; charset=UTF-8");
-  }
+  chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
 
   /*--------------------------------------------------------------------------*/
   /* The character string of the input is analyzed.                           */
@@ -409,26 +459,18 @@ chxj_convert_chtml20(
 
   qs_parse_string(&doc,ss, strlen(ss));
 
-  if (! chxj_buffered_write_init(r->pool, &doc.buf)) {
-    ERR(r, "failed: chxj_buffered_write_init()");
-    DBG(r, "end chxj_convert_chtml20()");
-    return apr_pstrdup(r->pool, ss);
-  }
-
+  chxj_buffered_write_init(r->pool, &doc.buf);
   /*--------------------------------------------------------------------------*/
   /* It converts it from CHTML to CHTML.                                      */
   /*--------------------------------------------------------------------------*/
-  chxj_node_convert(spec,r,(void*)&chtml20, &doc, qs_get_root(&doc), 0);
-  /*--------------------------------------------------------------------------*/
-  /* flush buffer AND terminate.                                              */
-  /*--------------------------------------------------------------------------*/
+  chxj_node_convert(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
   chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
   dst = apr_pstrdup(r->pool, chtml20.out);
   chxj_buffered_write_terminate(&doc.buf);
 
   qs_all_free(&doc,QX_LOGMARK);
 
-  if (dst == NULL) {
+  if (dst == NULL)  {
     return apr_pstrdup(r->pool,ss);
   }
 
@@ -464,10 +506,125 @@ s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
   doc->r        = r;
   chtml20->doc  = doc;
   chtml20->spec = spec;
-  chtml20->out  = qs_alloc_zero_byte_string(r);
-  chtml20->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
+  chtml20->out  = qs_alloc_zero_byte_string(r->pool);
+  chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+
+  chtml20->doc->parse_mode = PARSE_MODE_CHTML;
+}
+
+
+/**
+ * Corresponding EMOJI to a current character-code is retrieved. 
+ * The substitution character string is stored in the rslt pointer if agreeing.
+ *
+ * @param chtml20   [i]   The pointer to the CHTML structure is specified. 
+ * @param txt     [i]   The character string to want to examine whether it is 
+ *                      EMOJI is specified. 
+ * @param rslt    [o]   The pointer to the pointer that stores the result is 
+ *                      specified. 
+ * @return When corresponding EMOJI exists, it returns it excluding 0. 
+ */
+static int
+s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
+{
+  emoji_t       *ee;
+  request_rec   *r;
+  device_table  *spec;
+  int           len;
+
+  spec = chtml20->spec;
+
+  len = strlen(txt);
+  r   = chtml20->doc->r;
+
+  if (spec == NULL)
+    DBG(r,"spec is NULL");
+
+  for (ee = chtml20->conf->emoji;
+       ee;
+       ee = ee->next) {
+
+    if (ee->imode == NULL) {
+      DBG(r,"emoji->imode is NULL");
+      continue;
+    }
+
+    if (ee->imode->string != NULL
+    &&  strlen(ee->imode->string) > 0
+    &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
+      if (spec == NULL || spec->emoji_type == NULL) {
+        *rslt = apr_palloc(r->pool, 3);
+        (*rslt)[0] = ee->imode->hex1byte & 0xff;
+        (*rslt)[1] = ee->imode->hex2byte & 0xff;
+        (*rslt)[2] = 0;
+        return strlen(ee->imode->string);
+      }
+
+      return 0;
+    }
+  }
+
+  return 0;
+}
 
+char *
+chxj_chtml20_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
+{
+  apr_size_t ii;
+  Doc __doc;
+  Doc *doc;
+  chtml20_t __chtml20;
+  chtml20_t *chtml20;
+  char one_byte[2];
+  char two_byte[3];
+  apr_pool_t *pool;
+
+  chtml20 = &__chtml20;
+  doc     = &__doc;
+
+  DBG(r, "REQ[%X] start chxj_chtml20_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
+  memset(doc,     0, sizeof(Doc));
+  memset(chtml20, 0, sizeof(chtml20_t));
+
+  doc->r        = r;
+  chtml20->doc  = doc;
+  chtml20->spec = spec;
+  chtml20->out  = qs_alloc_zero_byte_string(r->pool);
+  chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
   chtml20->doc->parse_mode = PARSE_MODE_CHTML;
+
+  apr_pool_create(&pool, r->pool);
+
+  chxj_buffered_write_init(pool, &doc->buf);
+
+  for (ii=0; ii<len; ii++) {
+    char *out;
+    int   rtn;
+
+    rtn = s_chtml20_search_emoji(chtml20, (char *)&src[ii], &out);
+    if (rtn) {
+      W_V(out);
+      ii+=(rtn - 1);
+      continue;
+    }
+
+    if (is_sjis_kanji(src[ii])) {
+      two_byte[0] = src[ii+0];
+      two_byte[1] = src[ii+1];
+      two_byte[2] = 0;
+      W_V(two_byte);
+      ii++;
+    }
+    else {
+      one_byte[0] = src[ii+0];
+      one_byte[1] = 0;
+      W_V(one_byte);
+    }
+  }
+  chtml20->out = chxj_buffered_write_flush(chtml20->out, &doc->buf);
+
+  DBG(r, "REQ[%X] end chxj_chtml20_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
+  return chtml20->out;
 }
 
 
@@ -482,9 +639,9 @@ s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
 static char *
 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  Doc           *doc;
-  request_rec   *r;
-  chtml20_t     *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  chtml20_t   *chtml20;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -493,8 +650,7 @@ s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
   /*--------------------------------------------------------------------------*/
   /* start HTML tag                                                           */
   /*--------------------------------------------------------------------------*/
-  W_L("<html>\n");
-
+  W_L("<html>");
   return chtml20->out;
 }
 
@@ -510,15 +666,15 @@ s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  Doc           *doc;
-  request_rec   *r;
-  chtml20_t     *chtml20;
+  Doc *doc;
+  request_rec *r;
+  chtml20_t *chtml20;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("</html>\n");
+  W_L("</html>");
   return chtml20->out;
 }
 
@@ -534,12 +690,12 @@ s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_meta_tag(void *pdoc, Node *node) 
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-  Attr         *attr;
-  int          content_type_flag;
-  int          refresh_flag;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  int         content_type_flag;
+  int         refresh_flag;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -555,24 +711,19 @@ s_chtml20_start_meta_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 'h':
     case 'H':
-      if (strcasecmp(name, "http-equiv") == 0) {
+      if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
         /*----------------------------------------------------------------------*/
         /* CHTML 2.0                                                            */
         /*----------------------------------------------------------------------*/
         W_L(" http-equiv=\"");
         W_V(value);
         W_L("\"");
-        if (STRCASEEQ('c','C',"content-type",value)) {
+        if (STRCASEEQ('c','C',"content-type", value)) {
           content_type_flag = 1;
         }
         if (STRCASEEQ('r','R',"refresh", value)) {
@@ -583,26 +734,18 @@ s_chtml20_start_meta_tag(void *pdoc, Node *node)
 
     case 'c':
     case 'C':
-      if (strcasecmp(name, "content") == 0) {
+      if (strcasecmp(name, "content") == 0 && value && *value) {
         if (content_type_flag) {
-          if (IS_SJIS_STRING(GET_SPEC_CHARSET(chtml20->spec))) {
-            W_L(" ");
-            W_V(name);
-            W_L("=\"");
-            W_L("text/html; charset=Windows-31J");
-            W_L("\"");
-          }
-          else {
-            W_L(" ");
-            W_V(name);
-            W_L("=\"");
-            W_L("text/html; charset=UTF-8");
-          }
+          W_L(" ");
+          W_V(name);
+          W_L("=\"");
+          W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
+          W_L("\"");
         }
         else if (refresh_flag) {
-          charbuf = apr_pstrdup(r->pool, value);
-          charsec;
-          charurl;
+          char *buf = apr_pstrdup(r->pool, value);
+          char *sec;
+          char *url;
 
           url = strchr(buf, ';');
           if (url) {
@@ -625,6 +768,7 @@ s_chtml20_start_meta_tag(void *pdoc, Node *node)
           W_V(name);
           W_L("=\"");
           W_V(value);
+          W_L("\"");
         }
       }
       break;
@@ -634,6 +778,7 @@ s_chtml20_start_meta_tag(void *pdoc, Node *node)
     }
   }
   W_L(">");
+
   return chtml20->out;
 }
 
@@ -649,9 +794,7 @@ s_chtml20_start_meta_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t *chtml20;
-
-  chtml20 = GET_CHTML20(pdoc);
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
 
   return chtml20->out;
 }
@@ -668,15 +811,14 @@ s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
-  r       = doc->r;
 
-  W_L("<head>\r\n");
+  W_L("<head>");
+
   return chtml20->out;
 }
 
@@ -692,15 +834,16 @@ s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("</head>\r\n");
+  W_L("</head>");
+
   return chtml20->out;
 }
 
@@ -716,15 +859,16 @@ s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("<title>");
+
   return chtml20->out;
 }
 
@@ -740,15 +884,16 @@ s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("</title>\r\n");
+  W_L("</title>");
+
   return chtml20->out;
 }
 
@@ -764,10 +909,10 @@ s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_base_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -780,20 +925,16 @@ s_chtml20_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 (STRCASEEQ('h','H',"href",name)) {
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('h','H',"href", name)) {
       W_L(" href=\"");
       W_V(value);
       W_L("\"");
     }
   }
-  W_L(" >\r\n");
+  W_L(">");
+
   return chtml20->out;
 }
 
@@ -809,9 +950,9 @@ s_chtml20_start_base_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -832,10 +973,10 @@ s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_body_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -848,16 +989,12 @@ s_chtml20_start_body_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 'b':
     case 'B':
-      if (strcasecmp(name, "bgcolor") == 0) {
+      if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
         /*----------------------------------------------------------------------*/
         /* CHTML 2.0                                                            */
         /*----------------------------------------------------------------------*/
@@ -869,7 +1006,7 @@ s_chtml20_start_body_tag(void *pdoc, Node *node)
 
     case 't':
     case 'T':
-      if (strcasecmp(name, "text") == 0) {
+      if (strcasecmp(name, "text") == 0 && value && *value != 0) {
         /*----------------------------------------------------------------------*/
         /* CHTML 2.0                                                            */
         /*----------------------------------------------------------------------*/
@@ -881,7 +1018,7 @@ s_chtml20_start_body_tag(void *pdoc, Node *node)
 
     case 'l':
     case 'L':
-      if (strcasecmp(name, "link") == 0) {
+      if (strcasecmp(name, "link") == 0 && value && *value != 0) {
         /*----------------------------------------------------------------------*/
         /* CHTML 2.0                                                            */
         /*----------------------------------------------------------------------*/
@@ -915,7 +1052,8 @@ s_chtml20_start_body_tag(void *pdoc, Node *node)
       break;
     }
   }
-  W_L(">\r\n");
+  W_L(">");
+
   return chtml20->out;
 }
 
@@ -931,15 +1069,16 @@ s_chtml20_start_body_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("</body>\r\n");
+  W_L("</body>");
+
   return chtml20->out;
 }
 
@@ -955,10 +1094,10 @@ s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_a_tag(void *pdoc, Node *node) 
 {
-  Attr          *attr;
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  Attr        *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -971,13 +1110,8 @@ s_chtml20_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':
@@ -998,7 +1132,9 @@ s_chtml20_start_a_tag(void *pdoc, Node *node)
         /* CHTML1.0                                                           */
         /*--------------------------------------------------------------------*/
         value = chxj_encoding_parameter(r, value);
-        value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
+        if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
+          value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
+        }
         W_L(" href=\"");
         W_V(value);
         W_L("\"");
@@ -1127,15 +1263,16 @@ s_chtml20_start_a_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("</a>");
+
   return chtml20->out;
 }
 
@@ -1149,17 +1286,36 @@ s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_br_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_br_tag(void *pdoc, Node *node
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<br>\r\n");
+  W_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))) {
+        W_L(" clear=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+  }
+  W_L(">");
+
   return chtml20->out;
 }
 
@@ -1175,9 +1331,9 @@ s_chtml20_start_br_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -1198,9 +1354,9 @@ s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -1221,15 +1377,16 @@ s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<br>\r\n");
+  W_L("<br>");
+
   return chtml20->out;
 }
 
@@ -1245,38 +1402,32 @@ s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_font_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *color = NULL;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<font");
+
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
   for (attr = qs_get_attr(doc,node);
-       attr
+       attr && color == NULL;
        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);
-
-    switch(*name) {
-    case 'c':
-    case 'C':
-      if (strcasecmp(name, "color") == 0) {
-        W_L(" color=\"");
-        W_V(value);
-        W_L("\"");
-      }
-      break;
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    switch(*name) {
+    case 'c':
+    case 'C':
+      if (strcasecmp(name, "color") == 0 && value && *value) {
+        color = apr_pstrdup(doc->buf.pool, value);
+      }
+      break;
 
     case 's':
     case 'S':
@@ -1292,7 +1443,12 @@ s_chtml20_start_font_tag(void *pdoc, Node *node)
       break;
     }
   }
-  W_L(">");
+  if (color) {
+    W_L("<font color=\"");
+    W_V(color);
+    W_L("\">");
+    chtml20->font_flag++;
+  }
   return chtml20->out;
 }
 
@@ -1308,15 +1464,18 @@ s_chtml20_start_font_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("</font>");
+  if (chtml20->font_flag) {
+    W_L("</font>");
+    chtml20->font_flag--;
+  }
   return chtml20->out;
 }
 
@@ -1332,26 +1491,26 @@ s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_form_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t *chtml20;
+  Doc *doc;
+  request_rec *r;
+  Attr *attr;
+  char *new_hidden_tag = NULL;
+  char *attr_method = NULL;
+  char *attr_action = NULL;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<form");
   /*--------------------------------------------------------------------------*/
   /* 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);
 
@@ -1362,12 +1521,8 @@ s_chtml20_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        value = chxj_encoding_parameter(r, value);
-        value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
-
-        W_L(" action=\"");
-        W_V(value);
-        W_L("\"");
+        attr_action = chxj_encoding_parameter(r, value);
+        attr_action= chxj_add_cookie_parameter(r, attr_action, chtml20->cookie);
       }
       break;
 
@@ -1377,9 +1532,7 @@ s_chtml20_start_form_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" method=\"");
-        W_V(value);
-        W_L("\"");
+        attr_method = apr_pstrdup(doc->pool, value);
       }
       break;
 
@@ -1397,7 +1550,37 @@ s_chtml20_start_form_tag(void *pdoc, Node *node)
       break;
     }
   }
+
+  int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
+
+  W_L("<form");
+  if (attr_action) {
+    char *q;
+    char *new_query_string = NULL;
+    q = strchr(attr_action, '?');
+    if (q) {
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE, CHXJ_FALSE, chtml20->entryp);
+      if (new_hidden_tag || new_query_string) {
+        *q = 0;
+      }
+    }
+    W_L(" action=\"");
+    W_V(attr_action);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
+    W_L("\"");
+  }
+  if (attr_method) {
+    W_L(" method=\"");
+    W_V(attr_method);
+    W_L("\"");
+  }
   W_L(">");
+  if (new_hidden_tag) {
+    W_V(new_hidden_tag);
+  }
   return chtml20->out;
 }
 
@@ -1413,15 +1596,16 @@ s_chtml20_start_form_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("</form>");
+
   return chtml20->out;
 }
 
@@ -1437,98 +1621,101 @@ s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_input_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  char          *max_length  = NULL;
-  char          *type        = NULL;
-  char          *name        = NULL;
-  char          *value       = NULL;
-  char          *istyle      = NULL;
-  char          *size        = NULL;
-  char          *checked     = NULL;
-  char          *accesskey   = NULL;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  char        *max_length  = NULL;
+  char        *type        = NULL;
+  char        *name        = NULL;
+  char        *value       = NULL;
+  char        *istyle      = NULL;
+  char        *size        = NULL;
+  char        *checked     = NULL;
+  char        *accesskey   = NULL;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
+
   W_L("<input");
   /*--------------------------------------------------------------------------*/
   /* Get Attributes                                                           */
   /*--------------------------------------------------------------------------*/
-  type       = qs_get_type_attr(doc, node, r);
-  name       = qs_get_name_attr(doc, node, r);
-  value      = qs_get_value_attr(doc,node,r);
-  istyle     = qs_get_istyle_attr(doc,node,r);
-  max_length = qs_get_maxlength_attr(doc,node,r);
-  checked    = qs_get_checked_attr(doc,node,r);
-  accesskey  = qs_get_accesskey_attr(doc, node, r);
-  size       = qs_get_size_attr(doc, node, r);
+  type       = qs_get_type_attr(doc, node, doc->buf.pool);
+  name       = qs_get_name_attr(doc, node, doc->buf.pool);
+  value      = qs_get_value_attr(doc,node,doc->buf.pool);
+  istyle     = qs_get_istyle_attr(doc,node,doc->buf.pool);
+  max_length = qs_get_maxlength_attr(doc,node,doc->buf.pool);
+  checked    = qs_get_checked_attr(doc,node,doc->buf.pool);
+  accesskey  = qs_get_accesskey_attr(doc, node, doc->buf.pool);
+  size       = qs_get_size_attr(doc, node, doc->buf.pool);
 
   if (type) {
-    W_L(" type=\"");
-    W_V(type);
-    W_L("\" ");
+    type = qs_trim_string(doc->buf.pool, type);
+    if (type && (STRCASEEQ('t','T',"text",    type) ||
+                 STRCASEEQ('p','P',"password",type) ||
+                 STRCASEEQ('c','C',"checkbox",type) ||
+                 STRCASEEQ('r','R',"radio",   type) ||
+                 STRCASEEQ('h','H',"hidden",  type) ||
+                 STRCASEEQ('s','S',"submit",  type) ||
+                 STRCASEEQ('r','R',"reset",   type))) {
+      W_L(" type=\"");
+      W_V(type);
+      W_L("\"");
+    }
   }
-
-  if (size) {
+  if (size && *size) {
     W_L(" size=\"");
     W_V(size);
-    W_L("\" ");
+    W_L("\"");
   }
-
-  if (name) {
+  if (name && *name) {
     W_L(" name=\"");
     W_V(name);
-    W_L("\" ");
+    W_L("\"");
   }
-
-  if (value) {
+  if (value && *value) {
     W_L(" value=\"");
-    W_V(value);
-    W_L("\" ");
+    W_V(chxj_add_slash_to_doublequote(doc->pool, value));
+    W_L("\"");
   }
-
-  if (accesskey) {
+  if (accesskey && *accesskey) {
     W_L(" accesskey=\"");
     W_V(accesskey);
-    W_L("\" ");
+    W_L("\"");
   }
-
   if (istyle) {
     /*------------------------------------------------------------------------*/
     /* CHTML 2.0                                                              */
     /*------------------------------------------------------------------------*/
-    W_L(" istyle=\"");
-    W_V(istyle);
-    W_L("\" ");
+    if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
+      W_L(" istyle=\"");
+      W_V(istyle);
+      W_L("\"");
+    }
   }
-
   /*--------------------------------------------------------------------------*/
   /* The figure is default for the password.                                  */
   /*--------------------------------------------------------------------------*/
-  if (max_length) {
-    if (chxj_chk_numeric(max_length) != 0)
-      max_length = apr_psprintf(r->pool, "0");
-    if (istyle != NULL && istyle[0] == '1') {
-      char *vv = apr_psprintf(doc->buf.pool, 
-                              " maxlength=\"%d\"",
-                              chxj_atoi(max_length)*2);
+  if (max_length && *max_length) {
+    if (chxj_chk_numeric(max_length) != 0) {
+      max_length = apr_psprintf(doc->buf.pool, "0");
+    }
+    if (istyle && *istyle == '1') {
+      char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
       W_V(vv);
     }
     else {
-      char *vv = apr_psprintf(doc->buf.pool, 
-                              " maxlength=\"%d\"",
-                              chxj_atoi(max_length));
+      char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
       W_V(vv);
     }
   }
-
   if (checked) {
-    W_L(" checked ");
+    W_L(" checked");
   }
-  W_L(" >");
+  W_L(">");
+
   return chtml20->out;
 }
 
@@ -1544,9 +1731,9 @@ s_chtml20_start_input_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -1567,9 +1754,9 @@ s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -1591,15 +1778,16 @@ s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("</center>");
+
   return chtml20->out;
 }
 
@@ -1615,15 +1803,16 @@ s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("<ul>");
+
   return chtml20->out;
 }
 
@@ -1648,6 +1837,7 @@ s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
   r       = doc->r;
 
   W_L("</ul>");
+
   return chtml20->out;
 }
 
@@ -1661,17 +1851,39 @@ s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_ol_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_ol_tag(void *pdoc, Node *node
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<ol>");
+  W_L("<ol");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
+      W_L(" type=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('s','S',"start",name) && value && *value) {
+      W_L(" start=\"");
+      W_V(value);
+      W_L("\"");
+    }
+  }
+  W_L(">");
+
   return chtml20->out;
 }
 
@@ -1687,15 +1899,16 @@ s_chtml20_start_ol_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   W_L("</ol>");
+
   return chtml20->out;
 }
 
@@ -1709,17 +1922,38 @@ s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_li_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_li_tag(void *pdoc, Node *node
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<li>");
+  W_L("<li");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
+      W_L(" type=\"");
+      W_V(value);
+      W_L("\"");
+    }
+    else if (STRCASEEQ('v','V',"value", name) && value && *value) {
+      W_L(" value=\"");
+      W_V(value);
+      W_L("\"");
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -1735,15 +1969,7 @@ s_chtml20_start_li_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
-  W_L("</li>");
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
   return chtml20->out;
 }
 
@@ -1759,26 +1985,22 @@ s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_hr_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<hr ");
+
+  W_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':
@@ -1786,9 +2008,11 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" align=\"");
-        W_V(value);
-        W_L("\" ");
+        if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
+          W_L(" align=\"");
+          W_V(value);
+          W_L("\"");
+        }
       }
       break;
 
@@ -1798,9 +2022,11 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" size=\"");
-        W_V(value);
-        W_L("\" ");
+        if (value && value[0] != '\0') {
+          W_L(" size=\"");
+          W_V(value);
+          W_L("\"");
+        }
       }
       break;
 
@@ -1810,9 +2036,11 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" width=\"");
-        W_V(value);
-        W_L("\" ");
+        if (value && value[0] != '\0') {
+          W_L(" width=\"");
+          W_V(value);
+          W_L("\"");
+        }
       }
       break;
 
@@ -1822,7 +2050,7 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" noshade ");
+        W_L(" noshade");
       }
       break;
 
@@ -1840,7 +2068,7 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
       break;
     }
   }
-  W_L(" >");
+  W_L(">");
   return chtml20->out;
 }
 
@@ -1856,14 +2084,7 @@ s_chtml20_start_hr_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
   return chtml20->out;
 }
 
@@ -1879,10 +2100,10 @@ s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_img_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t    *chtml20;
+  Doc          *doc;
+  request_rec  *r;
+  Attr         *attr;
 #ifndef IMG_NOT_CONVERT_FILENAME
   device_table *spec;
 #endif
@@ -1902,13 +2123,8 @@ s_chtml20_start_img_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 's':
     case 'S':
@@ -1919,13 +2135,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
 #ifdef IMG_NOT_CONVERT_FILENAME
         value = chxj_encoding_parameter(r, value);
         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
-        if (value) {
-          value = apr_psprintf(r->pool,
-                               "%s%c%s=true",
-                               value,
-                               (strchr(value, '?')) ? '&' : '?',
-                               CHXJ_COOKIE_NOUPDATE_PARAM);
-        }
+        value = chxj_add_cookie_no_update_parameter(r, value);
         W_L(" src=\"");
         W_V(value);
         W_L("\"");
@@ -1933,13 +2143,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
         value = chxj_img_conv(r, spec, value);
         value = chxj_encoding_parameter(r, value);
         value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
-        if (value) {
-          value = apr_psprintf(r->pool,
-                               "%s%c%s=true",
-                               value,
-                               (strchr(value, '?')) ? '&' : '?',
-                               CHXJ_COOKIE_NOUPDATE_PARAM);
-        }
+        value = chxj_add_cookie_no_update_parameter(r, value);
         W_L(" src=\"");
         W_V(value);
         W_L("\"");
@@ -1953,11 +2157,24 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
-        W_L(" align=\"");
-        W_V(value);
-        W_L("\"");
+        if (value) {
+          if (STRCASEEQ('t','T',"top",   value) ||
+              STRCASEEQ('m','M',"middle",value) ||
+              STRCASEEQ('b','B',"bottom",value) ||
+              STRCASEEQ('l','L',"left",  value) ||
+              STRCASEEQ('r','R',"right", value)) {
+            W_L(" align=\"");
+            W_V(value);
+            W_L("\"");
+          }
+          else if (STRCASEEQ('c','C',"center",  value)) {
+            W_L(" align=\"");
+            W_L("middle");
+            W_L("\"");
+          }
+        }
       }
-      else if (strcasecmp(name, "alt"   ) == 0) {
+      else if (strcasecmp(name, "alt"   ) == 0 && value && *value) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
@@ -1965,17 +2182,11 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
         W_V(value);
         W_L("\"");
       }
-      else if (strcasecmp(name, "align" ) == 0) {
-        /*--------------------------------------------------------------------*/
-        /* CHTML 4.0                                                          */
-        /*--------------------------------------------------------------------*/
-        /* ignore */
-      }
       break;
 
     case 'w':
     case 'W':
-      if (strcasecmp(name, "width" ) == 0) {
+      if (strcasecmp(name, "width" ) == 0 && value && *value) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
@@ -1987,7 +2198,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
 
     case 'h':
     case 'H':
-      if (strcasecmp(name, "height") == 0) {
+      if (strcasecmp(name, "height") == 0 && value && *value) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
@@ -1995,8 +2206,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
         W_V(value);
         W_L("\"");
       }
-      else
-      if (strcasecmp(name, "hspace") == 0) {
+      else if (strcasecmp(name, "hspace") == 0 && value && *value) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
@@ -2008,7 +2218,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
 
     case 'v':
     case 'V':
-      if (strcasecmp(name, "vspace") == 0) {
+      if (strcasecmp(name, "vspace") == 0 && value && *value) {
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0                                                          */
         /*--------------------------------------------------------------------*/
@@ -2038,13 +2248,7 @@ s_chtml20_start_img_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
 
   return chtml20->out;
 }
@@ -2061,10 +2265,10 @@ s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_select_tag(void *pdoc, Node *child)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -2072,18 +2276,14 @@ s_chtml20_start_select_tag(void *pdoc, Node *child)
 
   char *size      = NULL;
   char *name      = NULL;
+  char *multiple  = NULL;
 
   W_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':
@@ -2091,7 +2291,7 @@ s_chtml20_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;
 
@@ -2101,7 +2301,7 @@ s_chtml20_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;
 
@@ -2111,7 +2311,7 @@ s_chtml20_start_select_tag(void *pdoc, Node *child)
         /*--------------------------------------------------------------------*/
         /* CHTML 1.0 version 2.0                                              */
         /*--------------------------------------------------------------------*/
-        /* not support */
+        multiple = apr_pstrdup(doc->buf.pool, val);
       }
       break;
 
@@ -2119,19 +2319,20 @@ s_chtml20_start_select_tag(void *pdoc, Node *child)
       break;
     }
   }
-
-  if (size) {
+  if (size && *size) {
     W_L(" size=\"");
     W_V(size);
     W_L("\"");
   }
-
-  if (name) {
+  if (name && *name) {
     W_L(" name=\"");
     W_V(name);
     W_L("\"");
   }
-  W_L(">\n");
+  if (multiple) {
+    W_L(" multiple");
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2147,15 +2348,13 @@ s_chtml20_start_select_tag(void *pdoc, Node *child)
 static char *
 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
-  r       = doc->r;
 
-  W_L("</select>\n");
+  W_L("</select>");
   return chtml20->out;
 }
 
@@ -2171,10 +2370,10 @@ s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_option_tag(void *pdoc, Node *child)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -2187,13 +2386,8 @@ s_chtml20_start_option_tag(void *pdoc, Node *child)
   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':
@@ -2201,7 +2395,7 @@ s_chtml20_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;
 
@@ -2211,7 +2405,7 @@ s_chtml20_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;
 
@@ -2225,12 +2419,9 @@ s_chtml20_start_option_tag(void *pdoc, Node *child)
     W_V(value);
     W_L("\"");
   }
-  else {
-    W_L(" value=\"\"");
-  }
 
   if (selected) {
-    W_L(" selected ");
+    W_L(" selected");
   }
   W_L(">");
   return chtml20->out;
@@ -2248,13 +2439,7 @@ s_chtml20_start_option_tag(void *pdoc, Node *child)
 static char *
 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
 
   /* Don't close */
 
@@ -2273,10 +2458,10 @@ s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_div_tag(void *pdoc, Node *child)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -2289,21 +2474,17 @@ s_chtml20_start_div_tag(void *pdoc, Node *child)
   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 (STRCASEEQ('a','A',"align", nm)) {
+    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) {
     W_L(" align=\"");
     W_V(align);
@@ -2325,15 +2506,10 @@ s_chtml20_start_div_tag(void *pdoc, Node *child)
 static char *
 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  W_L("</div>\n");
+  W_L("</div>");
   return chtml20->out;
 }
 
@@ -2347,17 +2523,33 @@ s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h1_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_h1_tag(void *pdoc, Node *node
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h1>\r\n");
+  W_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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2373,15 +2565,13 @@ s_chtml20_start_h1_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
-  r       = doc->r;
 
-  W_L("</h1>\r\n");
+  W_L("</h1>");
   return chtml20->out;
 }
 
@@ -2395,17 +2585,33 @@ s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h2_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_h2_tag(void *pdoc, Node *node
 {
   chtml20_t   *chtml20;
   Doc         *doc;
   request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h2>\r\n");
+  W_L("<h2");
+  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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2421,15 +2627,11 @@ s_chtml20_start_h2_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child)) 
 { 
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  W_L("</h2>");
 
-  W_L("</h2>\r\n");
   return chtml20->out;
 }
 
@@ -2443,17 +2645,33 @@ s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h3_tag(void *pdoc, Node *UNUSED(node)
+s_chtml20_start_h3_tag(void *pdoc, Node *node
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h3>\r\n");
+  W_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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2469,15 +2687,10 @@ s_chtml20_start_h3_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  W_L("</h3>\r\n");
+  W_L("</h3>");
   return chtml20->out;
 }
 
@@ -2491,17 +2704,33 @@ s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h4_tag(void *pdoc, Node *UNUSED(node)) 
+s_chtml20_start_h4_tag(void *pdoc, Node *node)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h4>\r\n");
+  W_L("<h4");
+  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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2517,15 +2746,10 @@ s_chtml20_start_h4_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
-  W_L("</h4>\r\n");
+  W_L("</h4>");
   return chtml20->out;
 }
 
@@ -2539,17 +2763,33 @@ s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h5_tag(void *pdoc, Node *UNUSED(node)) 
+s_chtml20_start_h5_tag(void *pdoc, Node *node)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h5>\r\n");
+  W_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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2565,15 +2805,10 @@ s_chtml20_start_h5_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  W_L("</h5>\r\n");
+  W_L("</h5>");
   return chtml20->out;
 }
 
@@ -2587,17 +2822,33 @@ s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_h6_tag(void *pdoc, Node *UNUSED(node)) 
+s_chtml20_start_h6_tag(void *pdoc, Node *node)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<h6>\r\n");
+  W_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))) {
+        W_L(" align=\"");
+        W_V(value);
+        W_L("\"");
+        break;
+      }
+    }
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2613,15 +2864,10 @@ s_chtml20_start_h6_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  W_L("</h6>\r\n");
+  W_L("</h6>");
   return chtml20->out;
 }
 
@@ -2637,16 +2883,10 @@ s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
   chtml20->pre_flag++;
-
   W_L("<pre>");
   return chtml20->out;
 }
@@ -2663,13 +2903,8 @@ s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
   W_L("</pre>");
   chtml20->pre_flag--;
@@ -2687,17 +2922,40 @@ s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
  * @return The conversion result is returned.
  */
 static char *
-s_chtml20_start_p_tag(void *pdoc, Node *UNUSED(node)) 
+s_chtml20_start_p_tag(void *pdoc, Node *node)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
+  char        *align = NULL;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
-  W_L("<p>");
+  W_L("<p");
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *nm  = qs_get_attr_name(doc,attr);
+    char *val = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('a','A',"align", nm)) {
+      /*----------------------------------------------------------------------*/
+      /* CHTML 1.0 (W3C version 3.2)                                          */
+      /*----------------------------------------------------------------------*/
+      if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
+        align = apr_pstrdup(doc->buf.pool, val);
+        break;
+      }
+    }
+  }
+  if (align) {
+    W_L(" align=\"");
+    W_V(align);
+    W_L("\"");
+  }
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2713,9 +2971,9 @@ s_chtml20_start_p_tag(void *pdoc, Node *UNUSED(node))
 static char *
 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -2729,10 +2987,10 @@ s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_chxjif_tag(void *pdoc, Node *node)
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  Node          *child;
-  request_rec   *r;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  Node        *child;
+  request_rec *r;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
@@ -2741,6 +2999,7 @@ s_chtml20_chxjif_tag(void *pdoc, Node *node)
   for (child = qs_get_child_node(doc, node);
        child;
        child = qs_get_next_node(doc, child)) {
+
     W_V(child->otext);
     s_chtml20_chxjif_tag(pdoc, child);
   }
@@ -2760,31 +3019,35 @@ s_chtml20_chxjif_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_start_textarea_tag(void *pdoc, Node *node) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  Attr          *attr;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  Attr        *attr;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
 
   chtml20->textarea_flag++;
-  W_L("<textarea ");
+  W_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) {
+        W_L(" accesskey=\"");
+        W_V(value);
+        W_L("\"");
+      }
+      break;
+
     case 'n':
     case 'N':
-      if (strcasecmp(name, "name") == 0) {
+      if (strcasecmp(name, "name") == 0 && value && *value != 0) {
         W_L(" name=\"");
         W_V(value);
         W_L("\"");
@@ -2793,7 +3056,7 @@ s_chtml20_start_textarea_tag(void *pdoc, Node *node)
 
     case 'r':
     case 'R':
-      if (strcasecmp(name, "rows") == 0) {
+      if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
         W_L(" rows=\"");
         W_V(value);
         W_L("\"");
@@ -2802,18 +3065,27 @@ s_chtml20_start_textarea_tag(void *pdoc, Node *node)
 
     case 'c':
     case 'C':
-      if (strcasecmp(name, "cols") == 0) {
+      if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
         W_L(" cols=\"");
         W_V(value);
         W_L("\"");
       }
       break;
 
+    case 'i':
+    case 'I':
+      if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
+        W_L(" istyle=\"");
+        W_V(value);
+        W_L("\"");
+      }
+      break;
+
     default:
       break;
     }
   }
-  W_L(">\r\n");
+  W_L(">");
   return chtml20->out;
 }
 
@@ -2829,15 +3101,10 @@ s_chtml20_start_textarea_tag(void *pdoc, Node *node)
 static char *
 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child)) 
 {
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t   *chtml20 = GET_CHTML20(pdoc);
+  Doc         *doc     = chtml20->doc;
 
-  W_L("</textarea>\r\n");
+  W_L("</textarea>");
   chtml20->textarea_flag--;
 
   return chtml20->out;
@@ -2847,33 +3114,40 @@ s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_text_tag(void *pdoc, Node *child)
 {       
-  chtml20_t     *chtml20;
-  Doc           *doc;
-  request_rec   *r;
-  char          *textval;
-  char          *tmp;
-  char          *tdst;
-  char          one_byte[2];
-  int           ii;
-  int           tdst_len;
+  chtml20_t   *chtml20;
+  Doc         *doc;
+  request_rec *r;
+  char        *textval;
+  char        *tmp;
+  char        *tdst;
+  char        one_byte[2];
+  int         ii;
+  int         tdst_len;
 
   chtml20 = GET_CHTML20(pdoc);
   doc     = chtml20->doc;
   r       = doc->r;
   
   textval = qs_get_node_value(doc,child);
-  textval = qs_trim_string(r->pool, textval);
-  if (strlen(textval) == 0) 
+  if (strlen(textval) == 0) {
     return chtml20->out;
+  }
   
   tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
   memset(tmp, 0, qs_get_node_size(doc,child)+1);
   
-  tdst     = qs_alloc_zero_byte_string(r);
+  tdst     = qs_alloc_zero_byte_string(doc->buf.pool);
   memset(one_byte, 0, sizeof(one_byte));
   tdst_len = 0;
   
   for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
+    char *out;
+    int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
+    if (rtn != 0) {
+      tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
+      ii+=(rtn - 1);
+      continue;
+    }
     if (is_sjis_kanji(textval[ii])) {
       one_byte[0] = textval[ii+0];
       tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
@@ -2903,6 +3177,79 @@ s_chtml20_text_tag(void *pdoc, Node *child)
 
 
 /**
+ * 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_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+  W_L("<blockquote>");
+  return chtml20->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_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+  W_L("</blockquote>");
+  return chtml20->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_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+  W_L("<dir>");
+  return chtml20->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_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+
+  W_L("</dir>");
+  return chtml20->out;
+}
+
+
+/**
  * It is a handler who processes the DL tag.
  *
  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
@@ -2913,21 +3260,15 @@ s_chtml20_text_tag(void *pdoc, Node *child)
 static char *
 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
   W_L("<dl>");
   return chtml20->out;
 }
 
 
 /**
- * It is a handler who processes the DLtag.
+ * 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.
@@ -2937,21 +3278,15 @@ s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
-  W_L("</dl>\n");
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+  W_L("</dl>");
   return chtml20->out;
 }
 
 
 /**
- * It is a handler who processes the DT tag.
+ * 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.
@@ -2961,21 +3296,15 @@ s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
   W_L("<dt>");
   return chtml20->out;
 }
 
 
 /**
- * It is a handler who processes the DT tag.
+ * 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.
@@ -2985,21 +3314,14 @@ s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
 
-  W_L("\n");
   return chtml20->out;
 }
 
 
 /**
- * It is a handler who processes the DD tag.
+ * 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.
@@ -3009,21 +3331,15 @@ s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
-
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
-
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
   W_L("<dd>");
   return chtml20->out;
 }
 
 
 /**
- * It is a handler who processes the DD tag.
+ * 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.
@@ -3033,15 +3349,214 @@ s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
 static char *
 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
 {
-  chtml20_t    *chtml20;
-  Doc          *doc;
-  request_rec  *r;
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
 
-  chtml20 = GET_CHTML20(pdoc);
-  doc     = chtml20->doc;
-  r       = doc->r;
+  return chtml20->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_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
 
-  W_L("\n");
+  W_L("<menu>");
+  return chtml20->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_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc = chtml20->doc;
+
+  W_L("</menu>");
+  return chtml20->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_chtml20_start_plaintext_tag(void *pdoc, Node *node)
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+
+  W_L("<plaintext>");
+  s_chtml20_start_plaintext_tag_inner(pdoc,node);
+  return chtml20->out;
+}
+
+static char *
+s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc     = chtml20->doc;
+  Node      *child;
+
+  for (child = qs_get_child_node(doc, node);
+       child;
+       child = qs_get_next_node(doc, child)) {
+    W_V(child->otext);
+    s_chtml20_start_plaintext_tag_inner(pdoc, child);
+  }
+  return chtml20->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_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  return chtml20->out;
+}
+
+/**
+ * It is a hanblinker who processes the BLINK tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLINK tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml20_start_blink_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc = chtml20->doc;
+  W_L("<blink>");
+  return chtml20->out;
+}
+
+
+/**
+ * It is a hanblinker who processes the BLINK tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The BLINK tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml20_end_blink_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc = chtml20->doc;
+  W_L("</blink>");
+  return chtml20->out;
+}
+
+
+/**
+ * It is a hanmarqueeer who processes the MARQUEE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MARQUEE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml20_start_marquee_tag(void *pdoc, Node *node)
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc = chtml20->doc;
+  Attr      *attr;
+  W_L("<marquee");
+  /*--------------------------------------------------------------------------*/
+  /* Get Attributes                                                           */
+  /*--------------------------------------------------------------------------*/
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name   = qs_get_attr_name(doc,attr);
+    char *value  = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('d','D',"direction", name)) {
+      if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
+        W_L(" direction=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+    else if (STRCASEEQ('b','B',"behavior",name)) {
+      if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
+        W_L(" behavior=\""); 
+        W_V(value);
+        W_L("\"");
+      }
+    }
+    else if (STRCASEEQ('l','L',"loop",name)) {
+      if (value && *value) {
+        W_L(" loop=\"");
+        W_V(value);
+        W_L("\"");
+      }
+    }
+  }
+  W_L(">");
+  return chtml20->out;
+}
+
+
+/**
+ * It is a hanmarqueeer who processes the MARQUEE tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The MARQUEE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml20_end_marquee_tag(void *pdoc, Node *UNUSED(child))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc       *doc = chtml20->doc;
+  W_L("</marquee>");
+  return chtml20->out;
+}
+
+
+/**
+ *  * It is handler who processes the New Line Code.
+ *   */
+static char *
+s_chtml20_newline_mark(void *pdoc, Node *UNUSED(node))
+{
+  chtml20_t *chtml20 = GET_CHTML20(pdoc);
+  Doc *doc = chtml20->doc;
+  W_NLCODE();
   return chtml20->out;
 }
 /*