Skip to content

Commit

Permalink
Cleanup TextTagParser to use a bit less copied code
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardrowe committed May 13, 2019
1 parent 41d6a04 commit 4c0b016
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Assets/RedBlueGames/TextTyper/TextTagParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public struct CustomTags
public const string Animation = "animation";
}

private static readonly List<string> UnityTagTypes = new List<string> { "b", "i", "size", "color", "style" };
private static readonly List<string> CustomTagTypes = new List<string>
private static readonly string[] UnityTagTypes = new string[] { "b", "i", "size", "color", "style" };
private static readonly string[] CustomTagTypes = new string[]
{
CustomTags.Delay,
CustomTags.Anim,
Expand Down Expand Up @@ -65,27 +65,25 @@ public static string RemoveAllTags(string textWithTags)

public static string RemoveCustomTags(string textWithTags)
{
string textWithoutTags = textWithTags;
foreach (var customTag in CustomTagTypes)
{
textWithoutTags = RichTextTag.RemoveTagsFromString(textWithoutTags, customTag);
}

return textWithoutTags;
return RemoveTags(textWithTags, CustomTagTypes);
}

public static string RemoveUnityTags(string textWithTags)
{
return RemoveTags(textWithTags, UnityTagTypes);
}

private static string RemoveTags(string textWithTags, params string[] tags)
{
string textWithoutTags = textWithTags;
foreach (var unityTag in UnityTagTypes)
foreach (var tag in tags)
{
textWithoutTags = RichTextTag.RemoveTagsFromString(textWithoutTags, unityTag);
textWithoutTags = RichTextTag.RemoveTagsFromString(textWithoutTags, tag);
}

return textWithoutTags;
}


public class TextSymbol
{
public TextSymbol(string character)
Expand Down

0 comments on commit 4c0b016

Please sign in to comment.