Empty quotes are skipped in UBBParser

main
Inga 🏳‍🌈 14 years ago
parent 0d47aa4086
commit 2c0dfd5bfb
  1. 5
      Common/BBCodes/Quote.cs
  2. 18
      Core/extensions/String.cs

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using FLocal.Core;
using PJonDevelopment.BBCode; using PJonDevelopment.BBCode;
namespace FLocal.Common.BBCodes { namespace FLocal.Common.BBCodes {
@ -12,9 +13,11 @@ namespace FLocal.Common.BBCodes {
} }
public override string Format(ITextFormatter formatter) { public override string Format(ITextFormatter formatter) {
string inner = this.GetInnerHTML(formatter).TrimHtml();
if(inner == "") return "";
string marker = this.Default; string marker = this.Default;
if(marker == null) marker = "Quote:"; if(marker == null) marker = "Quote:";
return "<br/><blockquote><font class=\"small\">" + marker + "</font><hr/>" + this.GetInnerHTML(formatter).Trim() + "<br/><hr/></blockquote><br/>"; return "<br/><blockquote><font class=\"small\">" + marker + "</font><hr/>" + inner + "<br/><hr/></blockquote><br/>";
} }
} }

@ -49,5 +49,23 @@ namespace FLocal.Core {
return str.ToLower().Contains(from needle in needles select needle.ToLower()); return str.ToLower().Contains(from needle in needles select needle.ToLower());
} }
private static readonly string[] TrimHtml_EmptyFragments = new string[] {
"<br/>",
"<br />",
"&nbsp;",
};
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;
}
} }
} }

Loading…
Cancel
Save