Added syntax highlighting for the yaml language
Some checks failed
Build, Tag, Push Docker Image / build (push) Has been cancelled
Create Release / Generate Release (push) Has been cancelled

This commit is contained in:
Mia Rose Winter 2024-03-21 12:17:29 +01:00
parent 85e654f231
commit 4774286eda
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 35 additions and 1 deletions

View file

@ -21,7 +21,8 @@ public static class MarkdownUtilities {
Class = "max-w-full" Class = "max-w-full"
}) })
.UseColorCode(HtmlFormatterType.Style, StyleDictionary.DefaultDark, [ .UseColorCode(HtmlFormatterType.Style, StyleDictionary.DefaultDark, [
new ShellLanguage() new ShellLanguage(),
new YamlLanguage()
]) ])
.DisableHtml() .DisableHtml()
.Build(); .Build();

View file

@ -0,0 +1,33 @@
using ColorCode;
namespace Wave.Utilities.SyntaxHighlighting;
#nullable disable
public class YamlLanguage : ILanguage {
public string Id => "yml";
public string FirstLinePattern => null;
public string Name => "Yaml";
public string CssClassName => "yml";
public IList<LanguageRule> Rules { get; } = [
new LanguageRule(@"(?:\w+):", new Dictionary<int, string> {
{0, ColorCode.Common.ScopeName.XmlAttribute}
}),
new LanguageRule(@"#(?:.*)\b", new Dictionary<int, string> {
{0, ColorCode.Common.ScopeName.Comment}
}),
new LanguageRule("[^\\\\]\"(?:.*?)[^\\\\]\"", new Dictionary<int, string> {
{0, ColorCode.Common.ScopeName.String}
}),
new LanguageRule(@"\-(?:\s\w.+)\b", new Dictionary<int, string> {
{0, ColorCode.Common.ScopeName.XmlAttributeValue}
})
];
public bool HasAlias(string lang) {
return string.Equals(lang, "yml", StringComparison.CurrentCultureIgnoreCase) ||
string.Equals(lang, "yaml", StringComparison.CurrentCultureIgnoreCase);
}
}