maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r392169 - /maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Date Fri, 07 Apr 2006 03:19:47 GMT
Author: brett
Date: Thu Apr  6 20:19:44 2006
New Revision: 392169

URL: http://svn.apache.org/viewcvs?rev=392169&view=rev
Log:
[DOXIA-52] improvements to the FML parser
Submitted by: Vincent Siveton

Modified:
    maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java

Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java?rev=392169&r1=392168&r2=392169&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
(original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Thu Apr  6 20:19:44 2006
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.doxia.module.HtmlTools;
 import org.apache.maven.doxia.module.fml.model.Faq;
 import org.apache.maven.doxia.module.fml.model.Faqs;
 import org.apache.maven.doxia.module.fml.model.Part;
@@ -157,7 +158,7 @@
 
                         buffer.append( "\"" );
 
-                        buffer.append( parser.getAttributeValue( i ) );
+                        buffer.append( HtmlTools.escapeHTML( parser.getAttributeValue( i
) ) );
 
                         buffer.append( "\"" );
                     }
@@ -201,6 +202,11 @@
                 }
                 else if ( inQuestion || inAnswer )
                 {
+                    if ( buffer.charAt( buffer.length() - 1 ) == ' ' )
+                    {
+                        buffer.deleteCharAt( buffer.length() - 1 );
+                    }
+
                     buffer.append( "</" );
 
                     buffer.append( parser.getName() );
@@ -208,6 +214,15 @@
                     buffer.append( ">" );
                 }
             }
+            else if ( eventType == XmlPullParser.CDSECT )
+            {
+                if ( buffer != null && parser.getText() != null )
+                {
+                    buffer.append( "<![CDATA[" );
+                    buffer.append( parser.getText() );
+                    buffer.append( "]]>" );
+                }
+            }
             else if ( eventType == XmlPullParser.TEXT )
             {
                 if ( buffer != null && parser.getText() != null )
@@ -216,7 +231,7 @@
                 }
             }
 
-            eventType = parser.next();
+            eventType = parser.nextToken();
         }
 
         return faqs;
@@ -231,11 +246,11 @@
         sink.head_();
 
         sink.body();
-        sink.anchor( "top" );
-        sink.anchor_();
         sink.section1();
         sink.sectionTitle1();
+        sink.anchor( "top" );
         sink.text( faqs.getTitle() );
+        sink.anchor_();
         sink.sectionTitle1_();
 
         // Write summary
@@ -269,9 +284,9 @@
         for ( Iterator partIterator = faqs.getParts().iterator(); partIterator.hasNext();
)
         {
             Part part = (Part) partIterator.next();
-            sink.section1();
             if ( StringUtils.isNotEmpty( part.getTitle() ) )
             {
+                sink.section1();
                 sink.sectionTitle1();
                 sink.text( part.getTitle() );
                 sink.sectionTitle1_();
@@ -303,7 +318,11 @@
                 sink.definition_();
             }
             sink.definitionList_();
-            sink.section1_();
+
+            if ( StringUtils.isNotEmpty( part.getTitle() ) )
+            {
+                sink.section1_();
+            }
         }
 
         sink.body_();
@@ -330,7 +349,7 @@
 
     private void writeTopLink( Sink sink )
     {
-        sink.rawText( "<table border=0>" );
+        sink.rawText( "<table border=\"0\">" );
         sink.rawText( "<tr><td align=\"right\">" );
 
         sink.link( "#top" );
@@ -339,6 +358,5 @@
 
         sink.rawText( "</td></tr>" );
         sink.rawText( "</table>" );
-
     }
 }



Mime
View raw message