@@ -349,50 +349,52 @@ public void CorrectLinksAndImages(MarkdownObject document, FileInfo file, Markdo
349
349
// and relative links to markdown pages
350
350
foreach ( var link in document . Descendants ( ) . OfType < LinkInline > ( ) )
351
351
{
352
- if ( ! link . Url . StartsWith ( "http" ) )
352
+ if ( link . Url != null )
353
353
{
354
+ if ( ! link . Url . StartsWith ( "http" ) )
355
+ {
354
356
355
- string absPath = null ;
357
+ string absPath = null ;
356
358
357
- if ( link . Url . StartsWith ( "/" ) )
358
- {
359
- absPath = Path . GetFullPath ( _path + link . Url ) ;
360
- }
361
- else
362
- {
363
- absPath = Path . GetFullPath ( file . Directory . FullName + "/" + link . Url ) ;
364
- }
365
- //the file is a markdown file, create a link to it
366
- var isMarkdown = false ;
367
- var fileInfo = new FileInfo ( absPath ) ;
368
- if ( fileInfo . Exists && fileInfo . Extension . Equals ( ".md" , StringComparison . InvariantCultureIgnoreCase ) )
369
- {
370
- isMarkdown = true ;
371
- }
372
- else if ( fileInfo . Exists )
373
- {
374
- link . Url = $ "file:///{ absPath } ";
375
- }
359
+ if ( link . Url . StartsWith ( "/" ) )
360
+ {
361
+ absPath = Path . GetFullPath ( _path + link . Url ) ;
362
+ }
363
+ else
364
+ {
365
+ absPath = Path . GetFullPath ( file . Directory . FullName + "/" + link . Url ) ;
366
+ }
367
+ //the file is a markdown file, create a link to it
368
+ var isMarkdown = false ;
369
+ var fileInfo = new FileInfo ( absPath ) ;
370
+ if ( fileInfo . Exists && fileInfo . Extension . Equals ( ".md" , StringComparison . InvariantCultureIgnoreCase ) )
371
+ {
372
+ isMarkdown = true ;
373
+ }
374
+ else if ( fileInfo . Exists )
375
+ {
376
+ link . Url = $ "file:///{ absPath } ";
377
+ }
376
378
377
- fileInfo = new FileInfo ( $ "{ absPath } .md") ;
378
- if ( fileInfo . Exists && fileInfo . Extension . Equals ( ".md" , StringComparison . InvariantCultureIgnoreCase ) )
379
- {
380
- isMarkdown = true ;
381
- }
379
+ fileInfo = new FileInfo ( $ "{ absPath } .md") ;
380
+ if ( fileInfo . Exists && fileInfo . Extension . Equals ( ".md" , StringComparison . InvariantCultureIgnoreCase ) )
381
+ {
382
+ isMarkdown = true ;
383
+ }
382
384
383
- //only markdown files get a pdf internal link
384
- if ( isMarkdown )
385
- {
386
- var relPath = mf . RelativePath + "\\ " + link . Url ;
387
- relPath = relPath . Replace ( "/" , "\\ " ) ;
388
- relPath = relPath . Replace ( "\\ " , "" ) ;
389
- relPath = relPath . Replace ( ".md" , "" ) ;
390
- relPath = relPath . ToLower ( ) ;
391
- Log ( $ "\t Markdown link: { relPath } ") ;
392
- link . Url = $ "#{ relPath } ";
385
+ //only markdown files get a pdf internal link
386
+ if ( isMarkdown )
387
+ {
388
+ var relPath = mf . RelativePath + "\\ " + link . Url ;
389
+ relPath = relPath . Replace ( "/" , "\\ " ) ;
390
+ relPath = relPath . Replace ( "\\ " , "" ) ;
391
+ relPath = relPath . Replace ( ".md" , "" ) ;
392
+ relPath = relPath . ToLower ( ) ;
393
+ Log ( $ "\t Markdown link: { relPath } ") ;
394
+ link . Url = $ "#{ relPath } ";
395
+ }
393
396
}
394
397
}
395
-
396
398
CorrectLinksAndImages ( link , file , mf ) ;
397
399
}
398
400
}
0 commit comments