mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 05:02:36 +01:00
Improve "Remove unneeded spaces" - thx uckthis :)
Related to comment https://github.com/SubtitleEdit/subtitleedit/issues/4131#issuecomment-619527038 in #4131
This commit is contained in:
parent
d699dbecd8
commit
571b0a958e
@ -2056,16 +2056,31 @@ namespace Nikse.SubtitleEdit.Core
|
||||
text = text.Remove(3, 1);
|
||||
}
|
||||
|
||||
if (text.EndsWith(" ...", StringComparison.Ordinal))
|
||||
while (text.EndsWith(" ...", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(text.Length - 4, 1);
|
||||
}
|
||||
|
||||
if (text.EndsWith(" ...</i>", StringComparison.Ordinal))
|
||||
while (text.EndsWith(" ...</i>", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(text.Length - 8, 1);
|
||||
}
|
||||
|
||||
while (text.EndsWith(" .</i>", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(text.Length - 6, 1);
|
||||
}
|
||||
|
||||
while (text.EndsWith(" !</i>", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(text.Length - 6, 1);
|
||||
}
|
||||
|
||||
while (text.EndsWith(" ?</i>", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(text.Length - 6, 1);
|
||||
}
|
||||
|
||||
if (text.StartsWith("- ... ", StringComparison.Ordinal))
|
||||
{
|
||||
text = text.Remove(5, 1);
|
||||
|
@ -27062,10 +27062,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
// nothing changed
|
||||
if (linesUpdated == 0)
|
||||
{
|
||||
return;
|
||||
return; // nothing changed
|
||||
}
|
||||
|
||||
var firstIdx = FirstSelectedIndex;
|
||||
|
@ -1155,6 +1155,17 @@ namespace Test.FixCommonErrors
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FixUnneededSpacesBeforeEndTag()
|
||||
{
|
||||
using (var target = GetFixCommonErrorsLib())
|
||||
{
|
||||
InitializeFixCommonErrorsLine(target, "<i>I happen to have" + Environment.NewLine + " the blood of an ancient family .</i>");
|
||||
new FixUnneededSpaces().Fix(_subtitle, new EmptyFixCallback());
|
||||
Assert.AreEqual("<i>I happen to have" + Environment.NewLine + "the blood of an ancient family.</i>", _subtitle.Paragraphs[0].Text);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Fix unneeded spaces
|
||||
|
||||
#region Fix EmptyLines
|
||||
|
Loading…
Reference in New Issue
Block a user