statiqdev / Statiq.Web

Statiq Web is a flexible static site generator written in .NET.
https://statiq.dev/web
Other
1.65k stars 235 forks source link

Feature Request: specify default code highlighting language in the config file #829

Closed SilentSin closed 2 years ago

SilentSin commented 5 years ago

I just found that I can get better syntax highlighting for my code blocks by putting csharp at the top like so:

    ```csharp
    public virtual void MyMethod()
    {
    }


But since every code block on my site is in C# I'm thinking it would be nice if I could just specify that in the config file.
daveaglick commented 2 years ago

After reviewing this issue some more (in the context of other broader changes I've been working on with highlighting), I don't think this particular change is quite right. The behavior of Markdown code blocks is pretty well defined and I don't want to stray from that well-known definition.

We also now have a FencedCodeBlocksShouldHaveLanguage analyzer in Statiq Web that can catch and warn (or generate an error) about code blocks that don't specify a language.

I suppose it would also be possible to enable this behavior by adding a ProcessHtml module to the Statiq Web Content pipeline's post-process phase. That would do the trick nicely for anyone who really wants to change the default language for generated code blocks.