Small improvement to 'fix italic tags' - thx azu :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1610 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-02-07 20:49:26 +00:00
parent fce087dbd2
commit b7fa10a68e

View File

@ -2231,11 +2231,20 @@ namespace Nikse.SubtitleEdit.Logic
if (italicBeginTagCount == 2 && italicEndTagCount == 1)
{
int lastIndex = text.LastIndexOf(beginTag);
if (text.Length > lastIndex + endTag.Length)
text = text.Substring(0, lastIndex) + text.Substring(lastIndex - 1 + endTag.Length);
var lines = text.Replace(Environment.NewLine, "\n").Split('\n');
if (lines.Length == 2 && lines[0].StartsWith("<i>") && lines[0].EndsWith("</i>") &&
lines[1].StartsWith("<i>"))
{
text = text.TrimEnd() + "</i>";
}
else
text = text.Substring(0, lastIndex - 1) + endTag;
{
int lastIndex = text.LastIndexOf(beginTag);
if (text.Length > lastIndex + endTag.Length)
text = text.Substring(0, lastIndex) + text.Substring(lastIndex - 1 + endTag.Length);
else
text = text.Substring(0, lastIndex - 1) + endTag;
}
}
if (italicBeginTagCount == 1 && italicEndTagCount == 0)