Colorify SCSI MODE PAGE 0Dh

This commit is contained in:
2025-08-17 16:54:14 +01:00
parent 2e1da76630
commit 5d0258dfb0
2 changed files with 55 additions and 26 deletions

View File

@@ -0,0 +1,27 @@
using System.Text.RegularExpressions;
public static class MarkupHelper
{
public static string HighlightNumbers(string input, string color, bool italicize = false)
{
if(string.IsNullOrEmpty(input) || string.IsNullOrEmpty(color)) return input;
// Match integers and decimals (e.g., 42, 3.14, -7)
string pattern = @"(?<!
\[" +
Regex.Escape(color) +
@"\]
)(-?\d+(\.\d+)?)(?!
\[/\]
)";
string openingTag = italicize ? $"[italic][{color}]" : $"[{color}]";
string closingTag = italicize ? "[/][/]" : "[/]";
return Regex.Replace(input, pattern, $"{openingTag}$1{closingTag}");
}
}