Fix common errors -> Remove un-needed spaces - now removes spaces at line beginnings

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@145 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2010-11-13 21:02:39 +00:00
parent 2fa37a84da
commit 44d7816793

View File

@ -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("! </i>" + Environment.NewLine))
{
p.Text = p.Text.Replace("! </i>" + Environment.NewLine, "!</i>" + Environment.NewLine);
}
if (p.Text.Contains(" !</i>" + Environment.NewLine))
{
p.Text = p.Text.Replace(" !</i>" + Environment.NewLine, "!</i>" + Environment.NewLine);
}
if (p.Text.EndsWith(" ?</i>"))
{
p.Text = p.Text.Replace(" ?</i>", "?</i>");
}
}
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(" ?</i>" + Environment.NewLine))
{
p.Text = p.Text.Replace(" ?</i>" + Environment.NewLine, "?</i>" + Environment.NewLine);
}
if (p.Text.Contains("? </i>" + Environment.NewLine))
{
p.Text = p.Text.Replace("? </i>" + Environment.NewLine, "?</i>" + Environment.NewLine);
}
if (p.Text.EndsWith(" </i>"))
{
p.Text = p.Text.Substring(0, p.Text.Length - " </i>".Length) + "</i>";
@ -868,7 +852,6 @@ namespace Nikse.SubtitleEdit.Forms
{
p.Text = p.Text.Replace(" </I>" + Environment.NewLine, "</I>" + Environment.NewLine);
}
if (p.Text.StartsWith("<i> "))
{
p.Text = "<i>" + p.Text.Substring("<i> ".Length);
@ -877,6 +860,8 @@ namespace Nikse.SubtitleEdit.Forms
{
p.Text = p.Text.Replace(Environment.NewLine + "<i> ", Environment.NewLine + "<i>");
}
p.Text = p.Text.Trim();
p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine);
if (p.Text.StartsWith("<I> "))
{
p.Text = "<I>" + p.Text.Substring("<I> ".Length);
@ -885,6 +870,8 @@ namespace Nikse.SubtitleEdit.Forms
{
p.Text = p.Text.Replace(Environment.NewLine + "<I> ", Environment.NewLine + "<I>");
}
p.Text = p.Text.Trim();
p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine);
if (p.Text != oldText)
{