SubtitleEdit/libse/NetflixQualityCheck/NetflixCheckItalics.cs
2017-03-25 12:11:58 +01:00

41 lines
1.5 KiB
C#

using System;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
public class NetflixCheckItalics : INetflixQualityChecker
{
public void Check(Subtitle subtitle, NetflixQualityController controller)
{
foreach (Paragraph p in subtitle.Paragraphs)
{
if (p.Text.Contains("i>", StringComparison.OrdinalIgnoreCase))
{
if (controller.AllowItalics)
{
var fixedParagraph = new Paragraph(p, false);
fixedParagraph.Text = HtmlUtil.FixInvalidItalicTags(fixedParagraph.Text);
if (fixedParagraph.Text != p.Text)
{
string comment = "Fixed italics";
controller.AddRecord(p, fixedParagraph, comment);
}
}
else
{
var fixedParagraph = new Paragraph(p, false);
fixedParagraph.Text = HtmlUtil.RemoveHtmlTags(fixedParagraph.Text);
if (fixedParagraph.Text != p.Text)
{
string comment = "Italics not allowed";
controller.AddRecord(p, fixedParagraph, comment);
}
}
}
}
}
}
}