maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vmas...@apache.org
Subject svn commit: r613132 - in /maven/sandbox/trunk/doxia/doxia-module-xwiki/src: main/java/org/apache/maven/doxia/module/xwiki/parser/ test/java/org/apache/maven/doxia/module/xwiki/parser/
Date Fri, 18 Jan 2008 11:32:29 GMT
Author: vmassol
Date: Fri Jan 18 03:32:27 2008
New Revision: 613132

URL: http://svn.apache.org/viewvc?rev=613132&view=rev
Log:
DOXIA-200: Add a Parser for XWiki

* Add support for parameter values with no name when in compatibility mode (e.g. {image:image.jpg})

Modified:
    maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/ChildBlocksBuilder.java
    maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/FigureBlockParser.java
    maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroBlock.java
    maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroParser.java
    maven/sandbox/trunk/doxia/doxia-module-xwiki/src/test/java/org/apache/maven/doxia/module/xwiki/parser/MacroParserTest.java

Modified: maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/ChildBlocksBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/ChildBlocksBuilder.java?rev=613132&r1=613131&r2=613132&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/ChildBlocksBuilder.java
(original)
+++ maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/ChildBlocksBuilder.java
Fri Jan 18 03:32:27 2008
@@ -147,7 +147,7 @@
                     break;
                 case '{':
                     text = addTextBlockIfNecessary( blocks, specialBlocks, text );
-                    i = macroParser.parse( input, i + 1, blocks );
+                    i = macroParser.parse( input, i + 1, blocks ) - 2;
                     break;
                 case '\\':
 

Modified: maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/FigureBlockParser.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/FigureBlockParser.java?rev=613132&r1=613131&r2=613132&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/FigureBlockParser.java
(original)
+++ maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/FigureBlockParser.java
Fri Jan 18 03:32:27 2008
@@ -25,6 +25,11 @@
 import org.apache.maven.doxia.parser.ParseException;
 import org.apache.maven.doxia.util.ByLineSource;
 
+/**
+ * This parser is left for performance reasons since it's very often that an image macro
is found on a line by itself.
+ * However note that macros (and thus this image macro) are also parsed by
+ * {@link org.apache.maven.doxia.module.xwiki.parser.MacroParser} when they're inside a paragraph.
+ */
 public class FigureBlockParser
     implements BlockParser
 {

Modified: maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroBlock.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroBlock.java?rev=613132&r1=613131&r2=613132&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroBlock.java
(original)
+++ maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroBlock.java
Fri Jan 18 03:32:27 2008
@@ -26,7 +26,8 @@
 
     public void before( Sink sink )
     {
-
+        // TODO: Make sure to generate existing events for some macros like for example for
the image macro we should
+        // send the same events as the one sent by the FigureBlock block.
     }
 
     public void after( Sink sink )

Modified: maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroParser.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroParser.java?rev=613132&r1=613131&r2=613132&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroParser.java
(original)
+++ maven/sandbox/trunk/doxia/doxia-module-xwiki/src/main/java/org/apache/maven/doxia/module/xwiki/parser/MacroParser.java
Fri Jan 18 03:32:27 2008
@@ -121,6 +121,20 @@
                     {
                         text.append( c );
                     }
+                    else if (isInCompatibilityMode && state == STATE_PARAM_NAME)
+                    {
+                        if ( charAt( input, i ) == '}' )
+                        {
+                            // In compatibility mode, allow a parameter without value
+                            i++;
+                            parameters.put( "default", text.toString() );
+                            state = STATE_END;
+                        }
+                        else
+                        {
+                            throw new ParseException( "Character '/' is not valid in parameter
names" );
+                        }
+                    }
                     else
                     {
                         throw new ParseException( "Invalid position for character '/' in
Macro" );

Modified: maven/sandbox/trunk/doxia/doxia-module-xwiki/src/test/java/org/apache/maven/doxia/module/xwiki/parser/MacroParserTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-module-xwiki/src/test/java/org/apache/maven/doxia/module/xwiki/parser/MacroParserTest.java?rev=613132&r1=613131&r2=613132&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-module-xwiki/src/test/java/org/apache/maven/doxia/module/xwiki/parser/MacroParserTest.java
(original)
+++ maven/sandbox/trunk/doxia/doxia-module-xwiki/src/test/java/org/apache/maven/doxia/module/xwiki/parser/MacroParserTest.java
Fri Jan 18 03:32:27 2008
@@ -136,4 +136,21 @@
         assertEquals( "", macroBlock.getContent() );
         assertEquals( 0, macroBlock.getParameters().size() );
     }
+
+    public void testParseOldStyleMacroWithDefaultParameterWithNoValue()
+        throws Exception
+    {
+        parser.setCompatibilityMode( true );
+        List blocks = new ArrayList();
+        String macro = "{macro:value/}";
+        int pos = parser.parse( macro + " ...", 1, blocks );
+
+        assertEquals( macro.length(), pos );
+        assertEquals( 1, blocks.size() );
+        MacroBlock macroBlock = (MacroBlock) blocks.get( 0 );
+        assertEquals( "macro", macroBlock.getName() );
+        assertEquals( "", macroBlock.getContent() );
+        assertEquals( 1, macroBlock.getParameters().size() );
+        assertEquals( "value", macroBlock.getParameters().get( "default" ) );
+    }
 }



Mime
View raw message