mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-01-31 13:01:39 +01:00
[utilities] - allow fixing spaces after quote.
This commit is contained in:
parent
a080f66098
commit
5d17802a8b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user