Fixed another case with italics

This commit is contained in:
niksedk 2014-09-12 22:30:35 +02:00
parent 8469aa7345
commit 2315a0f9cf
2 changed files with 27 additions and 0 deletions

View File

@ -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("- <i>") && firstLine.EndsWith(endTag))
{
text = "<i>- " + firstLine.Remove(0, 5) + Environment.NewLine + secondLine;
text = text.Replace("<i>- ", "<i>- ");
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("- <i>") && secondLine.EndsWith(endTag))
{
text = firstLine + Environment.NewLine + "<i>- " + secondLine.Remove(0, 5);
text = text.Replace("<i>- ", "<i>- ");
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);

View File

@ -88,6 +88,15 @@ namespace Test
Assert.AreEqual(s2, "<i>- It is a telegram?" + Environment.NewLine + "- It is.</i>");
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void FixInvalidItalicTags6()
{
string s1 = "- <i>Text1!</i>" + Environment.NewLine + "- <i>Text2.</i>";
string s2 = Utilities.FixInvalidItalicTags(s1);
Assert.AreEqual(s2, "<i>- Text1!" + Environment.NewLine + "- Text2.</i>");
}
[TestMethod]
[DeploymentItem("SubtitleEdit.exe")]
public void FixUnneededSpacesDoubleSpace1()