Fix minor space issue with "Fix italic tags" - thx Adam :)

This commit is contained in:
Nikolaj Olsson 2023-11-26 17:30:52 +01:00
parent f3bc862339
commit eb10eaebcc
3 changed files with 26 additions and 6 deletions

View File

@ -15,6 +15,7 @@
* Update yt-dlp to 2023-11-16
* FIXED:
* Fix Whisper CPP cuBLAS new hash (DLL files now included)
* Fix minor space issue with "Fix italic tags" - thx Adam
4.0.2 (19th November 2023)

View File

@ -463,6 +463,14 @@ namespace Test.Logic
Assert.AreEqual("ADULT MARK: <i>New friends</i>", s2);
}
[TestMethod]
public void FixInvalidItalicColonBracketItalic()
{
var s1 = "[König:]<i> Ich weiß, dass du dagegen</i>" + Environment.NewLine + "<i>bist.</i>";
var s2 = HtmlUtil.FixInvalidItalicTags(s1);
Assert.AreEqual("[König:] <i>Ich weiß, dass du dagegen</i>" + Environment.NewLine + "<i>bist.</i>", s2);
}
[TestMethod]
public void FixUnneededSpacesDoubleSpace1()
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
@ -651,6 +652,11 @@ namespace Nikse.SubtitleEdit.Core.Common
text = text.Replace("<I/>", string.Empty);
}
text = text.Replace("]<i> ", "] <i>");
text = text.Replace(")<i> ", ") <i>");
text = text.Replace("] </i>", "] </i>");
text = text.Replace(") </i>", ") </i>");
text = text.Replace(beginTag + beginTag, beginTag);
text = text.Replace(endTag + endTag, endTag);
@ -852,7 +858,11 @@ namespace Nikse.SubtitleEdit.Core.Common
if (idx > 1)
{
var pre = text.Substring(0, idx + 1).TrimStart();
text = text.Remove(0, idx + 1);
var tempText = text.Remove(0, idx + 1);
if (!tempText.StartsWith(']') && !tempText.StartsWith(')'))
{
text = tempText;
text = FixInvalidItalicTags(text).Trim();
if (text.StartsWith("<i> ", StringComparison.OrdinalIgnoreCase))
{
@ -864,6 +874,7 @@ namespace Nikse.SubtitleEdit.Core.Common
}
}
}
}
//<i>- You think they're they gone?<i>
//<i>- That can't be.</i>