@@ -168,10 +168,10 @@ private static void ProcessInternalLink(InlineProcessor processor, LinkInline li
168168 {
169169 var ( url , anchor ) = SplitUrlAndAnchor ( link . Url ?? string . Empty ) ;
170170 var includeFrom = GetIncludeFromPath ( url , context ) ;
171-
171+ var file = ResolveFile ( context , url ) ;
172172 ValidateInternalUrl ( processor , url , includeFrom , line , column , length , context ) ;
173- ProcessLinkText ( processor , link , context , url , anchor , line , column , length ) ;
174- UpdateLinkUrl ( link , url , anchor , context . Build . UrlPathPrefix ?? string . Empty ) ;
173+ ProcessLinkText ( processor , link , context , url , anchor , line , column , length , file ) ;
174+ UpdateLinkUrl ( link , url , context , anchor , file ) ;
175175 }
176176
177177 private static ( string url , string ? anchor ) SplitUrlAndAnchor ( string fullUrl )
@@ -195,12 +195,11 @@ private static void ValidateInternalUrl(InlineProcessor processor, string url, s
195195 processor . EmitError ( line , column , length , $ "`{ url } ` does not exist. resolved to `{ pathOnDisk } ") ;
196196 }
197197
198- private static void ProcessLinkText ( InlineProcessor processor , LinkInline link , ParserContext context , string url , string ? anchor , int line , int column , int length )
198+ private static void ProcessLinkText ( InlineProcessor processor , LinkInline link , ParserContext context , string url , string ? anchor , int line , int column , int length , IFileInfo file )
199199 {
200200 if ( link . FirstChild != null && string . IsNullOrEmpty ( anchor ) )
201201 return ;
202202
203- var file = ResolveFile ( context , url ) ;
204203 var markdown = context . GetDocumentationFile ? . Invoke ( file ) as MarkdownFile ;
205204
206205 if ( markdown == null )
@@ -236,13 +235,19 @@ private static void ValidateAnchor(InlineProcessor processor, MarkdownFile markd
236235 processor . EmitError ( line , column , length , $ "`{ anchor } ` does not exist in { markdown . FileName } .") ;
237236 }
238237
239- private static void UpdateLinkUrl ( LinkInline link , string url , string ? anchor , string urlPathPrefix )
238+ private static void UpdateLinkUrl ( LinkInline link , string url , ParserContext context , string ? anchor , IFileInfo file )
240239 {
240+ var urlPathPrefix = context . Build . UrlPathPrefix ?? string . Empty ;
241241 if ( url . EndsWith ( ".md" ) )
242242 url = Path . ChangeExtension ( url , ".html" ) ;
243243
244244 if ( url . StartsWith ( "/" ) && ! string . IsNullOrWhiteSpace ( urlPathPrefix ) )
245245 url = $ "{ urlPathPrefix . TrimEnd ( '/' ) } { url } ";
246+ else
247+ {
248+ var docsetDirectory = context . Configuration . SourceFile . Directory ;
249+ url = file . FullName . Replace ( docsetDirectory ! . FullName , string . Empty ) ;
250+ }
246251
247252 link . Url = ! string . IsNullOrEmpty ( anchor ) ? $ "{ url } #{ anchor } " : url ;
248253 }
0 commit comments