mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Fix new issue with OCR/Italic - thx Zoltan :)
This commit is contained in:
parent
9e428531ce
commit
0dcb118064
@ -138,6 +138,38 @@ namespace Test.Logic.Ocr
|
||||
Assert.AreEqual("CAESAR: <i>I live here.</i>", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestNonItalicAndParentheses()
|
||||
{
|
||||
var matches = new List<VobSubOcr.CompareMatch>
|
||||
{
|
||||
new VobSubOcr.CompareMatch("-(", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("L", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("A", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("U", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("G", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("H", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("I", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("N", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("G", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(")", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(Environment.NewLine, false, 0, Guid.NewGuid().ToString()) { },
|
||||
new VobSubOcr.CompareMatch("-", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("(", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("B", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("Y", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("E", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(" ", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("B", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("Y", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch("E", false, 0, Guid.NewGuid().ToString()),
|
||||
new VobSubOcr.CompareMatch(")", false, 0, Guid.NewGuid().ToString()),
|
||||
};
|
||||
|
||||
var result = MatchesToItalicStringConverter.GetStringWithItalicTags(matches);
|
||||
Assert.AreEqual("-(LAUGHING)" + Environment.NewLine + "-(BYE BYE)", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestItalicAndBrackets()
|
||||
{
|
||||
|
@ -194,9 +194,17 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
{
|
||||
var result = new List<SplitItem>();
|
||||
var line = new List<VobSubOcr.CompareMatch>();
|
||||
var skipNext = false;
|
||||
|
||||
foreach (var t in matches)
|
||||
for (var index = 0; index < matches.Count; index++)
|
||||
{
|
||||
var t = matches[index];
|
||||
if (skipNext)
|
||||
{
|
||||
skipNext = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t.Text == Environment.NewLine)
|
||||
{
|
||||
if (line.Count > 0)
|
||||
@ -210,8 +218,16 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
if (line.Count > 0)
|
||||
{
|
||||
line.Add(t);
|
||||
if (index < matches.Count - 1 && matches[index + 1].Text == Environment.NewLine)
|
||||
{
|
||||
result.Add(new SplitItem { Matches = line, Separator = Environment.NewLine });
|
||||
skipNext = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(new SplitItem { Matches = line, Separator = string.Empty });
|
||||
}
|
||||
|
||||
result.Add(new SplitItem { Matches = line, Separator = string.Empty });
|
||||
line = new List<VobSubOcr.CompareMatch>();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user