mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Minor refact + minor update of text
This commit is contained in:
parent
117e92ab0b
commit
9fba87b9bc
@ -666,5 +666,27 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return text;
|
||||
}
|
||||
|
||||
public static string ToogleTag(string text, string tag)
|
||||
{
|
||||
if (text.Contains("<" + tag + ">"))
|
||||
{
|
||||
text = text.Replace("<" + tag + ">", string.Empty);
|
||||
text = text.Replace("</" + tag + ">", string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOfEndBracket = text.IndexOf('}');
|
||||
if (text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6)
|
||||
{
|
||||
text = string.Format("{2}<{0}>{1}</{0}>", tag, text.Remove(0, indexOfEndBracket + 1), text.Substring(0, indexOfEndBracket + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
text = string.Format("<{0}>{1}</{0}>", tag, text);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1440,7 +1440,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
MergeSelectedLinesAsDialog = "Merge selected lines as dialog",
|
||||
MergeWithLineBefore = "Merge with line before",
|
||||
MergeWithLineAfter = "Merge with line after",
|
||||
Normal = "Normal",
|
||||
Normal = "Normal (remove formatting)",
|
||||
Underline = "Underline",
|
||||
Color = "Color...",
|
||||
FontName = "Font name...",
|
||||
|
@ -6082,36 +6082,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
if (original.Text.Contains("<" + tag + ">"))
|
||||
{
|
||||
original.Text = original.Text.Replace("<" + tag + ">", string.Empty);
|
||||
original.Text = original.Text.Replace("</" + tag + ">", string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOfEndBracket = original.Text.IndexOf('}');
|
||||
if (original.Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6)
|
||||
original.Text = string.Format("{2}<{0}>{1}</{0}>", tag, original.Text.Remove(0, indexOfEndBracket + 1), original.Text.Substring(0, indexOfEndBracket + 1));
|
||||
else
|
||||
original.Text = string.Format("<{0}>{1}</{0}>", tag, original.Text);
|
||||
}
|
||||
original.Text = HtmlUtil.ToogleTag(original.Text, tag);
|
||||
SubtitleListview1.SetAlternateText(i, original.Text);
|
||||
}
|
||||
}
|
||||
|
||||
if (_subtitle.Paragraphs[i].Text.Contains("<" + tag + ">"))
|
||||
{
|
||||
_subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + tag + ">", string.Empty);
|
||||
_subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("</" + tag + ">", string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
int indexOfEndBracket = _subtitle.Paragraphs[i].Text.IndexOf('}');
|
||||
if (_subtitle.Paragraphs[i].Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6)
|
||||
_subtitle.Paragraphs[i].Text = string.Format("{2}<{0}>{1}</{0}>", tag, _subtitle.Paragraphs[i].Text.Remove(0, indexOfEndBracket + 1), _subtitle.Paragraphs[i].Text.Substring(0, indexOfEndBracket + 1));
|
||||
else
|
||||
_subtitle.Paragraphs[i].Text = string.Format("<{0}>{1}</{0}>", tag, _subtitle.Paragraphs[i].Text);
|
||||
}
|
||||
_subtitle.Paragraphs[i].Text = HtmlUtil.ToogleTag(_subtitle.Paragraphs[i].Text, tag);
|
||||
SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text);
|
||||
}
|
||||
SubtitleListview1.EndUpdate();
|
||||
|
Loading…
Reference in New Issue
Block a user