diff --git a/src/Forms/FixCommonErrors.cs b/src/Forms/FixCommonErrors.cs index 3e9d0709b..87635ec58 100644 --- a/src/Forms/FixCommonErrors.cs +++ b/src/Forms/FixCommonErrors.cs @@ -767,91 +767,75 @@ namespace Nikse.SubtitleEdit.Forms Paragraph p = _subtitle.Paragraphs[i]; string oldText = p.Text; + p.Text = p.Text.Trim(); while (p.Text.Contains(" ")) { p.Text = p.Text.Replace(" ", " "); } - if (p.Text.Contains(" " + Environment.NewLine)) { p.Text = p.Text.Replace(" " + Environment.NewLine, Environment.NewLine); } - if (p.Text.EndsWith(" ")) { p.Text = p.Text.TrimEnd(' '); } - while (p.Text.Contains(" ,")) { p.Text = p.Text.Replace(" ,", ","); } - if (p.Text.EndsWith(" .")) { p.Text = p.Text.Substring(0, p.Text.Length - " .".Length) + "."; } - if (p.Text.EndsWith(" \"")) { p.Text = p.Text.Remove(p.Text.Length - 2, 1); } - if (p.Text.Contains(" \"" + Environment.NewLine)) { p.Text = p.Text.Replace(" \"" + Environment.NewLine, "\"" + Environment.NewLine); } - if (p.Text.Contains(" ." + Environment.NewLine)) { p.Text = p.Text.Replace(" ." + Environment.NewLine, "." + Environment.NewLine); } - if (p.Text.EndsWith(" !")) { p.Text = p.Text.Substring(0, p.Text.Length - " !".Length) + "!"; } - if (p.Text.Contains(" !" + Environment.NewLine)) { p.Text = p.Text.Replace(" !" + Environment.NewLine, "!" + Environment.NewLine); } - if (p.Text.Contains("! " + Environment.NewLine)) { p.Text = p.Text.Replace("! " + Environment.NewLine, "!" + Environment.NewLine); } - if (p.Text.Contains(" !" + Environment.NewLine)) { p.Text = p.Text.Replace(" !" + Environment.NewLine, "!" + Environment.NewLine); } - if (p.Text.EndsWith(" ?")) { p.Text = p.Text.Replace(" ?", "?"); - } - + } if (p.Text.EndsWith(" ?")) { p.Text = p.Text.Substring(0, p.Text.Length - " ?".Length) + "?"; } - if (p.Text.Contains(" ?" + Environment.NewLine)) { p.Text = p.Text.Replace(" ?" + Environment.NewLine, "?" + Environment.NewLine); } - if (p.Text.Contains(" ?" + Environment.NewLine)) { p.Text = p.Text.Replace(" ?" + Environment.NewLine, "?" + Environment.NewLine); } - if (p.Text.Contains("? " + Environment.NewLine)) { p.Text = p.Text.Replace("? " + Environment.NewLine, "?" + Environment.NewLine); } - if (p.Text.EndsWith(" ")) { p.Text = p.Text.Substring(0, p.Text.Length - " ".Length) + ""; @@ -868,7 +852,6 @@ namespace Nikse.SubtitleEdit.Forms { p.Text = p.Text.Replace(" " + Environment.NewLine, "" + Environment.NewLine); } - if (p.Text.StartsWith(" ")) { p.Text = "" + p.Text.Substring(" ".Length); @@ -877,6 +860,8 @@ namespace Nikse.SubtitleEdit.Forms { p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine + ""); } + p.Text = p.Text.Trim(); + p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine); if (p.Text.StartsWith(" ")) { p.Text = "" + p.Text.Substring(" ".Length); @@ -885,6 +870,8 @@ namespace Nikse.SubtitleEdit.Forms { p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine + ""); } + p.Text = p.Text.Trim(); + p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine); if (p.Text != oldText) {