From 6026ab69899350804da71a76870ea02ec9bfba70 Mon Sep 17 00:00:00 2001 From: niksedk Date: Mon, 21 Jun 2021 15:34:50 +0200 Subject: [PATCH] Fix for auto br line / French - thx Norbert :) --- src/Test/Logic/UtilitiesTest.cs | 13 +++++++++++-- src/libse/Common/Utilities.cs | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Test/Logic/UtilitiesTest.cs b/src/Test/Logic/UtilitiesTest.cs index 8d690453c..35aed24a8 100644 --- a/src/Test/Logic/UtilitiesTest.cs +++ b/src/Test/Logic/UtilitiesTest.cs @@ -64,6 +64,15 @@ namespace Test.Logic Assert.AreEqual(s1, s2); } + [TestMethod] + public void AutoBreakFrenchSpaceBeforePunctuation() + { + Configuration.Settings.General.SubtitleLineMaximumLength = 43; + string s1 = "Et elle te le dis maintenant ? Pour quoi donc ?"; + string s2 = Utilities.AutoBreakLine(s1, "fr"); + Assert.AreEqual("Et elle te le dis maintenant ?" + Environment.NewLine + "Pour quoi donc ?", s2); + } + [TestMethod] public void AutoBreakLine5DoNoBreakAtTwoMusicTaggedLines() { @@ -443,7 +452,7 @@ namespace Test.Logic { var s1 = ""; string s2 = HtmlUtil.FixInvalidItalicTags(s1); - Assert.AreEqual( "Hallo!", s2); + Assert.AreEqual("Hallo!", s2); } [TestMethod] @@ -717,7 +726,7 @@ namespace Test.Logic public void RemoveLineBreaks5() { string result = Utilities.RemoveLineBreaks("Foobar" + Environment.NewLine + ""); - Assert.AreEqual( "Foobar", result); + Assert.AreEqual("Foobar", result); } [TestMethod] diff --git a/src/libse/Common/Utilities.cs b/src/libse/Common/Utilities.cs index 04f620d52..0f738a6af 100644 --- a/src/libse/Common/Utilities.cs +++ b/src/libse/Common/Utilities.cs @@ -248,6 +248,15 @@ namespace Nikse.SubtitleEdit.Core.Common return false; } + if (nextChar == ' ' && language == "fr" && index + 1 < s.Length) + { + var nextNext = s[index + 1]; + if (nextNext == '?' || nextNext == '!' || nextNext == '.') + { + return false; + } + } + return true; }