Author: ltheussl
Date: Thu Jul 26 01:32:42 2007
New Revision: 559749

URL: http://svn.apache.org/viewvc?view=rev&rev=559749
Log:
ad DOXIA-47: add a legacy check to treat links to other html documents as 
external links. Note that this doesn't include other file formats, links to 
other documents should start with './' or '../' .

Modified:
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java?view=diff&rev=559749&r1=559748&r2=559749
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
 Thu Jul 26 01:32:42 2007
@@ -659,7 +659,7 @@
                 targ = " target=\"" + target + "\"";
             }
 
-            if ( StructureSink.isExternalLink( name ) )
+            if ( StructureSink.isExternalLink( name ) || isExternalHtml( name 
) )
             {
                 String clas = "";
                 if ( isExternalLink( name ) )
@@ -684,6 +684,18 @@
         return ( text.indexOf( "http:/" ) == 0 || text.indexOf( "https:/" ) == 0
             || text.indexOf( "ftp:/" ) == 0 || text.indexOf( "mailto:"; ) == 0
             || text.indexOf( "file:/" ) == 0 );
+
+    }
+
+    /* Legacy: treat links to other html documents as external links.
+     * Note that links to other file formats (images, pdf) will still be 
broken,
+     * links to other documents should always start with "./" or "../".
+     */
+    private boolean isExternalHtml( String href )
+    {
+        String text = href.toLowerCase();
+        return ( text.indexOf( ".html#" ) != -1 || text.indexOf( ".htm#" ) != 
-1
+            || text.endsWith( ".htm" ) || text.endsWith( ".html" ) );
 
     }
 


Reply via email to