mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
parent
a396e61fda
commit
69611bbc8f
@ -403,6 +403,22 @@ namespace Test.Core
|
||||
Assert.AreEqual("<i>How Are You?</i>", res);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ToLowercaseButKeepTags1()
|
||||
{
|
||||
var input = "<i>HOW ARE YOU?</i>";
|
||||
var res = input.ToLowercaseButKeepTags();
|
||||
Assert.AreEqual("<i>how are you?</i>", res);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ToLowercaseButKeepTags2()
|
||||
{
|
||||
var input = "{\\c&H0000FF&}Red";
|
||||
var res = input.ToLowercaseButKeepTags();
|
||||
Assert.AreEqual("{\\c&H0000FF&}red", res);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HasSentenceEndingCultureNeutralTest()
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
var text = original;
|
||||
if (FixNormal)
|
||||
{
|
||||
if (FixNormalOnlyAllUppercase && text != text.ToUpper(subtitleCulture))
|
||||
if (FixNormalOnlyAllUppercase && HtmlUtil.RemoveHtmlTags(text, true) != HtmlUtil.RemoveHtmlTags(text, true).ToUpper(subtitleCulture))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
@ -258,7 +258,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
if (text.Length > 1)
|
||||
{
|
||||
// first all to lower
|
||||
text = text.ToLower(subtitleCulture).Trim();
|
||||
text = text.ToLowercaseButKeepTags().Trim();
|
||||
text = text.FixExtraSpaces();
|
||||
var st = new StrippableText(text);
|
||||
st.FixCasing(nameList, false, true, true, lastLine, millisecondsFromLast); // fix all casing but names (that's a separate option)
|
||||
|
@ -500,6 +500,19 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return RestoreSavedTags(properCaseText, tags);
|
||||
}
|
||||
|
||||
public static string ToLowercaseButKeepTags(this string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var tags = RemoveAndSaveTags(input, sb, new SubRip());
|
||||
var lowercaseText = sb.ToString().ToLowerInvariant();
|
||||
return RestoreSavedTags(lowercaseText, tags);
|
||||
}
|
||||
|
||||
public static string ToggleCasing(this string input, SubtitleFormat format, string overrideFromStringInit = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
|
Loading…
Reference in New Issue
Block a user