From 4b613fffd8a132c7f364bbb998c25a0f2a42aede Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sat, 16 Mar 2024 19:35:19 +0100 Subject: [PATCH] Fixadding music notation to italics, removes italics - thx Charvelx04 :) Work on #7905 --- src/libse/Common/Utilities.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libse/Common/Utilities.cs b/src/libse/Common/Utilities.cs index bf4d5774e..f8923b25f 100644 --- a/src/libse/Common/Utilities.cs +++ b/src/libse/Common/Utilities.cs @@ -3178,30 +3178,32 @@ namespace Nikse.SubtitleEdit.Core.Common return text; } - public static string RemoveSymbols(string tag, string text, string endTag) + public static string RemoveSymbols(string tag, string input, string endTag) { var pre = string.Empty; var post = string.Empty; - text = SplitStartTags(text, ref pre); + var text = SplitStartTags(input, ref pre); text = SplitEndTags(text, ref post); if (!string.IsNullOrEmpty(tag) && text.Contains(tag) || string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(endTag) && text.Contains(endTag)) { if (!string.IsNullOrEmpty(endTag) && !string.IsNullOrEmpty(tag)) { - text = pre + text.Replace(tag, string.Empty).Replace(endTag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; + return pre + text.Replace(tag, string.Empty).Replace(endTag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; } - else if (string.IsNullOrEmpty(endTag) && !string.IsNullOrEmpty(tag)) + + if (string.IsNullOrEmpty(endTag) && !string.IsNullOrEmpty(tag)) { - text = pre + text.Replace(tag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; + return pre + text.Replace(tag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; } - else if (!string.IsNullOrEmpty(endTag)) + + if (!string.IsNullOrEmpty(endTag)) { - text = pre + text.Replace(endTag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; + return pre + text.Replace(endTag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; } } - return text; + return pre + text + post; }