[utilities] - allow fixing spaces after quote.

This commit is contained in:
Ivandro Ismael 2017-04-30 02:49:24 +01:00
parent a080f66098
commit 5d17802a8b
2 changed files with 34 additions and 0 deletions

View File

@ -1930,6 +1930,26 @@ namespace Nikse.SubtitleEdit.Core
text = text.Remove(idx, 1);
}
}
// Fix spaces after quotes
// e.g: Foobar. " Foobar" => Foobar. "Foobar"
string preText = string.Empty;
if (text.LineStartsWithHtmlTag(true, true))
{
int endIdx = text.IndexOf('>') + 1;
preText = text.Substring(0, endIdx);
text = text.Substring(endIdx);
}
if (text.StartsWith('"'))
{
text = '"' + text.Substring(1).TrimStart();
}
text = preText + text;
text = text.Replace(". \" ", ". \"");
text = text.Replace("? \" ", "? \"");
text = text.Replace("! \" ", "! \"");
text = text.Replace(") \" ", ") \"");
text = text.Replace("> \" ", "> \"");
return text;
}

View File

@ -344,6 +344,20 @@ namespace Test.Logic
Assert.AreEqual(s, "<font color=\"#808080\">- Foobar!</font>\r\n<font color=\"#808080\">(PEOPLE SPEAKING INDISTINCTLY)</font>");
}
[TestMethod]
public void RemoveUnneededSpacesAfterQuote()
{
const string lang = "en";
// variant 1
string s = Utilities.RemoveUnneededSpaces("\" In five years the Corleone family\r\nwill be completely legitimate.\"", lang);
Assert.AreEqual("\"In five years the Corleone family\r\nwill be completely legitimate.\"", s);
// variant 2
s = Utilities.RemoveUnneededSpaces("Foobar? \" Foobar\".", lang);
Assert.AreEqual("Foobar? \"Foobar\".", s);
}
[TestMethod]
public void CountTagInTextStringOneLetterString()
{