mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Another fix for start ellipsis and "add missing space" - thx btsix :)
This commit is contained in:
parent
fbd5239a26
commit
75ecb38eb8
@ -24,10 +24,10 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
const string expectedChars = @"""”<.";
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
Paragraph p = subtitle.Paragraphs[i];
|
||||
var p = subtitle.Paragraphs[i];
|
||||
|
||||
// missing space after comma ","
|
||||
Match match = FixMissingSpacesReComma.Match(p.Text);
|
||||
var match = FixMissingSpacesReComma.Match(p.Text);
|
||||
while (match.Success)
|
||||
{
|
||||
bool doFix = !expectedChars.Contains(p.Text[match.Index + 2]);
|
||||
@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
(p.Text.Substring(match.Index).StartsWith("ό,τι", StringComparison.Ordinal) ||
|
||||
p.Text.Substring(match.Index).StartsWith("O,τι", StringComparison.Ordinal) ||
|
||||
p.Text.Substring(match.Index).StartsWith("Ό,τι", StringComparison.Ordinal) ||
|
||||
p.Text.Substring(match.Index).StartsWith("Ο,ΤΙ", StringComparison.Ordinal) ||
|
||||
p.Text.Substring(match.Index).StartsWith("Ο,ΤΙ", StringComparison.Ordinal) ||
|
||||
p.Text.Substring(match.Index).StartsWith("ο,τι", StringComparison.Ordinal)))
|
||||
{
|
||||
doFix = false;
|
||||
@ -246,7 +246,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
string newText = p.Text;
|
||||
int indexOfFontTag = newText.IndexOf("<font ", StringComparison.OrdinalIgnoreCase);
|
||||
bool isAfterAssTag = newText.Contains("{\\") && start > 0 && newText[start - 1] == '}';
|
||||
if (!isAfterAssTag && start > 0 && !(Environment.NewLine + @" >[(♪♫¿").Contains(p.Text[start - 1]))
|
||||
bool isAfterEllipsis = start >= 3 && newText.Substring(start - 3, 3) == "...";
|
||||
if (!isAfterAssTag && !isAfterEllipsis && start > 0 && !(Environment.NewLine + @" >[(♪♫¿").Contains(p.Text[start - 1]))
|
||||
{
|
||||
if (indexOfFontTag < 0 || start > newText.IndexOf('>', indexOfFontTag)) // font tags can contain "
|
||||
{
|
||||
|
@ -1058,6 +1058,17 @@ namespace Test
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FixMissingSpacesStartEllipsisDoNotTouch2()
|
||||
{
|
||||
using (var target = GetFixCommonErrorsLib())
|
||||
{
|
||||
InitializeFixCommonErrorsLine(target, "...\"litigious need not apply.\"");
|
||||
new FixMissingSpaces().Fix(_subtitle, new EmptyFixCallback());
|
||||
Assert.AreEqual("...\"litigious need not apply.\"", _subtitle.Paragraphs[0].Text);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Fix missing spaces
|
||||
|
||||
#region Fix unneeded spaces
|
||||
|
Loading…
Reference in New Issue
Block a user