Added syntax highlighting for the shell language
This commit is contained in:
parent
afe9627438
commit
85e654f231
|
@ -1,7 +1,9 @@
|
|||
using Markdig;
|
||||
using ColorCode.Styling;
|
||||
using Markdig;
|
||||
using Markdig.Extensions.MediaLinks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Markdown.ColorCode;
|
||||
using Wave.Utilities.SyntaxHighlighting;
|
||||
|
||||
namespace Wave.Utilities;
|
||||
|
||||
|
@ -18,7 +20,9 @@ public static class MarkdownUtilities {
|
|||
AddControlsProperty = true,
|
||||
Class = "max-w-full"
|
||||
})
|
||||
.UseColorCode()
|
||||
.UseColorCode(HtmlFormatterType.Style, StyleDictionary.DefaultDark, [
|
||||
new ShellLanguage()
|
||||
])
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
return Markdig.Markdown.ToHtml(markdown, pipeline);
|
||||
|
|
27
Wave/Utilities/SyntaxHighlighting/ShellLanguage.cs
Normal file
27
Wave/Utilities/SyntaxHighlighting/ShellLanguage.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using ColorCode;
|
||||
|
||||
namespace Wave.Utilities.SyntaxHighlighting;
|
||||
|
||||
public class ShellLanguage : ILanguage {
|
||||
public string Id => "shell";
|
||||
public string FirstLinePattern => @"^\s*\$.*";
|
||||
public string Name => "Shell";
|
||||
public string CssClassName => "shell";
|
||||
|
||||
public IList<LanguageRule> Rules { get; } = [
|
||||
new LanguageRule(@"\$\s*\w[\w\d]+\b", new Dictionary<int, string> {
|
||||
{0, ColorCode.Common.ScopeName.PowerShellCommand}
|
||||
}),
|
||||
new LanguageRule(@"(?:\s(\-\w|\-\-\w\w+)\b)", new Dictionary<int, string> {
|
||||
{0, ColorCode.Common.ScopeName.PowerShellParameter}
|
||||
}),
|
||||
new LanguageRule("[^\\\\]\"(?:.*?)[^\\\\]\"", new Dictionary<int, string> {
|
||||
{0, ColorCode.Common.ScopeName.String}
|
||||
})
|
||||
];
|
||||
|
||||
public bool HasAlias(string lang) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue