You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2009/04/03 10:38:09 UTC

svn commit: r761569 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src: main/java/org/apache/maven/doxia/module/confluence/ main/java/org/apache/maven/doxia/module/confluence/parser/ test/java/org/apache/maven/doxia/module/confluen...

Author: ltheussl
Date: Fri Apr  3 08:38:09 2009
New Revision: 761569

URL: http://svn.apache.org/viewvc?rev=761569&view=rev
Log:
[DOXIA-302] {code} tag is not interpreted correctly if there is no empty line before it
Submitted by: Kornel

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlock.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlockParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/code.confluence

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java?rev=761569&r1=761568&r2=761569&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java Fri Apr  3 08:38:09 2009
@@ -67,7 +67,8 @@
         BlockParser listParser = new ListBlockParser();
         BlockParser tableParser = new TableBlockParser();
 
-        BlockParser[] subparsers = new BlockParser[] { headingParser, figureParser, listParser, tableParser };
+        BlockParser[] subparsers =
+                new BlockParser[] { headingParser, figureParser, listParser, tableParser, verbatimParser };
         BlockParser paragraphParser = new ParagraphBlockParser( subparsers );
 
         parsers =

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlock.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlock.java?rev=761569&r1=761568&r2=761569&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlock.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlock.java Fri Apr  3 08:38:09 2009
@@ -30,21 +30,35 @@
 class ParagraphBlock
     extends AbstractFatherBlock
 {
+
+    private boolean generateParagraphTags = true;
+
     ParagraphBlock( List blocks )
-        throws IllegalArgumentException
     {
         super( blocks );
     }
 
+    ParagraphBlock( List blocks, boolean generateParagraphTags )
+    {
+        super( blocks );
+        this.generateParagraphTags = generateParagraphTags;
+    }
+
     /** {@inheritDoc} */
     public  void before(  Sink sink )
     {
-        sink.paragraph();
+        if ( this.generateParagraphTags )
+        {
+            sink.paragraph();
+        }
     }
 
     /** {@inheritDoc} */
     public  void after(  Sink sink )
     {
-        sink.paragraph_();
+        if ( this.generateParagraphTags )
+        {
+            sink.paragraph_();
+        }
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlockParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlockParser.java?rev=761569&r1=761568&r2=761569&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlockParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ParagraphBlockParser.java Fri Apr  3 08:38:09 2009
@@ -35,7 +35,7 @@
     /**
      * <p>Constructor for ParagraphBlockParser.</p>
      *
-     * @param parsers
+     * @param parsers the parsers.
      */
     public ParagraphBlockParser( BlockParser[] parsers )
     {
@@ -49,6 +49,30 @@
         return true;
     }
 
+    /**
+     * Visit the Block.
+     *
+     * @param line the line to visit.
+     * @param source the source.
+     * @param generateParagraphTags whether to generate a paragraph.
+     * @return the visited Block.
+     *
+     * @throws org.apache.maven.doxia.parser.ParseException if any
+     */
+    public Block visit(String line, ByLineSource source, boolean generateParagraphTags)
+            throws ParseException
+    {
+        if ( generateParagraphTags )
+        {
+            return this.visit( line, source );
+        }
+        else
+        {
+            ChildBlocksBuilder builder = new ChildBlocksBuilder( appendUntilEmptyLine( line, source ) );
+            return new ParagraphBlock( builder.getBlocks(), generateParagraphTags );
+        }
+    }
+
     /** {@inheritDoc} */
     public Block visit( String line, ByLineSource source )
         throws ParseException

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java?rev=761569&r1=761568&r2=761569&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java Fri Apr  3 08:38:09 2009
@@ -202,10 +202,10 @@
         String result = locateAndParseTestSourceFile( "code" );
 
         assertContainsLines( result, "begin:verbatim, boxed: true\ntext: public class Cat {" );
-        // 3 paragraphs in the input...
-        assertEquals( 4, result.split( "end:paragraph\n" ).length );
-        // 1 verbatim in the input...
-        assertEquals( 2, result.split( "end:verbatim\n" ).length );
+        // 5 paragraphs in the input...
+        assertEquals( 5, result.split( "end:paragraph\n" ).length );
+        // 3 verbatim in the input...
+        assertEquals( 3, result.split( "end:verbatim\n" ).length );
     }
 
     /** @throws Exception */

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/code.confluence
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/code.confluence?rev=761569&r1=761568&r2=761569&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/code.confluence (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/resources/code.confluence Fri Apr  3 08:38:09 2009
@@ -18,4 +18,4 @@
 	}
 }
 {code}
-in the same paragraph (this didn't work until DOXIA-181).
\ No newline at end of file
+in the same paragraph (this didn't work until DOXIA-181). See also DOXIA-302.
\ No newline at end of file