diff --git a/Common/BBCodes/Quote.cs b/Common/BBCodes/Quote.cs index ced7d04..05af91b 100644 --- a/Common/BBCodes/Quote.cs +++ b/Common/BBCodes/Quote.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using FLocal.Core; using PJonDevelopment.BBCode; namespace FLocal.Common.BBCodes { @@ -12,9 +13,11 @@ namespace FLocal.Common.BBCodes { } public override string Format(ITextFormatter formatter) { + string inner = this.GetInnerHTML(formatter).TrimHtml(); + if(inner == "") return ""; string marker = this.Default; if(marker == null) marker = "Quote:"; - return "
" + marker + "
" + this.GetInnerHTML(formatter).Trim() + "


"; + return "
" + marker + "
" + inner + "


"; } } diff --git a/Core/extensions/String.cs b/Core/extensions/String.cs index 3a90931..0411e19 100644 --- a/Core/extensions/String.cs +++ b/Core/extensions/String.cs @@ -49,5 +49,23 @@ namespace FLocal.Core { return str.ToLower().Contains(from needle in needles select needle.ToLower()); } + private static readonly string[] TrimHtml_EmptyFragments = new string[] { + "
", + "
", + " ", + }; + public static string TrimHtml(this string str) { + string result = str.Trim(); + foreach(var fragment in TrimHtml_EmptyFragments) { + if(result.StartsWith(fragment)) { + return result.Substring(fragment.Length).TrimHtml(); + } + if(result.EndsWith(fragment)) { + return result.Substring(0, result.Length-fragment.Length).TrimHtml(); + } + } + return result; + } + } }