More assa style toggle

This commit is contained in:
Nikolaj Olsson 2021-06-14 21:06:25 +02:00
parent 16ad65a01a
commit 3b656f81aa

View File

@ -892,25 +892,31 @@ namespace Nikse.SubtitleEdit.Core.Common
if (assa)
{
var onOffTags = new List<string> { "i", "b", "u", "s", "be" };
if (wholeLine)
if (onOffTags.Contains(tag))
{
onOffTags.Clear();
}
if (text.Contains("\\" + tag))
{
if (onOffTags.Contains(tag))
if (text.Contains($"\\{tag}1"))
{
text = text.Replace($"{{\\{tag}1}}", string.Empty);
text = text.Replace($"{{\\{tag}0}}", string.Empty);
text = text.Replace($"\\{tag}1", string.Empty);
text = text.Replace($"\\{tag}0", string.Empty);
}
else
{
text = wholeLine ? $"{{\\{tag}1}}{text}" : $"{{\\{tag}1}}{text}{{\\{tag}0}}";
}
text = text.Replace($"{{\\{tag}1}}", string.Empty);
text = text.Replace($"\\{tag}1", string.Empty);
}
else
{
text = onOffTags.Contains(tag) || !wholeLine ? $"{{\\{tag}1}}{text}{{\\{tag}0}}" : $"{{\\{tag}1}}{text}";
if (text.Contains($"\\{tag}"))
{
text = text.Replace($"{{\\{tag}}}", string.Empty);
text = text.Replace($"\\{tag}", string.Empty);
}
else
{
text = $"{{\\{tag}}}{text}";
}
}
return text;