mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Fix FCE remove dash single line - thx Ding-adong :)
Related to comment in #3416 comment https://github.com/SubtitleEdit/subtitleedit/issues/3416#issuecomment-587035108
This commit is contained in:
parent
69649a0ee8
commit
3d3443dce4
@ -12,10 +12,10 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
var p = subtitle.Paragraphs[i];
|
||||
if (p.Text.SplitToLines().Count == 1 && callbacks.AllowFix(p, fixAction))
|
||||
if (Helper.IsOneSentence(p.Text) && callbacks.AllowFix(p, fixAction))
|
||||
{
|
||||
string oldText = p.Text;
|
||||
string text = Helper.FixHyphensRemoveForSingleLine(subtitle, p.Text, i);
|
||||
string text = Helper.FixHyphensRemoveForSingleLine(subtitle, p.Text, i);
|
||||
if (text != oldText)
|
||||
{
|
||||
p.Text = text;
|
||||
|
@ -275,9 +275,25 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
||||
return isPrevEndOfLine;
|
||||
}
|
||||
|
||||
public static bool IsOneSentence(string text)
|
||||
{
|
||||
var lines = HtmlUtil.RemoveHtmlTags(text).SplitToLines();
|
||||
if (lines.Count == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lines.Count > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !lines[0].HasSentenceEnding();
|
||||
}
|
||||
|
||||
public static string FixHyphensRemoveForSingleLine(Subtitle subtitle, string input, int i)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input) || input.SplitToLines().Count != 1)
|
||||
if (string.IsNullOrEmpty(input) || !IsOneSentence(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
|
||||
var last = s[s.Length - 1];
|
||||
return last == '.' || last == '!' || last == '?' || last == ']' || last == '…';
|
||||
return last == '.' || last == '!' || last == '?' || last == ']' || last == '…' || last == '♪' || last == '؟';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user