diff --git a/src/Logic/Forms/RemoveTextForHI.cs b/src/Logic/Forms/RemoveTextForHI.cs index e8026111d..7f546b3ea 100644 --- a/src/Logic/Forms/RemoveTextForHI.cs +++ b/src/Logic/Forms/RemoveTextForHI.cs @@ -474,6 +474,12 @@ namespace Nikse.SubtitleEdit.Logic.Forms text = text.TrimStart().TrimStart('-').TrimStart(); } + if (oldText.TrimStart().StartsWith("- ") && text != null && !text.Contains(Environment.NewLine) && + (oldText.Contains(Environment.NewLine + "- ") || oldText.Contains(Environment.NewLine + " - ") || oldText.Contains(Environment.NewLine + "- ") || oldText.Contains(Environment.NewLine + " - "))) + { + text = text.Remove(3, 2); + } + if (text != null && !text.Contains(Environment.NewLine) && (oldText.Contains(":") && !text.Contains(":") || oldText.Contains("[") && !text.Contains("[") || oldText.Contains("(") && !text.Contains("(") || oldText.Contains("{") && !text.Contains("{")) && (oldText.Contains(Environment.NewLine + "- ") || oldText.Contains(Environment.NewLine + " - ") || oldText.Contains(Environment.NewLine + "- ") || oldText.Contains(Environment.NewLine + " - "))) @@ -662,6 +668,16 @@ namespace Nikse.SubtitleEdit.Logic.Forms temp = temp.Remove(index - s.Length, 2); removeAfter = false; } + else if (index > 0 && temp.Substring(index - s.Length).StartsWith(", -—")) + { + temp = temp.Remove(index - s.Length, 3); + removeAfter = false; + } + else if (index > 0 && temp.Substring(index - s.Length).StartsWith(", --")) + { + temp = temp.Remove(index - s.Length, 2); + removeAfter = false; + } } if (removeAfter && temp.Length > index - s.Length + 2 && index > s.Length) { @@ -927,6 +943,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms string tmp = lineNoHtml.TrimEnd('.', '!', '?', ':').Trim(); if (lineNoHtml != lineNoHtml.ToLower() && lineNoHtml == lineNoHtml.ToUpper()) { + tmp = tmp.Trim(' ', '-', '—'); if (tmp == "YES" || tmp == "NO" || tmp == "WHY" || tmp == "HI" || tmp.Length == 1) { sb.AppendLine(line); diff --git a/src/Test/RemoveTextForHearImpairedTest.cs b/src/Test/RemoveTextForHearImpairedTest.cs index 66f0263f1..b2bfe5531 100644 --- a/src/Test/RemoveTextForHearImpairedTest.cs +++ b/src/Test/RemoveTextForHearImpairedTest.cs @@ -826,6 +826,42 @@ namespace Test Assert.AreEqual(expected, actual); } + [TestMethod] + [DeploymentItem("SubtitleEdit.exe")] + public void RemoveInterjectionsMDash() + { + RemoveTextForHI target = GetRemoveTextForHiLib(); + target.Settings.RemoveInterjections = true; + const string text = "I'm sorry. I, mm-hmm—"; + const string expected = "I'm sorry. I—"; + string actual = target.RemoveInterjections(text); + Assert.AreEqual(expected, actual); + } + + [TestMethod] + [DeploymentItem("SubtitleEdit.exe")] + public void RemoveFirstDashItalics() + { + RemoveTextForHI target = GetRemoveTextForHiLib(); + target.Settings.RemoveTextBetweenBrackets = true; + string text = "- A man who wants to make his mark..." + Environment.NewLine + "- [ Coughing]"; + const string expected = "A man who wants to make his mark..."; + string actual = target.RemoveTextFromHearImpaired(text); + Assert.AreEqual(expected, actual); + } + + [TestMethod] + [DeploymentItem("SubtitleEdit.exe")] + public void RemoveTextIfUppercaseNotEmdash() + { + RemoveTextForHI target = GetRemoveTextForHiLib(); + target.Settings.RemoveIfAllUppercase = true; + string text = "- And you?" + Environment.NewLine + "- I—"; + string expected = "- And you?" + Environment.NewLine + "- I—"; + string actual = target.RemoveTextFromHearImpaired(text); + Assert.AreEqual(expected, actual); + } + #region Additional test attributes //