Fix issue with "Remove text for HI" - thx thunderbolt8

Fix #1427
This commit is contained in:
niksedk 2015-12-03 08:22:19 +01:00
parent 3ccffd1b6e
commit d77df271de
2 changed files with 25 additions and 0 deletions

View File

@ -1053,6 +1053,21 @@ namespace Nikse.SubtitleEdit.Core.Forms
text = text.TrimStart('-').TrimStart();
}
}
if (oldText != text)
{
text = text.Replace(Environment.NewLine + "<i>" + Environment.NewLine, Environment.NewLine + "<i>");
text = text.Replace(Environment.NewLine + "</i>" + Environment.NewLine, "</i>" + Environment.NewLine);
if (text.StartsWith("<i>" + Environment.NewLine))
{
text = text.Remove(3, Environment.NewLine.Length);
}
if (text.EndsWith(Environment.NewLine + "</i>"))
{
text = text.Remove(text.Length - (Environment.NewLine.Length + 4), Environment.NewLine.Length);
}
text = text.Replace(Environment.NewLine + "</i>" + Environment.NewLine, "</i>" + Environment.NewLine);
}
return text;
}

View File

@ -1416,6 +1416,16 @@ namespace Test.Logic.Forms
Assert.AreEqual(expected, actual);
}
[TestMethod]
public void RemoveTextForHiRemoveFirstBlankLineAlsoItalics()
{
RemoveTextForHI target = GetRemoveTextForHiLib();
string text = "<i>Ow. Ow." + Environment.NewLine + "Ow, my head.</i>";
const string expected = "<i>My head.</i>";
string actual = target.RemoveInterjections(text);
Assert.AreEqual(expected, actual);
}
#region Additional test attributes
//