mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
parent
2e8bb4b613
commit
a98952a307
@ -1206,6 +1206,13 @@ namespace Nikse.SubtitleEdit.Core
|
||||
s2 = s2.Remove(0, 3);
|
||||
}
|
||||
|
||||
bool startsWithBold = false;
|
||||
if (s2.StartsWith("<b>", StringComparison.Ordinal))
|
||||
{
|
||||
startsWithBold = true;
|
||||
s2 = s2.Remove(0, 3);
|
||||
}
|
||||
|
||||
var startFontTag = string.Empty;
|
||||
if (s2.StartsWith("<font ", StringComparison.Ordinal) && s2.IndexOf('>') > 0)
|
||||
{
|
||||
@ -1222,6 +1229,13 @@ namespace Nikse.SubtitleEdit.Core
|
||||
s2 = s2.Remove(s2.Length - endFontTag.Length);
|
||||
}
|
||||
|
||||
bool endsWithBold = false;
|
||||
if (s2.EndsWith("</b>", StringComparison.Ordinal))
|
||||
{
|
||||
endsWithBold = true;
|
||||
s2 = s2.Remove(s2.Length - 4, 4);
|
||||
}
|
||||
|
||||
bool endsWithItalic = false;
|
||||
if (s2.EndsWith("</i>", StringComparison.Ordinal))
|
||||
{
|
||||
@ -1247,11 +1261,15 @@ namespace Nikse.SubtitleEdit.Core
|
||||
newLines.Append(assTag);
|
||||
if (startsWithItalic)
|
||||
newLines.Append("<i>");
|
||||
if (startsWithBold)
|
||||
newLines.Append("<b>");
|
||||
newLines.Append(startFontTag);
|
||||
newLines.Append(ReverseParenthesis(post.ToString()));
|
||||
newLines.Append(s2.Substring(pre.Length, s2.Length - (pre.Length + post.Length)));
|
||||
newLines.Append(ReverseParenthesis(ReverseString(pre.ToString())));
|
||||
newLines.Append(endFontTag);
|
||||
if (endsWithBold)
|
||||
newLines.Append("</b>");
|
||||
if (endsWithItalic)
|
||||
newLines.Append("</i>");
|
||||
newLines.AppendLine();
|
||||
|
@ -541,5 +541,12 @@ namespace Test.Logic
|
||||
"<i>.I have a big head-</i>" + Environment.NewLine + "<font color='red'>?So do I~</font>" + Environment.NewLine + "!I do too+");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ReverseStartAndEndingForRightToLeft8BoldTag()
|
||||
{
|
||||
Assert.AreEqual(Utilities.ReverseStartAndEndingForRightToLeft("<b>-I have a big head.</b>" + Environment.NewLine + "<font color='red'>~So do I?</font>" + Environment.NewLine + "+I do too!"),
|
||||
"<b>.I have a big head-</b>" + Environment.NewLine + "<font color='red'>?So do I~</font>" + Environment.NewLine + "!I do too+");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user