OSDN Git Service

* The pre tag and p tag are added to XHTML.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Fri, 16 Jun 2006 00:43:43 +0000 (00:43 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Fri, 16 Jun 2006 00:43:43 +0000 (00:43 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/trunk@693 1a406e8e-add9-4483-a2c8-d8cac5b7c224

include/chxj_xhtml_mobile_1_0.h
src/chxj_hdml.c
src/chxj_xhtml_mobile_1_0.c

index 725c9fb..195cbfc 100644 (file)
@@ -26,6 +26,7 @@ typedef struct _xhtml_t {
     Doc*               doc;
     char*              out;
     int                out_len;
+    int                pre_flag;
 
     device_table_t*    spec;
     mod_chxj_config*   conf;
index 8eca05c..6ac6ec6 100644 (file)
 
 static void  s_init_hdml            (hdml_t* hdml, Doc* doc, request_rec* r, device_table_t* spec);
 static char* s_hdml_node_exchange   (hdml_t* doc,  Node* node, int indent);
-static char* s_hdml_start_html_tag  (hdml_t* doc,  Node* child);
-static char* s_hdml_end_html_tag    (hdml_t* doc,  Node* child);
-static char* s_hdml_start_li_tag    (hdml_t* doc,  Node* child);
-static char* s_hdml_end_li_tag      (hdml_t* doc,  Node* child);
+static char* s_hdml_start_html_tag  (hdml_t* doc,  Node* node);
+static char* s_hdml_end_html_tag    (hdml_t* doc,  Node* node);
+static char* s_hdml_start_li_tag    (hdml_t* doc,  Node* node);
+static char* s_hdml_end_li_tag      (hdml_t* doc,  Node* node);
 static char* s_hdml_start_meta_tag  (hdml_t* doc,  Node* node);
 static char* s_hdml_end_meta_tag    (hdml_t* doc,  Node* node);
 static char* s_hdml_start_head_tag  (hdml_t* doc,  Node* node);
@@ -283,6 +283,20 @@ s_hdml_node_exchange(hdml_t* hdml, Node* node,  int indent)
 
 
     /*------------------------------------------------------------------------*/
+    /* <PRE> (for TEST)                                                       */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
+      s_hdml_node_exchange (hdml, child, indent+1);
+    }
+    else
+    /*------------------------------------------------------------------------*/
+    /* <P> (for TEST)                                                         */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "p") == 0) {
+      s_hdml_node_exchange (hdml, child, indent+1);
+    }
+    else
+    /*------------------------------------------------------------------------*/
     /* <UL> (for TEST)                                                        */
     /*------------------------------------------------------------------------*/
     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "ul") == 0) {
index e39eb80..1765be8 100644 (file)
 
 
 static char* s_xhtml_1_0_node_exchange    (xhtml_t* xhtml, Node* node, int indent);
-static char* s_xhtml_1_0_start_html_tag   (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_html_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_ul_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_ul_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h1_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h1_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h2_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h2_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h3_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h3_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h4_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h4_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h5_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h5_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_h6_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_h6_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_ol_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_ol_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_ol_tag       (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_start_li_tag     (xhtml_t* xhtml, Node* child);
-static char* s_xhtml_1_0_end_li_tag       (xhtml_t* xhtml, Node* child);
+static char* s_xhtml_1_0_start_html_tag   (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_html_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_p_tag      (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_p_tag        (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_pre_tag    (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_pre_tag      (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_ul_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_ul_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h1_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h1_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h2_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h2_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h3_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h3_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h4_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h4_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h5_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h5_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_h6_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_h6_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_ol_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_ol_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_ol_tag       (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_start_li_tag     (xhtml_t* xhtml, Node* node);
+static char* s_xhtml_1_0_end_li_tag       (xhtml_t* xhtml, Node* node);
 static char* s_xhtml_1_0_start_meta_tag   (xhtml_t* xhtml, Node* node);
 static char* s_xhtml_1_0_end_meta_tag     (xhtml_t* xhtml, Node* node);
 static char* s_xhtml_1_0_start_head_tag   (xhtml_t* xhtml, Node* node);
@@ -212,6 +216,24 @@ s_xhtml_1_0_node_exchange(xhtml_t* xhtml, Node* node, int indent)
     char* name = qs_get_node_name(doc,child);
 
     /*------------------------------------------------------------------------*/
+    /* <P> (for TEST)                                                         */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "p") == 0) {
+      s_xhtml_1_0_start_p_tag   (xhtml, child);
+      s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
+      s_xhtml_1_0_end_p_tag     (xhtml, child);
+    }
+    else
+    /*------------------------------------------------------------------------*/
+    /* <PRE> (for TEST)                                                       */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
+      s_xhtml_1_0_start_pre_tag (xhtml, child);
+      s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
+      s_xhtml_1_0_end_pre_tag   (xhtml, child);
+    }
+    else
+    /*------------------------------------------------------------------------*/
     /* <UL> (for TEST)                                                        */
     /*------------------------------------------------------------------------*/
     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "ul") == 0) {
@@ -575,6 +597,10 @@ s_xhtml_1_0_node_exchange(xhtml_t* xhtml, Node* node, int indent)
             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
             ii++;
           }
+          else if (xhtml->pre_flag) {
+            one_byte[0] = textval[ii+0];
+            tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
+          }
           else if (textval[ii] != '\r' && textval[ii] != '\n') {
             one_byte[0] = textval[ii+0];
             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
@@ -1631,6 +1657,84 @@ s_xhtml_1_0_end_hr_tag(xhtml_t* xhtml, Node* child)
 }
 
 /**
+ * It is a handler who processes the PRE tag.
+ *
+ * @param xhtml  [i/o] The pointer to the XHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PRE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_xhtml_1_0_start_pre_tag(xhtml_t* xhtml, Node* node) 
+{
+  Doc*          doc = xhtml->doc;
+  request_rec*  r   = doc->r;
+
+  xhtml->pre_flag++;
+  xhtml->out = apr_pstrcat(r->pool, xhtml->out, "<pre>", NULL);
+
+  return xhtml->out;
+}
+
+/**
+ * It is a handler who processes the PRE tag.
+ *
+ * @param xhtml  [i/o] The pointer to the XHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PRE tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_xhtml_1_0_end_pre_tag(xhtml_t* xhtml, Node* child) 
+{
+  Doc*          doc = xhtml->doc;
+  request_rec*  r   = doc->r;
+
+  xhtml->out = apr_pstrcat(r->pool, xhtml->out, "</pre>", NULL);
+  xhtml->pre_flag--;
+
+  return xhtml->out;
+}
+
+/**
+ * It is a handler who processes the P tag.
+ *
+ * @param xhtml  [i/o] The pointer to the XHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The P tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_xhtml_1_0_start_p_tag(xhtml_t* xhtml, Node* node) 
+{
+  Doc*          doc = xhtml->doc;
+  request_rec*  r   = doc->r;
+
+  xhtml->out = apr_pstrcat(r->pool, xhtml->out, "<p>", NULL);
+
+  return xhtml->out;
+}
+
+/**
+ * It is a handler who processes the P tag.
+ *
+ * @param xhtml  [i/o] The pointer to the XHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The P tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_xhtml_1_0_end_p_tag(xhtml_t* xhtml, Node* child) 
+{
+  Doc*          doc = xhtml->doc;
+  request_rec*  r   = doc->r;
+
+  xhtml->out = apr_pstrcat(r->pool, xhtml->out, "</p>", NULL);
+
+  return xhtml->out;
+}
+
+/**
  * It is a handler who processes the UL tag.
  *
  * @param xhtml  [i/o] The pointer to the XHTML structure at the output