Closed pakrym closed 2 years ago
@pakrym , can you add additional information for your proposal?
How to repro
Include https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md as embedded README.md. It contains triple ` code blocks in C#
Current behavior
Expected behavior
READMEs with code fences is very common on GitHub. Here are the top 10 most popular C# projects that are affected:
GitHub project | NuGet README preview | Stars |
---|---|---|
microsoft/PowerToys | Preview | 57582 |
shadowsocks/shadowsocks-windows | Preview | 52624 |
PowerShell/PowerShell | Preview | 27894 |
dnSpy/dnSpy | Preview | 18634 |
dotnet-architecture/eShopOnContainers | Preview | 18232 |
mxgmn/WaveFunctionCollapse | Preview | 16662 |
DapperLib/Dapper | Preview | 13946 |
AvaloniaUI/Avalonia | Preview | 11675 |
jellyfin/jellyfin | Preview | 11319 |
dotnet/efcore | Preview | 10415 |
If it's of any use, Highlight.js appears to be a pretty popular package for this purpose. It's used, for example, by Discord for its own syntax highlighting.
It has a bunch of themes that you can explore here: https://highlightjs.org/static/demo/
For example, this is how the readme preview looks if you just add the following to the <head>
of the page:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/vs2015.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('pre').forEach(block => hljs.highlightBlock(block));
});
</script>
Adding Prism.js to the conversation as another potential solution to the clientside rendering of code blocks.
Currently syntax blocks are not highlighted:
Would be great to enable syntax highlighting.