Merge pull request #193 from ivandrofly/patch-12

Patch 12
This commit is contained in:
Nikolaj Olsson 2014-06-27 06:18:01 +02:00
commit 45c5849d08
2 changed files with 19 additions and 4 deletions

View File

@ -958,11 +958,13 @@ namespace Nikse.SubtitleEdit.Forms
const string endTag = "</i>";
string fixAction = _language.FixInvalidItalicTag;
int noOfInvalidHtmlTags = 0;
listViewFixes.BeginUpdate();
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
if (_subtitle.Paragraphs[i].Text.Contains("<"))
var text = _subtitle.Paragraphs[i].Text;
if (text.Contains("<"))
{
string text = _subtitle.Paragraphs[i].Text.Replace(beginTag.ToUpper(), beginTag).Replace(endTag.ToUpper(), endTag);
text = text.Replace(beginTag.ToUpper(), beginTag).Replace(endTag.ToUpper(), endTag);
string oldText = text;
text = Utilities.FixInvalidItalicTags(text);
@ -978,6 +980,8 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
listViewFixes.EndUpdate();
listViewFixes.Refresh();
if (noOfInvalidHtmlTags > 0)
LogStatus(_language.FixInvalidItalicTags, string.Format(_language.XInvalidHtmlTagsFixed, noOfInvalidHtmlTags));
}

View File

@ -326,11 +326,18 @@ namespace Nikse.SubtitleEdit.Logic
private static bool IsPartOfNumber(string s, int position)
{
if (s == null || s.Trim().Length == 0)
return false;
if (position + 2 > s.Length)
return false;
const string numbers = "1234567890";
if (",.".Contains(s[position].ToString()))
{
if (position > 0 && position < s.Length - 1)
{
return "1234567890".Contains(s[position - 1].ToString()) && "1234567890".Contains(s[position + 1].ToString());
return numbers.Contains(s[position - 1].ToString()) && numbers.Contains(s[position + 1].ToString());
}
}
return false;
@ -805,6 +812,9 @@ namespace Nikse.SubtitleEdit.Logic
if (!s.Contains("<"))
return s;
if(s.Contains("< "))
s = FixInvalidItalicTags(s);
s = s.Replace("<i>", string.Empty);
s = s.Replace("<і>", string.Empty); // different unicode chars
s = s.Replace("</i>", string.Empty);
@ -2520,6 +2530,7 @@ namespace Nikse.SubtitleEdit.Logic
text = text.Replace("< /I>", endTag);
text = text.Replace("</ I>", endTag);
text = text.Replace("< /I>", endTag);
text = text.Replace("< / I >", endTag);
text = text.Replace("</i> <i>", "_@_");
text = text.Replace(" _@_", "_@_");
@ -2745,7 +2756,7 @@ namespace Nikse.SubtitleEdit.Logic
return null;
}
/// <summary>
/// <summary>
/// HTML-encodes a string
/// </summary>
/// <param name="text">Text string to encode</param>