Index: src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java =================================================================== --- src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java (revision 596402) +++ src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java (working copy) @@ -26,6 +26,7 @@ import org.apache.maven.doxia.module.confluence.parser.Block; import org.apache.maven.doxia.module.confluence.parser.BlockParser; +import org.apache.maven.doxia.module.confluence.parser.DefinitionListBlockParser; import org.apache.maven.doxia.module.confluence.parser.FigureBlockParser; import org.apache.maven.doxia.module.confluence.parser.HorizontalRuleBlockParser; import org.apache.maven.doxia.module.confluence.parser.ParagraphBlockParser; @@ -58,6 +59,7 @@ BlockParser headingParser = new SectionBlockParser(); BlockParser figureParser = new FigureBlockParser(); BlockParser verbatimParser = new VerbatimBlockParser(); + BlockParser definitionParser = new DefinitionListBlockParser(); BlockParser horizontalRuleParser = new HorizontalRuleBlockParser(); BlockParser listParser = new ListBlockParser(); BlockParser tableParser = new TableBlockParser(); @@ -66,7 +68,7 @@ BlockParser paragraphParser = new ParagraphBlockParser( subparsers ); parsers = - new BlockParser[] { headingParser, figureParser, verbatimParser, horizontalRuleParser, listParser, + new BlockParser[] { headingParser, figureParser, verbatimParser, definitionParser, horizontalRuleParser, listParser, tableParser, paragraphParser }; } Index: src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlock.java =================================================================== --- src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlock.java (revision 0) +++ src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlock.java (revision 0) @@ -0,0 +1,42 @@ +package org.apache.maven.doxia.module.confluence.parser; + +import java.util.Iterator; +import java.util.List; + +import org.apache.maven.doxia.sink.Sink; +import org.codehaus.plexus.util.StringUtils; + +public class DefinitionListBlock + implements Block +{ + + private String title; + + private List text; + + public DefinitionListBlock( String title, String text ) + { + this.title = title; + this.text = new ChildBlocksBuilder(text).getBlocks(); + } + + public void traverse( Sink sink ) + { + sink.definitionList(); + if ( !StringUtils.isEmpty( title ) ) + { + sink.definedTerm(); + sink.text( title ); + sink.definedTerm_(); + } + sink.definition(); + for ( Iterator iterator = text.iterator(); iterator.hasNext(); ) + { + Block block = (Block) iterator.next(); + block.traverse( sink ); + } + sink.definition_(); + sink.definitionList_(); + } + +} Index: src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlockParser.java =================================================================== --- src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlockParser.java (revision 0) +++ src/main/java/org/apache/maven/doxia/module/confluence/parser/DefinitionListBlockParser.java (revision 0) @@ -0,0 +1,82 @@ +package org.apache.maven.doxia.module.confluence.parser; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.doxia.parser.ParseException; +import org.apache.maven.doxia.util.ByLineSource; + +/** + * @author Dave Syer + * @version $Id: VerbatimBlockParser.java 589828 2007-10-29 19:53:59Z ltheussl $ + */ +public class DefinitionListBlockParser + implements BlockParser +{ + static String LS = System.getProperty( "line.separator" ); + + public boolean accept( String line, ByLineSource source ) + { + if ( line.startsWith( "{note" ) || line.startsWith( "{tip" ) || line.startsWith( "{info" ) || line.startsWith( "{quote" )) + { + return true; + } + + return false; + } + + public Block visit( String line, ByLineSource source ) + throws ParseException + { + StringBuffer text = new StringBuffer(); + StringBuffer title = new StringBuffer(); + + int index = line.indexOf( "title=" ); + if (index>=0) { + line = line.substring( index+6 ); + while ( !(line.indexOf( "}" )>=0) && line != null ) { + append( title, line ); + line = source.getNextLine(); + } + if (line!=null) { + append( title, line.substring( 0, line.indexOf( "}" ) ) ); + } + } + + while ( ( line = source.getNextLine() ) != null ) + { + if ( line.startsWith( "{note" ) || line.startsWith( "{tip" ) || line.startsWith( "{info" ) || line.startsWith( "{quote" )) + { + break; + } + + append( text, line ); + } + + return new DefinitionListBlock( title.toString(), text.toString() ); + } + + private void append( StringBuffer title, String line ) + { + if (title.length()>0) { + title.append( " " ); + } + title.append( line.trim() ); + } +} Index: src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java =================================================================== --- src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java (revision 596402) +++ src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java (working copy) @@ -313,6 +313,27 @@ assertEquals( 3, result.split( "end:monospaced\n" ).length ); } + /** @throws Exception */ + public void testNoteInfoTipQuote() + throws Exception + { + String result = locateAndParseTestSourceFile( "note-tip-info" ); + + assertContainsLines( result, "begin:definedTerm\ntext: Be Careful\nend:definedTerm\n" ); + assertContainsLines( result, "begin:definition\ntext: The body of the note here..\nend:definition" ); + assertContainsLines( result, "begin:definedTerm\ntext: Guess What?\nend:definedTerm\n" ); + assertContainsLines( result, "begin:definition\ntext: The body of the tip here..\nend:definition" ); + assertContainsLines( result, "begin:definedTerm\ntext: Some Info\nend:definedTerm\n" ); + assertContainsLines( result, "begin:definition\ntext: The body of the info here..\nend:definition" ); + assertContainsLines( result, "begin:definedTerm\ntext: Simon Says\nend:definedTerm\n" ); + assertContainsLines( result, "begin:definition\ntext: The body of the \nbegin:bold\ntext: quote\nend:bold" ); + + // 5 paragraphs in the input... + assertEquals( 6, result.split( "end:paragraph\n" ).length ); + // 4 dinitionList in the input... + assertEquals( 5, result.split( "end:definitionList\n" ).length ); + } + private void assertContainsLines( String message, String result, String lines ) { lines = StringUtils.replace( lines, "\n", EOL ); Index: src/test/resources/code.confluence =================================================================== --- src/test/resources/code.confluence (revision 596402) +++ src/test/resources/code.confluence (working copy) @@ -18,4 +18,4 @@ } } {code} -in the same paragraph (this doesn't work right now DOXIA-181). \ No newline at end of file +in the same paragraph (this didn't work until DOXIA-181). \ No newline at end of file Index: src/test/resources/note-tip-info.confluence =================================================================== --- src/test/resources/note-tip-info.confluence (revision 0) +++ src/test/resources/note-tip-info.confluence (revision 0) @@ -0,0 +1,27 @@ +Simple paragraph. + +{note:title=Be Careful} +The body of the note here.. +{note} + +Tip + +{tip:title=Guess What?} +The body of the tip here.. +{tip} + +Info + +{info:title=Some +Info} +The body of the info here.. +{info} + +Quote + +{quote:title=Simon Says} +The body of the *quote* here.. +{quote} + +(In all cases there is no way to reverse the Doxia output +back to confluence because they are all rendered as a defitionList.) \ No newline at end of file