Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ============================== old
- if (lines.Count == 1 && text != oldText && Utilities.GetNumberOfLines(oldText) == 2)
- ============================== new
- private static bool ContainsPunctuationFollowedByNewLine(string text)
- {
- string[] punctuations = new[] { ".", ".</i>", "!", "!</i>", "?", "?</i>" };
- return punctuations.Any(punct => oldText.Contains(punct + Environment.NewLine));
- }
- public void SomeMethod()
- {
- if (lines.Count == 1 && text != oldText && Utilities.GetNumberOfLines(oldText) == 2)
- {
- string[] startPatterns = new[] { "-", "<i>-"};
- string[] lineBreakPatterns = new[] { Environment.NewLine + "-", Environment.NewLine + "<i>-" };
- if ((startPatterns.Any(pattern => oldText.StartsWith(pattern, StringComparison.Ordinal)) ||
- lineBreakPatterns.Any(pattern => oldText.Contains(pattern))) &&
- ContainsPunctuationFollowedByNewLine(oldText))
- {
- if (text.StartsWith("<i>-", StringComparison.Ordinal))
- {
- text = "<i>" + text.Remove(0, 4).TrimStart();
- }
- else
- {
- text = text.TrimStart('-').TrimStart();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement