maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r772527 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src: main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java
Date Thu, 07 May 2009 07:14:52 GMT
Author: ltheussl
Date: Thu May  7 07:14:46 2009
New Revision: 772527

URL: http://svn.apache.org/viewvc?rev=772527&view=rev
Log:
[DOXIA-298] Problem with relative links
Submitted by: Kornel

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceParserTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.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/ChildBlocksBuilder.java?rev=772527&r1=772526&r2=772527&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/ChildBlocksBuilder.java
Thu May  7 07:14:46 2009
@@ -109,11 +109,26 @@
                 case ']':
                     if ( insideLink )
                     {
+                    	boolean addHTMLSuffix = false;
                         String link = text.toString();
 
+                        if (!link.endsWith(".html"))
+                        	if (!link.contains("http"))
+                        			addHTMLSuffix = true;
                         if ( link.indexOf( "|" ) > 0 )
                         {
                             String[] pieces = StringUtils.split( text.toString(), "|" );
+                            if (addHTMLSuffix) {
+                                if (!pieces[1].contains("#"))
+                                    pieces[1] = pieces[1].concat(".html");
+                                else {
+                                    if (!pieces[1].startsWith("#"))
+                                    {
+                                        String[] temp = pieces[1].split("#");
+                                        pieces[1] = temp[0] + ".html#" + temp[1];
+                                    }
+                                }
+                            }
 
                             blocks.add( new LinkBlock( pieces[1], pieces[0] ) );
                         }
@@ -126,6 +141,17 @@
                                 value = link.substring( 1 );
                             }
 
+                            if (addHTMLSuffix) {
+                                if (!link.contains("#"))
+                                    link = link.concat(".html");
+                                else {
+                                    if (!link.startsWith("#"))
+                                    {
+                                        String[] temp = link.split("#");
+                                        link = temp[0] + ".html#" + temp[1];
+                                    }
+                                }
+                            }
                             blocks.add( new LinkBlock( link, value ) );
                         }
 

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=772527&r1=772526&r2=772527&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
Thu May  7 07:14:46 2009
@@ -240,10 +240,10 @@
     {
         String result = locateAndParseTestSourceFile( "link" );
 
-        assertContainsLines( result, "begin:link, name: middle\ntext: middle\nend:link" );
-        assertContainsLines( result, "begin:link, name: end\ntext: end\nend:link" );
-        assertContainsLines( result, "begin:link, name: link\ntext: alias\nend:link" );
-        assertContainsLines( result, "begin:link, name: link#anchor\ntext: link#anchor\nend:link"
);
+        assertContainsLines( result, "begin:link, name: middle.html\ntext: middle\nend:link"
);
+        assertContainsLines( result, "begin:link, name: end.html\ntext: end\nend:link" );
+        assertContainsLines( result, "begin:link, name: link.html\ntext: alias\nend:link"
);
+        assertContainsLines( result, "begin:link, name: link.html#anchor\ntext: link#anchor\nend:link"
);
         assertContainsLines( result, "begin:link, name: #simple\ntext: simple\nend:link"
);
         // 3 paragraphs in the input...
         assertEquals( 4, result.split( "end:paragraph\n" ).length );



Mime
View raw message