mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Add some handling of font tags in split - thx Peter :)
This commit is contained in:
parent
cd819f2a21
commit
b5a31a7f72
@ -9870,6 +9870,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
FixSplitFontTag(currentParagraph, newParagraph);
|
||||
SetSplitTime(splitSeconds, currentParagraph, newParagraph, oldText);
|
||||
|
||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
@ -10050,6 +10051,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
|
||||
_subtitleAlternate.Renumber();
|
||||
FixSplitFontTag(originalCurrent, originalNew);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10075,6 +10077,36 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void FixSplitFontTag(Paragraph currentParagraph, Paragraph nextParagraph)
|
||||
{
|
||||
if (currentParagraph == null || nextParagraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var startIdx = currentParagraph.Text.LastIndexOf("<font ", StringComparison.OrdinalIgnoreCase);
|
||||
if (startIdx >= 0 &&
|
||||
!currentParagraph.Text.Contains("</font>", StringComparison.OrdinalIgnoreCase) &&
|
||||
nextParagraph.Text.Contains("</font>", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var endIdx = currentParagraph.Text.IndexOf('>', startIdx);
|
||||
if (endIdx >= 0)
|
||||
{
|
||||
var fontTag = currentParagraph.Text.Substring(startIdx, endIdx - startIdx + 1);
|
||||
var pre = string.Empty;
|
||||
if (currentParagraph.Text.StartsWith('{') && currentParagraph.Text.IndexOf('}') > 0)
|
||||
{
|
||||
var i = currentParagraph.Text.IndexOf('}');
|
||||
pre = currentParagraph.Text.Substring(0, i + 1);
|
||||
currentParagraph.Text = currentParagraph.Text.Remove(0, i + 1);
|
||||
}
|
||||
|
||||
currentParagraph.Text = pre + currentParagraph.Text + "</font>";
|
||||
nextParagraph.Text = pre + fontTag + nextParagraph.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSplitTime(double? splitSeconds, Paragraph currentParagraph, Paragraph newParagraph, string oldText)
|
||||
{
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds / 2);
|
||||
|
Loading…
Reference in New Issue
Block a user