Added syntax highlighting for the yaml language
This commit is contained in:
		
							parent
							
								
									85e654f231
								
							
						
					
					
						commit
						4774286eda
					
				| 
						 | 
					@ -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();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										33
									
								
								Wave/Utilities/SyntaxHighlighting/YamlLanguage.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Wave/Utilities/SyntaxHighlighting/YamlLanguage.cs
									
									
									
									
									
										Normal 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);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in a new issue