maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r1096107 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src: main/java/org/apache/maven/doxia/module/apt/AptParser.java test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
Date Sat, 23 Apr 2011 06:22:09 GMT
Author: ltheussl
Date: Sat Apr 23 06:22:09 2011
New Revision: 1096107

URL: http://svn.apache.org/viewvc?rev=1096107&view=rev
Log:
[DOXIA-425] AptParser: Trailing spaces breaks Snippet Macro

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java?rev=1096107&r1=1096106&r2=1096107&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java
Sat Apr 23 06:22:09 2011
@@ -2875,9 +2875,10 @@ public class AptParser
                 return;
             }
 
-            String s = text;
+            final int start = text.indexOf( '{' );
+            final int end = text.indexOf( '}' );
 
-            s = s.substring( 2, s.length() - 1 );
+            String s = text.substring( start + 1, end );
 
             s = escapeForMacro( s );
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java?rev=1096107&r1=1096106&r2=1096107&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/test/java/org/apache/maven/doxia/module/apt/AptParserTest.java
Sat Apr 23 06:22:09 2011
@@ -161,6 +161,32 @@ public class AptParserTest
         assertFalse( it.hasNext() );
     }
 
+
+    /** @throws Exception  */
+    public void testSnippetTrailingSpace()
+        throws Exception
+    {
+        // DOXIA-425
+        String text = "%{snippet|id=myid|file=pom.xml}  " + EOL;
+
+        SinkEventTestingSink sink = new SinkEventTestingSink();
+
+        parser.parse( text, sink );
+
+        Iterator<SinkEventElement> it = sink.getEventList().iterator();
+
+        assertEquals( "head", ( it.next() ).getName() );
+        assertEquals( "head_", ( it.next() ).getName() );
+        assertEquals( "body", ( it.next() ).getName() );
+
+        assertEquals( "verbatim", ( it.next() ).getName() );
+        assertEquals( "text", ( it.next() ).getName() );
+        assertEquals( "verbatim_", ( it.next() ).getName() );
+        assertEquals( "body_", ( it.next() ).getName() );
+
+        assertFalse( it.hasNext() );
+    }
+
     /** @throws Exception  */
     public void testTocMacro()
         throws Exception



Mime
View raw message