@@ -168,10 +168,10 @@ private static void ProcessInternalLink(InlineProcessor processor, LinkInline li
168
168
{
169
169
var ( url , anchor ) = SplitUrlAndAnchor ( link . Url ?? string . Empty ) ;
170
170
var includeFrom = GetIncludeFromPath ( url , context ) ;
171
-
171
+ var file = ResolveFile ( context , url ) ;
172
172
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 ) ;
175
175
}
176
176
177
177
private static ( string url , string ? anchor ) SplitUrlAndAnchor ( string fullUrl )
@@ -195,12 +195,11 @@ private static void ValidateInternalUrl(InlineProcessor processor, string url, s
195
195
processor . EmitError ( line , column , length , $ "`{ url } ` does not exist. resolved to `{ pathOnDisk } ") ;
196
196
}
197
197
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 )
199
199
{
200
200
if ( link . FirstChild != null && string . IsNullOrEmpty ( anchor ) )
201
201
return ;
202
202
203
- var file = ResolveFile ( context , url ) ;
204
203
var markdown = context . GetDocumentationFile ? . Invoke ( file ) as MarkdownFile ;
205
204
206
205
if ( markdown == null )
@@ -236,13 +235,19 @@ private static void ValidateAnchor(InlineProcessor processor, MarkdownFile markd
236
235
processor . EmitError ( line , column , length , $ "`{ anchor } ` does not exist in { markdown . FileName } .") ;
237
236
}
238
237
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 )
240
239
{
240
+ var urlPathPrefix = context . Build . UrlPathPrefix ?? string . Empty ;
241
241
if ( url . EndsWith ( ".md" ) )
242
242
url = Path . ChangeExtension ( url , ".html" ) ;
243
243
244
244
if ( url . StartsWith ( "/" ) && ! string . IsNullOrWhiteSpace ( urlPathPrefix ) )
245
245
url = $ "{ urlPathPrefix . TrimEnd ( '/' ) } { url } ";
246
+ else
247
+ {
248
+ var docsetDirectory = context . Configuration . SourceFile . Directory ;
249
+ url = file . FullName . Replace ( docsetDirectory ! . FullName , string . Empty ) ;
250
+ }
246
251
247
252
link . Url = ! string . IsNullOrEmpty ( anchor ) ? $ "{ url } #{ anchor } " : url ;
248
253
}
0 commit comments