diff --git a/source/BaseGeneratorCommand.cs b/source/BaseGeneratorCommand.cs index 281f104fa161878622571d364e6188daa4218fc7..3a827765da5c75067d377c34f588272d8718eced 100644 --- a/source/BaseGeneratorCommand.cs +++ b/source/BaseGeneratorCommand.cs @@ -67,6 +67,12 @@ public abstract class BaseGeneratorCommand /// protected readonly StopwatchReporter stopwatch = new(); + /// + /// Markdig 20+ built-in extensions + /// + /// https://github.com/xoofx/markdig + protected MarkdownPipeline markdownPipeline; + /// /// The time that the older cache should be ignored. /// @@ -182,6 +188,11 @@ public abstract class BaseGeneratorCommand templateOptions.MemberAccessStrategy.Register(); templateOptions.FileProvider = new PhysicalFileProvider(Path.GetFullPath(site.SourceThemePath)); + // Configure Markdig with the Bibliography extension + markdownPipeline = new MarkdownPipelineBuilder() + .UseAdvancedExtensions() + .Build(); + ScanAllMarkdownFiles(); ParseSourceFiles(); @@ -222,7 +233,7 @@ public abstract class BaseGeneratorCommand } catch { - Log.Error("Error parsing file {file}. Skipped.", file.filePath); + Log.Error("Error parsing file {file}", file.filePath); } // Use interlocked to safely increment the counter in a multi-threaded environment @@ -349,7 +360,7 @@ public abstract class BaseGeneratorCommand ?? throw new FormatException($"Error parsing frontmatter for {filePath}"); // Convert the Markdown content to HTML - frontmatter.ContentPreRendered = Markdown.ToHtml(frontmatter.ContentRaw); + frontmatter.ContentPreRendered = Markdown.ToHtml(frontmatter.ContentRaw, markdownPipeline); frontmatter.Permalink = "/" + GetOutputPath(filePath, site, frontmatter); if (site.HomePage is null && string.IsNullOrEmpty(frontmatter.SourcePath) && frontmatter.SourceFileNameWithoutExtension == "index")