diff --git a/WebfrontCore/TagHelpers/ColorCode.cs b/WebfrontCore/TagHelpers/ColorCode.cs
index 52da35df..f3f18455 100644
--- a/WebfrontCore/TagHelpers/ColorCode.cs
+++ b/WebfrontCore/TagHelpers/ColorCode.cs
@@ -1,10 +1,8 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using SharedLibraryCore;
-using System;
-using System.Collections.Generic;
using System.Linq;
+using System.Web;
using System.Text.RegularExpressions;
-using System.Threading.Tasks;
namespace WebfrontCore.TagHelpers
{
@@ -19,22 +17,28 @@ namespace WebfrontCore.TagHelpers
output.TagName = "ColorCode";
output.TagMode = TagMode.StartTagAndEndTag;
+
+
if (Allow)
{
- string updated = Value;
-
- foreach (Match match in Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)"))
+ var matches = Regex.Matches(Value, @"\^([0-9]|\:)([^\^]*)");
+ foreach (Match match in matches)
{
char colorCode = match.Groups[1].ToString().Last();
- updated = updated.Replace(match.Value, $"{match.Groups[2].ToString()}");
+ output.PreContent.AppendHtml($"");
+ output.PreContent.Append(match.Groups[2].ToString());
+ output.PreContent.AppendHtml("");
}
- output.PreContent.SetHtmlContent(updated);
+ if (matches.Count <= 1)
+ {
+ output.PreContent.SetContent(Value.StripColors());
+ }
}
else
{
- output.PreContent.SetHtmlContent(Value.StripColors());
+ output.PreContent.SetContent(Value.StripColors());
}
}
}