OSDN Git Service

<h1-6 /> for XHTML(y!)
authorcoltware@gmail.com <coltware@gmail.com>
Thu, 5 Nov 2009 03:26:12 +0000 (03:26 +0000)
committerAtsushi Konno <atkonn@gmail.com>
Tue, 10 Nov 2009 10:41:21 +0000 (19:41 +0900)
git-svn-id: svn://coltware.com/home/svn/svnroot/mod_chxj/trunk@16 94a86f0a-4377-0410-8349-a3afc59ff858

src/chxj_jxhtml.c

index e6ce0a3..d82040f 100644 (file)
@@ -4473,6 +4473,7 @@ s_jxhtml_start_h1_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml = GET_JXHTML(pdoc);
   doc    = jxhtml->doc;
@@ -4496,6 +4497,7 @@ s_jxhtml_start_h1_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4508,17 +4510,35 @@ s_jxhtml_start_h1_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:xx-large;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h1");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -4543,7 +4563,7 @@ s_jxhtml_end_h1_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
   
-  W_L("</div>");
+  W_L("</h1>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }
@@ -4569,6 +4589,7 @@ s_jxhtml_start_h2_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4592,6 +4613,7 @@ s_jxhtml_start_h2_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4604,17 +4626,35 @@ s_jxhtml_start_h2_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:x-large;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h2");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -4639,7 +4679,7 @@ s_jxhtml_end_h2_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
   
-  W_L("</div>");
+  W_L("</h2>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }
@@ -4664,6 +4704,7 @@ s_jxhtml_start_h3_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4687,6 +4728,7 @@ s_jxhtml_start_h3_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4699,17 +4741,35 @@ s_jxhtml_start_h3_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:large;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h3");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -4734,7 +4794,7 @@ s_jxhtml_end_h3_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
 
-  W_L("</div>");
+  W_L("</h3>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }
@@ -4759,6 +4819,7 @@ s_jxhtml_start_h4_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4782,6 +4843,7 @@ s_jxhtml_start_h4_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4794,17 +4856,35 @@ s_jxhtml_start_h4_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:small;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h4");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -4829,7 +4909,7 @@ s_jxhtml_end_h4_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
   
-  W_L("</div>");
+  W_L("</h4>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }
@@ -4855,6 +4935,7 @@ s_jxhtml_start_h5_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4878,6 +4959,7 @@ s_jxhtml_start_h5_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4890,17 +4972,35 @@ s_jxhtml_start_h5_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:x-small;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h5");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -4925,7 +5025,7 @@ s_jxhtml_end_h5_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
   
-  W_L("</div>");
+  W_L("</h5>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }
@@ -4951,6 +5051,7 @@ s_jxhtml_start_h6_tag(void *pdoc, Node *node)
   Attr        *attr;
   char        *attr_style = NULL;
   char        *attr_align = NULL;
+  char        *css_clear  = NULL;
 
   jxhtml   = GET_JXHTML(pdoc);
   doc     = jxhtml->doc;
@@ -4974,6 +5075,7 @@ s_jxhtml_start_h6_tag(void *pdoc, Node *node)
     css_prop_list_t *style = s_jxhtml_push_and_get_now_style(pdoc, node, attr_style);
     if (style) {
       css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
+      css_property_t *clear_prop           = chxj_css_get_property_value(doc, style, "clear");
       css_property_t *cur;
       for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
         if (STRCASEEQ('l','L',"left", cur->value)) {
@@ -4986,17 +5088,35 @@ s_jxhtml_start_h6_tag(void *pdoc, Node *node)
           attr_align = apr_pstrdup(doc->pool, "right");
         }
       }
+      for (cur = clear_prop->next; cur != clear_prop; cur = cur->next) {
+        if (STRCASEEQ('b','B',"both", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "both");
+        }
+        else if (STRCASEEQ('r','R',"right", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "right");
+        }
+        else if (STRCASEEQ('l','L',"left", cur->value)) {
+          css_clear = apr_pstrdup(doc->pool, "left");
+        }
+      }
     }
   }
-  W_L("<div");
-  W_L(" style=\""); 
-  W_L("font-size:xx-small;");
-  if (attr_align) {
-    W_L("text-align:");
-    W_V(attr_align);
-    W_L(";");
+  W_L("<h6");
+  if (attr_align || css_clear ) {
+    W_L(" style=\"");
+    if(attr_align){
+      W_L("text-align:");
+      W_V(attr_align);
+      W_L(";");
+    }
+    if(css_clear){
+      W_L("clear:");
+      W_V(css_clear);
+      W_L(";");
+    }
+    W_L("\"");
   }
-  W_L("\">");
+  W_L(">");
 
   return jxhtml->out;
 }
@@ -5021,7 +5141,7 @@ s_jxhtml_end_h6_tag(void *pdoc, Node *UNUSED(child))
   doc     = jxhtml->doc;
   r       = doc->r;
   
-  W_L("</div>");
+  W_L("</h6>");
   if (IS_CSS_ON(jxhtml->entryp)) {
     chxj_css_pop_prop_list(jxhtml->css_prop_stack);
   }