Index: src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java =================================================================== --- src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java (revision 589423) +++ src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java (working copy) @@ -122,7 +122,7 @@ // System.out.println( "line = " + line ); - if ( input.charAt( i + 1 ) == '}' ) + if ( input.length()>i+1 && input.charAt( i + 1 ) == '}' ) { i++; TextBlock tb = new TextBlock( text.toString() ); Index: src/main/java/org/apache/maven/doxia/module/confluence/parser/VerbatimBlockParser.java =================================================================== --- src/main/java/org/apache/maven/doxia/module/confluence/parser/VerbatimBlockParser.java (revision 589423) +++ src/main/java/org/apache/maven/doxia/module/confluence/parser/VerbatimBlockParser.java (working copy) @@ -33,7 +33,7 @@ public boolean accept( String line, ByLineSource source ) { - if ( line.startsWith( "{code}" ) || line.startsWith( "{noformat}" ) ) + if ( line.startsWith( "{code" ) || line.startsWith( "{noformat}" ) ) { return true; } Index: src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java =================================================================== --- src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java (revision 589423) +++ src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java (working copy) @@ -146,7 +146,8 @@ { String result = locateAndParseTestSourceFile( "nested-list" ); - assertContainsLines( "Nested list not found", result, "begin:listItem\ntext: A top level list item\nbegin:list" ); + assertContainsLines( "Nested list not found", result, + "begin:listItem\ntext: A top level list item\nbegin:list" ); // two lists in the input... assertEquals( 3, result.split( "end:list\n" ).length ); // ...and 4 list items @@ -158,7 +159,7 @@ throws Exception { String result = locateAndParseTestSourceFile( "simple-list" ); - + assertContainsLines( result, "begin:bold\ntext: bold\n" ); assertContainsLines( result, "begin:italic\ntext: italic\n" ); assertContainsLines( result, "begin:monospaced\ntext: monospaced\n" ); @@ -176,11 +177,11 @@ throws Exception { String result = locateAndParseTestSourceFile( "anchor" ); - + assertContainsLines( result, "begin:paragraph\nbegin:anchor, name: start\nend:anchor" ); assertContainsLines( result, "begin:anchor, name: middle\nend:anchor" ); assertContainsLines( result, "begin:paragraph\ntext: Simple paragraph\nbegin:anchor, name: end\nend:anchor" ); - // 3 anchors in the input... + // 3 anchors in the input... assertEquals( 4, result.split( "end:anchor\n" ).length ); } @@ -189,10 +190,23 @@ throws Exception { String result = locateAndParseTestSourceFile( "unknown-macro" ); - + assertContainsLines( result, "begin:paragraph\ntext: {unknown:start}" ); - } + } + /** @throws Exception */ + public void testCodeMacro() + throws Exception + { + 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 ); + } + private void assertContainsLines( String message, String result, String lines ) { lines = StringUtils.replace( lines, "\n", EOL ); Index: src/test/resources/anchor.confluence =================================================================== --- src/test/resources/anchor.confluence (revision 589423) +++ src/test/resources/anchor.confluence (working copy) @@ -2,6 +2,6 @@ {anchor:start}Simple paragraph. -Simple paragraph{anchor:end}. +Simple paragraph{anchor:end} Simple {anchor:middle} paragraph. Index: src/test/resources/code.confluence =================================================================== --- src/test/resources/code.confluence (revision 0) +++ src/test/resources/code.confluence (revision 0) @@ -0,0 +1,21 @@ +Simple paragraph. + +{code:title=Cat.java} +public class Cat { + public void sitOn(Mat mat) { + // ... code here + } +} +{code} + +Another paragraph (the title of the code block is ignored). + +Simple paragraph with embedded code +{code} +public class Cat { + public void sitOn(Mat mat) { + // ... code here + } +} +{code} +in the same paragraph (this doesn't work right now DOXIA-181). \ No newline at end of file