Skip to content

Commit

Permalink
null pointer for empty content files mentioned in [TOC]
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMelcher committed Jan 24, 2022
1 parent e62b13b commit 1ae131e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"--verbose",
//"-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\DeepLink",
"-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki",
// "--attachments-path=..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki\\.attachments\\",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Code",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Azure-Platform-Design",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\1k",
// "-s..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Test-Emoticon\\emoji.md",
// "--attachments-path=..\\AzureDevOps.WikiPDFExport.Test\\Tests\\AzureDevOps.WikiPDFExport.wiki\\.attachments\\",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Code",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Azure-Platform-Design",
// "-p..\\AzureDevOps.WikiPDFExport.Test\\Tests\\1k",
// "-s..\\AzureDevOps.WikiPDFExport.Test\\Tests\\Test-Emoticon\\emoji.md",
"--heading",
"--breakPage",
// "-m",
Expand Down
8 changes: 7 additions & 1 deletion AzureDevOps.WikiPDFExport/WikiPDFExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ private string ConvertMarkdownToHTML(List<MarkdownFile> files)
pipelineBuilder.Extensions.RemoveAll(x => x is Markdig.Extensions.AutoIdentifiers.AutoIdentifierExtension);
//handled by katex
pipelineBuilder.Extensions.RemoveAll(x => x is Markdig.Extensions.Mathematics.MathExtension);

//todo: is this needed? it will stop support of resizing images:
//this interferes with katex parsing of {} elements.
pipelineBuilder.Extensions.RemoveAll(x => x is Markdig.Extensions.GenericAttributes.GenericAttributesExtension);
//pipelineBuilder.Extensions.RemoveAll(x => x is Markdig.Extensions.GenericAttributes.GenericAttributesExtension);

DeepLinkExtension deeplink = new DeepLinkExtension();
pipelineBuilder.Extensions.Add(deeplink);
Expand Down Expand Up @@ -461,6 +463,10 @@ private string ConvertMarkdownToHTML(List<MarkdownFile> files)

var md = mf.Content;

if (string.IsNullOrEmpty(md)) {
Log($"File {file.FullName} is empty and will be skipped!", LogLevel.Warning, 1);
continue;}

//rename TOC tags to fit to MarkdigToc or delete them from each markdown document
var newTOCString = _options.GlobalTOC != null ? "" : "[TOC]";
md = md.Replace("[[_TOC_]]", newTOCString);
Expand Down
Binary file modified AzureDevOps.WikiPDFExport/export.pdf
Binary file not shown.

0 comments on commit 1ae131e

Please sign in to comment.