code block backgound #329

Closed
opened 2026-01-29 14:33:55 +00:00 by claunia · 1 comment
Owner

Originally created by @zoinkydoink on GitHub (Sep 30, 2019).

I am using the SyntaxHighlighting extension but it generates a white background for the code block. I tried passing in StyleDictionarly.DefaultDark but that gave a black background and most of the code is invisible.

I simply would like each code block to have a light grey like you see on every blog post on line

here is the code I am using

private MarkupString ConvertStringToMarkupString(string value)
{
    if (!string.IsNullOrWhiteSpace(_content))
    {
        var pipeline = new MarkdownPipelineBuilder()
        .UseAdvancedExtensions()
        .UseSyntaxHighlighting()
        .Build();
        var html = Markdig.Markdown.ToHtml(value, pipeline);
  
        var sanitizedHtml = HtmlSanitizer.Sanitize(html);

        return new MarkupString(sanitizedHtml);
    }

    return new MarkupString();

}
Originally created by @zoinkydoink on GitHub (Sep 30, 2019). I am using the SyntaxHighlighting extension but it generates a white background for the code block. I tried passing in StyleDictionarly.DefaultDark but that gave a black background and most of the code is invisible. I simply would like each code block to have a light grey like you see on every blog post on line here is the code I am using private MarkupString ConvertStringToMarkupString(string value) { if (!string.IsNullOrWhiteSpace(_content)) { var pipeline = new MarkdownPipelineBuilder() .UseAdvancedExtensions() .UseSyntaxHighlighting() .Build(); var html = Markdig.Markdown.ToHtml(value, pipeline); var sanitizedHtml = HtmlSanitizer.Sanitize(html); return new MarkupString(sanitizedHtml); } return new MarkupString(); }
Author
Owner

@xoofx commented on GitHub (Sep 30, 2019):

That's a CSS issue/SyntaxHighlighting on your side that should be solved with CSS. Markdig doesn't enforce any rendering rules

@xoofx commented on GitHub (Sep 30, 2019): That's a CSS issue/SyntaxHighlighting on your side that should be solved with CSS. Markdig doesn't enforce any rendering rules
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#329