Fix two hearing impaired issues - thx

teodargent :)
Fix #3599
This commit is contained in:
Nikolaj Olsson 2019-09-29 07:18:57 +02:00
parent 33893f93df
commit 3e47effb77
2 changed files with 31 additions and 4 deletions

View File

@ -859,11 +859,11 @@ namespace Nikse.SubtitleEdit.Core.Forms
text = st.Pre + text + st.Post;
}
if (input.TrimStart().StartsWith("- ", StringComparison.Ordinal) &&
if ((input.TrimStart().StartsWith("-", StringComparison.Ordinal) || input.TrimStart().StartsWith("<i>-", StringComparison.Ordinal)) &&
text != null && !text.Contains(Environment.NewLine) &&
(input.Contains(Environment.NewLine + "- ") ||
(input.Contains(Environment.NewLine + "-") ||
input.Contains(Environment.NewLine + " - ") ||
input.Contains(Environment.NewLine + "<i>- ") ||
input.Contains(Environment.NewLine + "<i>-") ||
input.Contains(Environment.NewLine + "<i> - ")))
{
if (text.StartsWith("<i>-", StringComparison.Ordinal))
@ -1267,6 +1267,12 @@ namespace Nikse.SubtitleEdit.Core.Forms
{
text = text.Remove(0, 1).TrimStart();
}
else if (text.Substring(0, start).EndsWith(", ") && text.Remove(0, start).TrimStart().StartsWith(','))
{
text = text.Substring(0, start).TrimEnd() + " " + text.Remove(0, start).TrimStart(' ', ',');
text = text.Trim();
}
start = text.IndexOf(startTag, StringComparison.Ordinal);
}
while (start >= 0 && text.Length - start - startTag.Length >= endTag.Length);

View File

@ -2,7 +2,6 @@
using Nikse.SubtitleEdit.Core.Forms;
using System;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Dictionaries;
namespace Test.Logic.Forms
{
@ -1786,6 +1785,28 @@ namespace Test.Logic.Forms
Assert.AreEqual(string.Empty, actual);
}
[TestMethod]
public void RemoveHiSecondLineHiDialog()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBeforeColon = true;
target.Settings.RemoveTextBeforeColonOnlyUppercase = true;
target.Settings.OnlyIfInSeparateLine = true;
string actual = target.RemoveTextFromHearImpaired("<i>-Era stato avveritito.</i>" + Environment.NewLine + "-(PARLA IN SPANOLO)");
Assert.AreEqual("<i>Era stato avveritito.</i>", actual);
}
[TestMethod]
public void RemoveHiRemoveInLine()
{
var target = GetRemoveTextForHiLib();
target.Settings.RemoveTextBeforeColon = true;
target.Settings.RemoveTextBeforeColonOnlyUppercase = true;
target.Settings.OnlyIfInSeparateLine = true;
string actual = target.RemoveTextFromHearImpaired("Senti, [si schiarisce la voce]," + Environment.NewLine + "dille semplicemente che ti e mancata.");
Assert.AreEqual("Senti," + Environment.NewLine + "dille semplicemente che ti e mancata.", actual);
}
#region Additional test attributes
//