mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Fixed bug in remove text for HI - thx Thunderbolt8 :)
< i >- ♪♪[Continues ]< /i >|- It's pretty strong stuff. => It's pretty strong stuff.
This commit is contained in:
parent
8554d6e00b
commit
7c7bbe1355
@ -626,6 +626,31 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
text = text.TrimStart().TrimStart('-').TrimStart();
|
||||
}
|
||||
|
||||
string removeText = "<i>- </i>" + Environment.NewLine + "-";
|
||||
if (text.StartsWith(removeText))
|
||||
{
|
||||
text = text.Remove(0, removeText.Length).TrimStart(' ');
|
||||
}
|
||||
|
||||
removeText = "<i>-</i>" + Environment.NewLine + "-";
|
||||
if (text.StartsWith(removeText))
|
||||
{
|
||||
text = text.Remove(0, removeText.Length).TrimStart(' ');
|
||||
}
|
||||
|
||||
removeText = "<i>-</i>" + Environment.NewLine + "<i>-";
|
||||
if (text.StartsWith(removeText))
|
||||
{
|
||||
text = "<i>" + text.Remove(0, removeText.Length).TrimStart(' ');
|
||||
}
|
||||
|
||||
removeText = "<i>- </i>" + Environment.NewLine + "<i>-";
|
||||
if (text.StartsWith(removeText))
|
||||
{
|
||||
text = "<i>" + text.Remove(0, removeText.Length).TrimStart(' ');
|
||||
}
|
||||
|
||||
|
||||
if (oldText != text)
|
||||
{
|
||||
// insert spaces before "-"
|
||||
@ -1065,6 +1090,9 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
preAssTag = text.Substring(0, indexOfEndBracketSuccessor);
|
||||
text = text.Remove(0, indexOfEndBracketSuccessor).TrimStart();
|
||||
}
|
||||
string preNewLine = string.Empty;
|
||||
if (text.StartsWith(Environment.NewLine))
|
||||
preNewLine = Environment.NewLine;
|
||||
if (Settings.RemoveTextBetweenSquares)
|
||||
{
|
||||
text = RemoveTextBetweenTags("[", "]:", text);
|
||||
@ -1091,7 +1119,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return string.Empty;
|
||||
return preAssTag + text.TrimStart();
|
||||
return preAssTag + preNewLine + text.TrimStart();
|
||||
}
|
||||
|
||||
private bool HasHearImpairedText(string text)
|
||||
|
@ -1331,6 +1331,21 @@ namespace Test.Logic.Forms
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RemoveTextForHiRemoveFirstLine()
|
||||
{
|
||||
RemoveTextForHI target = GetRemoveTextForHiLib();
|
||||
target.Settings.RemoveTextBetweenBrackets = true;
|
||||
target.Settings.RemoveTextBetweenCustomTags = true;
|
||||
target.Settings.CustomStart = "♪";
|
||||
target.Settings.CustomEnd = "♪";
|
||||
target.Settings.RemoveTextBetweenBrackets = true;
|
||||
string text = "<i>- ♪♪[Continues ]</i>" + Environment.NewLine + "- It's pretty strong stuff.";
|
||||
const string expected = "It's pretty strong stuff.";
|
||||
string actual = target.RemoveTextFromHearImpaired(text);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
#region Additional test attributes
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user