protected URL transformURL ( URL link , ReferenceContext references ) { if ( URISchemeType . FILE . isURL ( link ) ) { File filename = FileSystem . convertURLToFile ( link ) ; if ( Strings . isEmpty ( filename . getName ( ) ) ) { // This is a link to the local document. final String anchor = transformURLAnchor ( filename , link . getRef ( ) , references ) ; final URL url = FileSystemAddons . convertFileToURL ( filename , true ) ; if ( ! Strings . isEmpty ( anchor ) ) { try { return new URL ( url . toExternalForm ( ) + "#" + anchor ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { // } } return url ; } // This is a link to another document. final String extension = FileSystem . extension ( filename ) ; if ( isMarkdownFileExtension ( extension ) ) { filename = FileSystem . replaceExtension ( filename , ".html" ) ; //$NON-NLS-1$ final String anchor = transformURLAnchor ( filename , link . getRef ( ) , null ) ; final URL url = FileSystemAddons . convertFileToURL ( filename , true ) ; if ( ! Strings . isEmpty ( anchor ) ) { try { return new URL ( url . toExternalForm ( ) + "#" + anchor ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { // } } return url ; } } return null ; }
Transform an URL from Markdown format to HTML format .