Coloring support for code #501

Closed
opened 2026-01-29 14:38:15 +00:00 by claunia · 2 comments
Owner

Originally created by @rdmzkn on GitHub (Feb 7, 2022).

Is there any colouring support for code tag ?

I use the latest version and colouring updates are not generated in html for code sections in md files.

Originally created by @rdmzkn on GitHub (Feb 7, 2022). Is there any colouring support for code tag ? I use the latest version and colouring updates are not generated in html for code sections in md files.
claunia added the question label 2026-01-29 14:38:15 +00:00
Author
Owner

@MihaZupan commented on GitHub (Feb 7, 2022):

Markdig does not emit style tags / CSS, though it will add the language class on code blocks so that other tools may add coloring.

For example

```csharp
Console.WriteLine("Hello world");
```

will be rendered as

<pre>
  <code class="language-csharp">
    Console.WriteLine("Hello world");

</code></pre>

You can then use other plugins to do the highlighting - e.g. highlight.js or prism.js.
See #345 for some more discussions around highlighting.

@MihaZupan commented on GitHub (Feb 7, 2022): Markdig does not emit style tags / CSS, though it will add the language class on code blocks so that other tools may add coloring. For example ````md ```csharp Console.WriteLine("Hello world"); ``` ```` will be rendered as ```html <pre> <code class="language-csharp"> Console.WriteLine("Hello world"); </code></pre> ``` You can then use other plugins to do the highlighting - e.g. `highlight.js` or `prism.js`. See #345 for some more discussions around highlighting.
Author
Owner

@xoofx commented on GitHub (Feb 7, 2022):

In my experience, I have been using prism.js with markdig without changing anything, used on my blog post and on https://kalk.dev/ and it works very well.

Also see some third party extensions that are proposing syntax highlighting

@xoofx commented on GitHub (Feb 7, 2022): In my experience, I have been using `prism.js` with markdig without changing anything, used on my blog post and on https://kalk.dev/ and it works very well. Also see [some third party extensions](https://github.com/xoofx/markdig#third-party-extensions) that are proposing syntax highlighting
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#501