Highlighted code blocks inside the app (#1153)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-04 07:58:57 +01:00
1 parent 0b42c0288e
commit f4a86c2fb8
60 files changed
+2550 -41

No files matched your search

@@ -0,0 +1,27 @@
namespace AIStudio.Tools.CodeHighlighting;
public static class CodeTokenKindExtensions
{
/// <summary>
/// The CSS class which MudBlazor.Markdown gives this kind of part, so that it takes its color from
/// the palette of the theme, just as the languages the library highlights itself.
/// </summary>
/// <param name="kind">What the part is.</param>
/// <returns>The CSS class of the part.</returns>
public static string ToCssClass(this CodeTokenKind kind) => kind switch
{
CodeTokenKind.KEYWORD => "hljs-keyword",
CodeTokenKind.TYPE => "hljs-type",
CodeTokenKind.LITERAL => "hljs-literal",
CodeTokenKind.STRING => "hljs-string",
CodeTokenKind.COMMENT => "hljs-comment",
CodeTokenKind.NUMBER => "hljs-number",
CodeTokenKind.FUNCTION => "hljs-title function_",
CodeTokenKind.META => "hljs-meta",
CodeTokenKind.VARIABLE => "hljs-variable",
CodeTokenKind.ATTRIBUTE => "hljs-attr",
CodeTokenKind.SELECTOR => "hljs-selector-class",
_ => string.Empty,
};
}