diff --git a/src/Logic/Utilities.cs b/src/Logic/Utilities.cs index 56ca172b2..5ec08d3fd 100644 --- a/src/Logic/Utilities.cs +++ b/src/Logic/Utilities.cs @@ -2679,6 +2679,24 @@ namespace Nikse.SubtitleEdit.Logic { var firstLine = text.Substring(0, index).Trim(); var secondLine = text.Substring(index + 2).Trim(); + + if (firstLine.Length > 10 && firstLine.StartsWith("- ") && firstLine.EndsWith(endTag)) + { + text = "- " + firstLine.Remove(0, 5) + Environment.NewLine + secondLine; + text = text.Replace("- ", "- "); + index = text.IndexOf(Environment.NewLine, StringComparison.Ordinal); + firstLine = text.Substring(0, index).Trim(); + secondLine = text.Substring(index + 2).Trim(); + } + if (secondLine.Length > 10 && secondLine.StartsWith("- ") && secondLine.EndsWith(endTag)) + { + text = firstLine + Environment.NewLine + "- " + secondLine.Remove(0, 5); + text = text.Replace("- ", "- "); + index = text.IndexOf(Environment.NewLine, StringComparison.Ordinal); + firstLine = text.Substring(0, index).Trim(); + secondLine = text.Substring(index + 2).Trim(); + } + if (StartsAndEndsWithTag(firstLine, beginTag, endTag) && StartsAndEndsWithTag(secondLine, beginTag, endTag)) { text = text.Replace(beginTag, String.Empty).Replace(endTag, String.Empty); diff --git a/src/Test/UtilitiesTest.cs b/src/Test/UtilitiesTest.cs index 3abaa08b9..74de3ee0b 100644 --- a/src/Test/UtilitiesTest.cs +++ b/src/Test/UtilitiesTest.cs @@ -88,6 +88,15 @@ namespace Test Assert.AreEqual(s2, "- It is a telegram?" + Environment.NewLine + "- It is."); } + [TestMethod] + [DeploymentItem("SubtitleEdit.exe")] + public void FixInvalidItalicTags6() + { + string s1 = "- Text1!" + Environment.NewLine + "- Text2."; + string s2 = Utilities.FixInvalidItalicTags(s1); + Assert.AreEqual(s2, "- Text1!" + Environment.NewLine + "- Text2."); + } + [TestMethod] [DeploymentItem("SubtitleEdit.exe")] public void FixUnneededSpacesDoubleSpace1()