mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-24 12:12:41 +01:00
Merge pull request #8947 from ivandrofly/feature/hyphen
Standardize hyphen character handling in RemoveDialogFirstLineInNonDialogs ✨
This commit is contained in:
commit
d2915f8221
@ -14,6 +14,8 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
|||||||
{
|
{
|
||||||
var fixAction = Language.RemoveDialogFirstInNonDialogs;
|
var fixAction = Language.RemoveDialogFirstInNonDialogs;
|
||||||
var noOfFixes = 0;
|
var noOfFixes = 0;
|
||||||
|
const char hyphenMinus = '-'; // Hyphen-Minus (-, U+002D)
|
||||||
|
const char hyphen = '‐'; // Hyphen (‐, U+2010)
|
||||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||||
{
|
{
|
||||||
var p = subtitle.Paragraphs[i];
|
var p = subtitle.Paragraphs[i];
|
||||||
@ -22,15 +24,15 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
|
|||||||
var noHtml = HtmlUtil.RemoveHtmlTags(text, true).TrimStart();
|
var noHtml = HtmlUtil.RemoveHtmlTags(text, true).TrimStart();
|
||||||
|
|
||||||
|
|
||||||
var count = Utilities.CountTagInText(text, '-') + Utilities.CountTagInText(text, '‐');
|
var count = Utilities.CountTagInText(text, hyphenMinus) + Utilities.CountTagInText(text, hyphen);
|
||||||
if (count == 0 || !noHtml.StartsWith('-') && !noHtml.StartsWith('‐'))
|
if (count == 0 || !noHtml.StartsWith(hyphenMinus) && !noHtml.StartsWith(hyphen))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the two different dashes
|
// test the two different dashes
|
||||||
text = RemoveDash(text, noHtml, '-');
|
text = RemoveDash(text, noHtml, hyphenMinus);
|
||||||
text = RemoveDash(text, noHtml, '‐');
|
text = RemoveDash(text, noHtml, hyphen);
|
||||||
|
|
||||||
if (oldText != text && callbacks.AllowFix(p, fixAction))
|
if (oldText != text && callbacks.AllowFix(p, fixAction))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user