Advertisement
ivandrofly

SubtitleEdit: Utilities#SplitEndTags

Mar 20th, 2025
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. public static (string, string) SplitEndTags(string line)
  2.         {
  3.             int r = line.Length - 1;
  4.  
  5.             if (line.EndsWith("{\\r}", StringComparison.Ordinal))
  6.             {
  7.                 r = line.Length - 4;
  8.             }
  9.  
  10.             for (int l = r; l >= 0; l--)
  11.             {
  12.                 if (line[l] == '>')
  13.                 {
  14.                     r = l;
  15.                 }
  16.                 else if (line[l] == '<' && line[r] == '>')
  17.                 {
  18.                     string tag = line.Substring(l, r - l + 1).ToLowerInvariant();
  19.                     if (HtmlUtil.CommonHtmlTags.Contains(tag) || tag.StartsWith("<font", StringComparison.Ordinal))
  20.                     {
  21.                         r = l;
  22.                     }
  23.                 }
  24.                 else if (line[l] != ' ')
  25.                 {
  26.                     break;
  27.                 }
  28.             }
  29.  
  30.             return (line.Substring(0, r), line.Substring(r));
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement