OSDN Git Service

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

include/chxj_chtml30.h
src/chxj_chtml30.c

index c62681c..e914899 100644 (file)
@@ -26,6 +26,7 @@ typedef struct _chtml30_t {
     Doc*               doc;
     char*              out;
     int                out_len;
+    int                pre_flag;
 
     device_table_t*    spec;
     mod_chxj_config*   conf;
index 672c2d4..e1a1f55 100644 (file)
@@ -26,6 +26,10 @@ static char* s_chtml30_start_html_tag   (chtml30_t* chtml, Node* child);
 static char* s_chtml30_end_html_tag     (chtml30_t* chtml, Node* child);
 static char* s_chtml30_start_meta_tag   (chtml30_t* chtml, Node* node);
 static char* s_chtml30_end_meta_tag     (chtml30_t* chtml, Node* node);
+static char* s_chtml30_start_p_tag      (chtml30_t* chtml, Node* node);
+static char* s_chtml30_end_p_tag        (chtml30_t* chtml, Node* node);
+static char* s_chtml30_start_pre_tag    (chtml30_t* chtml, Node* node);
+static char* s_chtml30_end_pre_tag      (chtml30_t* chtml, Node* node);
 static char* s_chtml30_start_h1_tag     (chtml30_t* chtml, Node* node);
 static char* s_chtml30_end_h1_tag       (chtml30_t* chtml, Node* node);
 static char* s_chtml30_start_h2_tag     (chtml30_t* chtml, Node* node);
@@ -204,8 +208,26 @@ s_chtml30_node_exchange(chtml30_t* chtml30, Node* node, int indent)
        child = qs_get_next_node(doc,child)) {
     char* name = qs_get_node_name(doc,child);
 
-
+    /*------------------------------------------------------------------------*/
+    /* <P> (for TEST)                                                         */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "p") == 0) {
+      s_chtml30_start_p_tag   (chtml30, child);
+      s_chtml30_node_exchange (chtml30, child, indent+1);
+      s_chtml30_end_p_tag     (chtml30, child);
+    }
+    else
+    /*------------------------------------------------------------------------*/
+    /* <PRE> (for TEST)                                                       */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
+      s_chtml30_start_pre_tag (chtml30, child);
+      s_chtml30_node_exchange (chtml30, child, indent+1);
+      s_chtml30_end_pre_tag   (chtml30, child);
+    }
+    else
     if (*name == 's' || *name == 'S') {
+
       /*----------------------------------------------------------------------*/
       /* <STYLE> (for TEST)                                                   */
       /*----------------------------------------------------------------------*/
@@ -568,6 +590,10 @@ s_chtml30_node_exchange(chtml30_t* chtml30, Node* node, int indent)
             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
             ii++;
           }
+          else if (chtml30->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);
@@ -1966,6 +1992,84 @@ s_chtml30_end_ul_tag(chtml30_t* chtml30, Node* child)
 }
 
 /**
+ * It is a handler who processes the PRE tag.
+ *
+ * @param chtml30  [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_chtml30_start_pre_tag(chtml30_t* chtml30, Node* node) 
+{
+  Doc*          doc = chtml30->doc;
+  request_rec*  r   = doc->r;
+
+  chtml30->pre_flag++;
+  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<pre>", NULL);
+
+  return chtml30->out;
+}
+
+/**
+ * It is a handler who processes the PRE tag.
+ *
+ * @param chtml30  [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_chtml30_end_pre_tag(chtml30_t* chtml30, Node* child) 
+{
+  Doc*          doc = chtml30->doc;
+  request_rec*  r   = doc->r;
+
+  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</pre>", NULL);
+  chtml30->pre_flag--;
+
+  return chtml30->out;
+}
+
+/**
+ * It is a handler who processes the P tag.
+ *
+ * @param chtml30  [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_chtml30_start_p_tag(chtml30_t* chtml30, Node* node) 
+{
+  Doc*          doc = chtml30->doc;
+  request_rec*  r   = doc->r;
+
+  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "<p>", NULL);
+
+  return chtml30->out;
+}
+
+/**
+ * It is a handler who processes the P tag.
+ *
+ * @param chtml30  [i/o] The pointer to the CHTML 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_chtml30_end_p_tag(chtml30_t* chtml30, Node* child) 
+{
+  Doc*          doc = chtml30->doc;
+  request_rec*  r   = doc->r;
+
+  chtml30->out = apr_pstrcat(r->pool, chtml30->out, "</p>", NULL);
+
+  return chtml30->out;
+}
+
+/**
  * It is a handler who processes the OL tag.
  *
  * @param chtml30  [i/o] The pointer to the CHTML structure at the output