mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Some fixes for "Remove text for HI" - thx Thunderbolt8 :)
This commit is contained in:
parent
2ae6ddcfde
commit
407044a370
@ -474,6 +474,12 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
||||
text = text.TrimStart().TrimStart('-').TrimStart();
|
||||
}
|
||||
|
||||
if (oldText.TrimStart().StartsWith("<i>- ") && text != null && !text.Contains(Environment.NewLine) &&
|
||||
(oldText.Contains(Environment.NewLine + "- ") || oldText.Contains(Environment.NewLine + " - ") || oldText.Contains(Environment.NewLine + "<i>- ") || oldText.Contains(Environment.NewLine + "<i> - ")))
|
||||
{
|
||||
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 + "<i>- ") || oldText.Contains(Environment.NewLine + "<i> - ")))
|
||||
@ -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);
|
||||
|
@ -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 = "<i>- A man who wants to make his mark..." + Environment.NewLine + "- [ Coughing]</i>";
|
||||
const string expected = "<i>A man who wants to make his mark...</i>";
|
||||
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
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user