From 9847264000109da13cf72ef34ed4949dcae707cc Mon Sep 17 00:00:00 2001
From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Fri, 20 Apr 2012 21:57:08 +0400
Subject: [PATCH] PJonDevelopment refactored to use generic context
---
FLocal.Common/BBCodes/AbstractLocalLink.cs | 4 +-
FLocal.Common/BBCodes/B.cs | 4 +-
FLocal.Common/BBCodes/Code.cs | 2 +-
FLocal.Common/BBCodes/ECode.cs | 4 +-
FLocal.Common/BBCodes/FUrl.cs | 4 +-
FLocal.Common/BBCodes/Font.cs | 4 +-
FLocal.Common/BBCodes/FontColor.cs | 4 +-
FLocal.Common/BBCodes/FontSize.cs | 4 +-
FLocal.Common/BBCodes/Google.cs | 4 +-
FLocal.Common/BBCodes/I.cs | 4 +-
FLocal.Common/BBCodes/Image.cs | 2 +-
FLocal.Common/BBCodes/List.cs | 4 +-
FLocal.Common/BBCodes/ListElem.cs | 2 +-
FLocal.Common/BBCodes/Lurk.cs | 4 +-
FLocal.Common/BBCodes/Math.cs | 2 +-
FLocal.Common/BBCodes/Quote.cs | 4 +-
FLocal.Common/BBCodes/QuoteSkipper.cs | 4 +-
FLocal.Common/BBCodes/RuWiki.cs | 4 +-
FLocal.Common/BBCodes/S.cs | 4 +-
FLocal.Common/BBCodes/Spoiler.cs | 4 +-
FLocal.Common/BBCodes/Tex.cs | 2 +-
FLocal.Common/BBCodes/U.cs | 4 +-
FLocal.Common/BBCodes/UploadImage.cs | 2 +-
FLocal.Common/BBCodes/UploadLink.cs | 4 +-
FLocal.Common/BBCodes/Url.cs | 4 +-
FLocal.Common/BBCodes/User.cs | 2 +-
FLocal.Common/BBCodes/Wiki.cs | 4 +-
FLocal.Common/BBCodes/helpers/BBCode.cs | 7 +-
.../BBCodes/helpers/IPostParsingContext.cs | 10 +
FLocal.Common/FLocal.Common.csproj | 2 +
FLocal.Common/UBBParser.cs | 24 +-
FLocal.Common/dataobjects/User.cs | 36 +-
.../helpers/DelegatePostParsingContext.cs | 11 +
.../handlers/response/UserRepliesHandler.cs | 2 +-
.../Classes/BBCodeConfiguration.vb | 244 +++---
.../Classes/BBCodeDocument.vb | 128 +--
.../Classes/BBCodeElement.vb | 436 +++++-----
.../Classes/BBCodeElementFactory.vb | 136 ++--
.../Classes/BBCodeElementTypeDictionary.vb | 180 ++---
.../Classes/BBCodeNode.vb | 136 ++--
.../Classes/BBCodeNodeCollection.vb | 130 +--
.../Classes/BBCodeParser.vb | 598 +++++++-------
.../Classes/BBCodeText.vb | 102 +--
.../PJonDevelopment.BBCode/Modules/Utils.vb | 746 +++++++++---------
44 files changed, 1515 insertions(+), 1507 deletions(-)
create mode 100644 FLocal.Common/BBCodes/helpers/IPostParsingContext.cs
create mode 100644 FLocal.Common/helpers/DelegatePostParsingContext.cs
diff --git a/FLocal.Common/BBCodes/AbstractLocalLink.cs b/FLocal.Common/BBCodes/AbstractLocalLink.cs
index fd2810c..36420f1 100644
--- a/FLocal.Common/BBCodes/AbstractLocalLink.cs
+++ b/FLocal.Common/BBCodes/AbstractLocalLink.cs
@@ -16,11 +16,11 @@ namespace FLocal.Common.BBCodes {
get;
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var url = this.url;
var name = this.Safe(url.title);
if(this.Default != null) {
- name = this.GetInnerHTML(formatter);
+ name = this.GetInnerHTML(context, formatter);
}
return string.Format("{1}", url.canonical, url.title);
}
diff --git a/FLocal.Common/BBCodes/B.cs b/FLocal.Common/BBCodes/B.cs
index 5197f1c..0af8e1f 100644
--- a/FLocal.Common/BBCodes/B.cs
+++ b/FLocal.Common/BBCodes/B.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("b") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/Code.cs b/FLocal.Common/BBCodes/Code.cs
index 02115ec..43aa8bb 100644
--- a/FLocal.Common/BBCodes/Code.cs
+++ b/FLocal.Common/BBCodes/Code.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("code") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
return "
" + System.Web.HttpUtility.HtmlEncode(this.InnerBBCode) + "
";
}
diff --git a/FLocal.Common/BBCodes/ECode.cs b/FLocal.Common/BBCodes/ECode.cs
index db8de6c..0e2bf95 100644
--- a/FLocal.Common/BBCodes/ECode.cs
+++ b/FLocal.Common/BBCodes/ECode.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("ecode") {
}
- public override string Format(ITextFormatter formatter) {
- return this.GetInnerHTML(new BBCodeHtmlFormatter());
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return this.GetInnerHTML(context, new BBCodeHtmlFormatter());
}
}
diff --git a/FLocal.Common/BBCodes/FUrl.cs b/FLocal.Common/BBCodes/FUrl.cs
index dd77367..d96fe59 100644
--- a/FLocal.Common/BBCodes/FUrl.cs
+++ b/FLocal.Common/BBCodes/FUrl.cs
@@ -11,11 +11,11 @@ namespace FLocal.Common.BBCodes {
: base("furl") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
string rawUrl = this.DefaultOrValue;
string title = null;
if(rawUrl.ToLower() != this.InnerText.ToLower()) {
- title = this.GetInnerHTML(formatter);
+ title = this.GetInnerHTML(context, formatter);
}
return UrlProcessor.ProcessLink(rawUrl, title, false);
}
diff --git a/FLocal.Common/BBCodes/Font.cs b/FLocal.Common/BBCodes/Font.cs
index 4cf6cfc..31336d0 100644
--- a/FLocal.Common/BBCodes/Font.cs
+++ b/FLocal.Common/BBCodes/Font.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("font") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/FontColor.cs b/FLocal.Common/BBCodes/FontColor.cs
index 8031296..7d11d08 100644
--- a/FLocal.Common/BBCodes/FontColor.cs
+++ b/FLocal.Common/BBCodes/FontColor.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("color") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/FontSize.cs b/FLocal.Common/BBCodes/FontSize.cs
index dec1ecb..498b023 100644
--- a/FLocal.Common/BBCodes/FontSize.cs
+++ b/FLocal.Common/BBCodes/FontSize.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("size") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/Google.cs b/FLocal.Common/BBCodes/Google.cs
index 10867ec..65fc817 100644
--- a/FLocal.Common/BBCodes/Google.cs
+++ b/FLocal.Common/BBCodes/Google.cs
@@ -12,8 +12,8 @@ namespace FLocal.Common.BBCodes {
: base("google") {
}
- public override string Format(ITextFormatter formatter) {
- return "g:" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "g:" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/I.cs b/FLocal.Common/BBCodes/I.cs
index 2241b5b..1c3a422 100644
--- a/FLocal.Common/BBCodes/I.cs
+++ b/FLocal.Common/BBCodes/I.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("i") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/Image.cs b/FLocal.Common/BBCodes/Image.cs
index fc0562c..b7ddea5 100644
--- a/FLocal.Common/BBCodes/Image.cs
+++ b/FLocal.Common/BBCodes/Image.cs
@@ -10,7 +10,7 @@ namespace FLocal.Common.BBCodes {
public Image() : base("image") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var urlInfo = UrlProcessor.Process(this.InnerText);
if (urlInfo.isLocal && urlInfo.relativeUrl.StartsWith("/user/upload/")) {
return "" + urlInfo.relativeUrl + "" + urlInfo.relativeUrl + "";
diff --git a/FLocal.Common/BBCodes/List.cs b/FLocal.Common/BBCodes/List.cs
index c59ec03..33c2dad 100644
--- a/FLocal.Common/BBCodes/List.cs
+++ b/FLocal.Common/BBCodes/List.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("list") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "
";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "
";
}
}
diff --git a/FLocal.Common/BBCodes/ListElem.cs b/FLocal.Common/BBCodes/ListElem.cs
index 6e6f670..f0558a8 100644
--- a/FLocal.Common/BBCodes/ListElem.cs
+++ b/FLocal.Common/BBCodes/ListElem.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("*") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
// return "" + this.GetInnerHTML(formatter) + "";
return "";
}
diff --git a/FLocal.Common/BBCodes/Lurk.cs b/FLocal.Common/BBCodes/Lurk.cs
index 6a9b17e..94014db 100644
--- a/FLocal.Common/BBCodes/Lurk.cs
+++ b/FLocal.Common/BBCodes/Lurk.cs
@@ -12,8 +12,8 @@ namespace FLocal.Common.BBCodes {
: base("lurk") {
}
- public override string Format(ITextFormatter formatter) {
- return "l:" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "l:" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/Math.cs b/FLocal.Common/BBCodes/Math.cs
index 9eef691..a87ccea 100644
--- a/FLocal.Common/BBCodes/Math.cs
+++ b/FLocal.Common/BBCodes/Math.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("math") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
string tex = "$$" + this.InnerBBCode + "$$";
var upload = helpers.TexProcessor.getCompiled(tex);
return "/Upload/Item/" + upload.id.ToString() + "/" + this.Safe(tex) + "";
diff --git a/FLocal.Common/BBCodes/Quote.cs b/FLocal.Common/BBCodes/Quote.cs
index ed0f2fe..4edd138 100644
--- a/FLocal.Common/BBCodes/Quote.cs
+++ b/FLocal.Common/BBCodes/Quote.cs
@@ -12,8 +12,8 @@ namespace FLocal.Common.BBCodes {
: base("quote") {
}
- public override string Format(ITextFormatter formatter) {
- string inner = this.GetInnerHTML(formatter).TrimHtml();
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ string inner = this.GetInnerHTML(context, formatter).TrimHtml();
if(inner == "") return "";
string marker = this.Default;
if(marker == null) marker = "Quote:";
diff --git a/FLocal.Common/BBCodes/QuoteSkipper.cs b/FLocal.Common/BBCodes/QuoteSkipper.cs
index 84f9b4c..9666396 100644
--- a/FLocal.Common/BBCodes/QuoteSkipper.cs
+++ b/FLocal.Common/BBCodes/QuoteSkipper.cs
@@ -10,7 +10,7 @@ namespace FLocal.Common.BBCodes {
public QuoteSkipper() : base("quoteskipper") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
if(this.Name.ToLower() == "q" || this.Name.ToLower() == "quote") {
return "";
} else if(this.Name.ToLower() == "code") {
@@ -36,7 +36,7 @@ namespace FLocal.Common.BBCodes {
}
sb.Append("]");
if(this.RequireClosingTag) {
- sb.Append(this.GetInnerHTML(formatter));
+ sb.Append(this.GetInnerHTML(context, formatter));
sb.Append("[/");
sb.Append(name);
sb.Append("]");
diff --git a/FLocal.Common/BBCodes/RuWiki.cs b/FLocal.Common/BBCodes/RuWiki.cs
index 2bcc644..bbd6ae9 100644
--- a/FLocal.Common/BBCodes/RuWiki.cs
+++ b/FLocal.Common/BBCodes/RuWiki.cs
@@ -12,8 +12,8 @@ namespace FLocal.Common.BBCodes {
: base("ruwiki") {
}
- public override string Format(ITextFormatter formatter) {
- return "в:" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "в:" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/S.cs b/FLocal.Common/BBCodes/S.cs
index 76796cb..6753de1 100644
--- a/FLocal.Common/BBCodes/S.cs
+++ b/FLocal.Common/BBCodes/S.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("s") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/Spoiler.cs b/FLocal.Common/BBCodes/Spoiler.cs
index 68519d7..67b1afa 100644
--- a/FLocal.Common/BBCodes/Spoiler.cs
+++ b/FLocal.Common/BBCodes/Spoiler.cs
@@ -11,10 +11,10 @@ namespace FLocal.Common.BBCodes {
: base("spoiler") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
string marker = this.Default;
if(marker == null) marker = "Spoiler";
- return "" + marker + "
" + this.GetInnerHTML(formatter).Trim() + "
";
+ return "" + marker + "
" + this.GetInnerHTML(context, formatter).Trim() + "
";
}
}
diff --git a/FLocal.Common/BBCodes/Tex.cs b/FLocal.Common/BBCodes/Tex.cs
index 2a94843..001f229 100644
--- a/FLocal.Common/BBCodes/Tex.cs
+++ b/FLocal.Common/BBCodes/Tex.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("tex") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
string tex = this.InnerBBCode;
var upload = helpers.TexProcessor.getCompiled(tex);
return "/Upload/Item/" + upload.id.ToString() + "/" + this.Safe(tex) + "";
diff --git a/FLocal.Common/BBCodes/U.cs b/FLocal.Common/BBCodes/U.cs
index 8548211..505f4e9 100644
--- a/FLocal.Common/BBCodes/U.cs
+++ b/FLocal.Common/BBCodes/U.cs
@@ -11,8 +11,8 @@ namespace FLocal.Common.BBCodes {
: base("u") {
}
- public override string Format(ITextFormatter formatter) {
- return "" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/UploadImage.cs b/FLocal.Common/BBCodes/UploadImage.cs
index 5688dcd..425ae71 100644
--- a/FLocal.Common/BBCodes/UploadImage.cs
+++ b/FLocal.Common/BBCodes/UploadImage.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("uploadimage") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var upload = dataobjects.Upload.LoadById(int.Parse(this.InnerText));
var name = upload.filename;
return "/Upload/Item/" + upload.id.ToString() + "/" + this.Safe(upload.filename) + "";
diff --git a/FLocal.Common/BBCodes/UploadLink.cs b/FLocal.Common/BBCodes/UploadLink.cs
index cb2feaf..81c3125 100644
--- a/FLocal.Common/BBCodes/UploadLink.cs
+++ b/FLocal.Common/BBCodes/UploadLink.cs
@@ -11,11 +11,11 @@ namespace FLocal.Common.BBCodes {
: base("uploadlink") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var upload = dataobjects.Upload.LoadById(int.Parse(this.DefaultOrValue));
var name = this.Safe(upload.filename);
if(this.Default != null) {
- name = this.GetInnerHTML(formatter);
+ name = this.GetInnerHTML(context, formatter);
}
return "" + name + "";
}
diff --git a/FLocal.Common/BBCodes/Url.cs b/FLocal.Common/BBCodes/Url.cs
index e879572..67b2604 100644
--- a/FLocal.Common/BBCodes/Url.cs
+++ b/FLocal.Common/BBCodes/Url.cs
@@ -11,11 +11,11 @@ namespace FLocal.Common.BBCodes {
: base("url") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
string rawUrl = this.DefaultOrValue;
string title = null;
if(rawUrl.ToLower() != this.InnerText.ToLower()) {
- title = this.GetInnerHTML(formatter);
+ title = this.GetInnerHTML(context, formatter);
}
return UrlProcessor.ProcessLink(rawUrl, title, true);
}
diff --git a/FLocal.Common/BBCodes/User.cs b/FLocal.Common/BBCodes/User.cs
index cb1b72d..45f45d0 100644
--- a/FLocal.Common/BBCodes/User.cs
+++ b/FLocal.Common/BBCodes/User.cs
@@ -11,7 +11,7 @@ namespace FLocal.Common.BBCodes {
: base("user") {
}
- public override string Format(ITextFormatter formatter) {
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var user = dataobjects.User.LoadByName(this.DefaultOrValue);
var url = new URL.users.user.Info(user.id.ToString(), null);
return String.Format("{2}", this.Safe(user.userGroup.name), url.canonical, this.Safe(user.name));
diff --git a/FLocal.Common/BBCodes/Wiki.cs b/FLocal.Common/BBCodes/Wiki.cs
index 28be404..22a6a7c 100644
--- a/FLocal.Common/BBCodes/Wiki.cs
+++ b/FLocal.Common/BBCodes/Wiki.cs
@@ -12,8 +12,8 @@ namespace FLocal.Common.BBCodes {
: base("wiki") {
}
- public override string Format(ITextFormatter formatter) {
- return "w:" + this.GetInnerHTML(formatter) + "";
+ public override string Format(IPostParsingContext context, ITextFormatter formatter) {
+ return "w:" + this.GetInnerHTML(context, formatter) + "";
}
}
diff --git a/FLocal.Common/BBCodes/helpers/BBCode.cs b/FLocal.Common/BBCodes/helpers/BBCode.cs
index 82a0e15..67fbaf9 100644
--- a/FLocal.Common/BBCodes/helpers/BBCode.cs
+++ b/FLocal.Common/BBCodes/helpers/BBCode.cs
@@ -2,18 +2,19 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using FLocal.Common.helpers;
namespace FLocal.Common.BBCodes {
- abstract class BBCode : PJonDevelopment.BBCode.BBCodeElement {
+ abstract class BBCode : PJonDevelopment.BBCode.BBCodeElement {
public BBCode(string name)
: base(name) {
}
- protected string GetInnerHTML(PJonDevelopment.BBCode.ITextFormatter formatter) {
+ protected string GetInnerHTML(IPostParsingContext context, PJonDevelopment.BBCode.ITextFormatter formatter) {
StringBuilder builder = new StringBuilder();
foreach (var node in this.Nodes) {
- builder.Append(node.Format(formatter));
+ builder.Append(node.Format(context, formatter));
}
return builder.ToString();
}
diff --git a/FLocal.Common/BBCodes/helpers/IPostParsingContext.cs b/FLocal.Common/BBCodes/helpers/IPostParsingContext.cs
new file mode 100644
index 0000000..038221f
--- /dev/null
+++ b/FLocal.Common/BBCodes/helpers/IPostParsingContext.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FLocal.Common.dataobjects;
+
+namespace FLocal.Common.BBCodes {
+ public interface IPostParsingContext {
+ }
+}
diff --git a/FLocal.Common/FLocal.Common.csproj b/FLocal.Common/FLocal.Common.csproj
index 7841395..add5180 100644
--- a/FLocal.Common/FLocal.Common.csproj
+++ b/FLocal.Common/FLocal.Common.csproj
@@ -123,6 +123,8 @@
+
+
diff --git a/FLocal.Common/UBBParser.cs b/FLocal.Common/UBBParser.cs
index c465e28..8968bc0 100644
--- a/FLocal.Common/UBBParser.cs
+++ b/FLocal.Common/UBBParser.cs
@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
using PJonDevelopment.BBCode;
using System.IO;
using Web.Core;
+using FLocal.Common.helpers;
namespace FLocal.Common {
public static class UBBParser {
@@ -108,14 +109,14 @@ namespace FLocal.Common {
public static readonly BBParserGateway instance = new BBParserGateway();
- private BBCodeParser parser;
+ private BBCodeParser parser;
private ITextFormatter formatter;
- private BBCodeParser quotesParser;
+ private BBCodeParser quotesParser;
private ITextFormatter simpleFormatter;
private BBParserGateway() {
- this.parser = new BBCodeParser();
+ this.parser = new BBCodeParser();
this.parser.ElementTypes.Add("b", typeof(BBCodes.B), true);
this.parser.ElementTypes.Add("code", typeof(BBCodes.Code), true);
this.parser.ElementTypes.Add("ecode", typeof(BBCodes.ECode), true);
@@ -145,30 +146,33 @@ namespace FLocal.Common {
this.parser.ElementTypes.Add("wiki", typeof(BBCodes.Wiki), true);
this.parser.ElementTypes.Add("ruwiki", typeof(BBCodes.RuWiki), true);
this.formatter = TextFormatter.instance;
-
- this.quotesParser = new BBCodeParser();
+
+ this.quotesParser = new BBCodeParser();
foreach(var elementType in this.parser.ElementTypes) {
this.quotesParser.ElementTypes.Add(elementType.Key, typeof(BBCodes.QuoteSkipper), elementType.Value.RequireClosingTag);
}
this.simpleFormatter = SimpleFormatter.instance;
}
- public string Parse(string input) {
- string result = this.parser.Parse(input).Format(this.formatter);
+ public string Parse(BBCodes.IPostParsingContext context, string input) {
+ string result = this.parser.Parse(input).Format(context, this.formatter);
if(result.EndsWith("
")) result = result.Substring(0, result.Length - 5);
return result;
}
public string ParseQuote(string input) {
- string result = this.quotesParser.Parse(input).Format(this.simpleFormatter);
+ string result = this.quotesParser.Parse(input).Format(new DelegatePostParsingContext(), this.simpleFormatter);
return result;
}
}
+ public static string UBBToIntermediate(BBCodes.IPostParsingContext context, string UBB) {
+ return BBParserGateway.instance.Parse(context, UBB);
+ }
+
public static string UBBToIntermediate(string UBB) {
- //return HttpUtility.HtmlEncode(UBB).Replace(Util.EOL, "
" + Util.EOL);
- return BBParserGateway.instance.Parse(UBB);
+ return UBBToIntermediate(new DelegatePostParsingContext(), UBB);
}
public static string ShallerToUBB(string shaller) {
diff --git a/FLocal.Common/dataobjects/User.cs b/FLocal.Common/dataobjects/User.cs
index 9c1e993..c8c41ed 100644
--- a/FLocal.Common/dataobjects/User.cs
+++ b/FLocal.Common/dataobjects/User.cs
@@ -253,38 +253,18 @@ namespace FLocal.Common.dataobjects {
);
}
- public IEnumerable getReplies(Diapasone diapasone, bool isAscending) {
- JoinSpec parent = new JoinSpec(
- Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_PARENTPOSTID),
- Post.TableSpec.instance,
- "parent"
- );
+ public IEnumerable getMentions(Diapasone diapasone, bool isAscending) {
return Post.LoadByIds(
from stringId in Config.instance.mainConnection.LoadIdsByConditions(
- Post.TableSpec.instance,
- new ComplexCondition(
- ConditionsJoinType.AND,
- new ComparisonCondition(
- parent.additionalTable.getColumnSpec(Post.TableSpec.FIELD_POSTERID),
- ComparisonType.EQUAL,
- this.id.ToString()
- ),
- new ComparisonCondition(
- Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_POSTERID),
- ComparisonType.NOTEQUAL,
- this.id.ToString()
- )
+ Mention.TableSpec.instance,
+ new ComparisonCondition(
+ Mention.TableSpec.instance.getColumnSpec(Mention.TableSpec.FIELD_MENTIONEDUSERID),
+ ComparisonType.EQUAL,
+ this.id.ToString()
),
diapasone,
- new JoinSpec[] {
- parent
- },
- new SortSpec[] {
- new SortSpec(
- Post.TableSpec.instance.getIdSpec(),
- isAscending
- ),
- }
+ Mention.TableSpec.instance.getColumnSpec(Mention.TableSpec.FIELD_POSTID),
+ new SortSpec(Mention.TableSpec.instance.getIdSpec(), isAscending)
) select int.Parse(stringId)
);
}
diff --git a/FLocal.Common/helpers/DelegatePostParsingContext.cs b/FLocal.Common/helpers/DelegatePostParsingContext.cs
new file mode 100644
index 0000000..9116f52
--- /dev/null
+++ b/FLocal.Common/helpers/DelegatePostParsingContext.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using FLocal.Common.dataobjects;
+using FLocal.Common.BBCodes;
+
+namespace FLocal.Common.helpers {
+ class DelegatePostParsingContext : IPostParsingContext {
+ }
+}
diff --git a/FLocal.IISHandler/handlers/response/UserRepliesHandler.cs b/FLocal.IISHandler/handlers/response/UserRepliesHandler.cs
index e353641..cb6f279 100644
--- a/FLocal.IISHandler/handlers/response/UserRepliesHandler.cs
+++ b/FLocal.IISHandler/handlers/response/UserRepliesHandler.cs
@@ -22,7 +22,7 @@ namespace FLocal.IISHandler.handlers.response {
override protected IEnumerable getUserSpecificData(WebContext context, User user) {
PageOuter pageOuter = PageOuter.createFromUrl(this.url, context.userSettings.postsPerPage);
- IEnumerable posts = user.getReplies(pageOuter, pageOuter.descendingDirection);
+ IEnumerable posts = user.getMentions(pageOuter, pageOuter.descendingDirection);
return new XElement[] {
user.exportToXmlForViewing(context),
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeConfiguration.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeConfiguration.vb
index 28ca5c0..8d3fa08 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeConfiguration.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeConfiguration.vb
@@ -22,127 +22,127 @@ Imports System.Xml.Serialization
'''
_
_
-Public NotInheritable Class BBCodeConfiguration
- Implements IXmlSerializable
-
- Private Shared ReadOnly __CurrentVersion As New System.Version(1, 0)
-
- Private __Version As System.Version
- Private __Dictionary As BBCodeElementDictionary
- Private __ElementTypes As BBCodeElementTypeDictionary
-
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Friend Sub New()
- __Version = New Version(1, 0)
- End Sub
-
- '''
- ''' Gets the version of the configuration file.
- '''
- Public Property Version() As System.Version
- Get
- Return __Version
- End Get
- Private Set(ByVal value As System.Version)
- If (value > __CurrentVersion) Then
- Throw New ArgumentException("Unrecognized version.")
- End If
- __Version = value
- End Set
- End Property
-
- '''
- ''' Gets the dictionary configuration.
- '''
- _
- Public ReadOnly Property Dictionary() As BBCodeElementDictionary
- Get
- If (__Dictionary Is Nothing) Then
- __Dictionary = New BBCodeElementDictionary()
- End If
- Return __Dictionary
- End Get
- End Property
-
- '''
- ''' Gets the factory configuration.
- '''
- _
- Public ReadOnly Property ElementTypes() As BBCodeElementTypeDictionary
- Get
- If (__ElementTypes Is Nothing) Then
- __ElementTypes = New BBCodeElementTypeDictionary()
- End If
- Return __ElementTypes
- End Get
- End Property
-
- ''' This method is reserved and should not be used. When implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the to the class.
- ''' An that describes the XML representation of the object that is produced by the method and consumed by the method.
- Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
- Return Nothing
- End Function
-
- ''' Generates an object from its XML representation.
- ''' The stream from which the object is deserialized.
- Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
-
- '*
- '* Check the name of the element
- '*
- If (reader.NamespaceURI <> STR_BBCodeSchemaNamespace) OrElse (reader.LocalName <> STR_BBCodeConfigurationXmlElement) Then
- Exit Sub
- End If
-
- '*
- '* Gets the version of the configuration
- '*
- Dim versionString = reader.GetAttribute("version")
- If (Not String.IsNullOrEmpty(versionString)) Then
- Me.Version = New System.Version(versionString)
- End If
-
- '*
- '* Move to the first item
- '*
- reader.Read()
-
- Dim dictionarySerializer = New XmlSerializer(GetType(BBCodeElementDictionary))
- Dim typesSerializer = New XmlSerializer(GetType(BBCodeElementTypeDictionary))
-
- __ElementTypes = Nothing
- __Dictionary = Nothing
-
- If (reader.LocalName = STR_BBCodeElementTypesXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
- __ElementTypes = typesSerializer.Deserialize(reader)
- End If
-
- If (reader.LocalName = STR_BBCodeDictionaryXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
- __Dictionary = dictionarySerializer.Deserialize(reader)
- End If
-
- If (__ElementTypes Is Nothing AndAlso reader.LocalName = STR_BBCodeElementTypesXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
- __ElementTypes = typesSerializer.Deserialize(reader)
- End If
-
- End Sub
-
- ''' Converts an object into its XML representation.
- ''' The stream to which the object is serialized.
- Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
-
- Dim dictionarySerializer = New XmlSerializer(GetType(BBCodeElementDictionary))
- Dim typesSerializer = New XmlSerializer(GetType(BBCodeElementTypeDictionary))
-
- If (ElementTypes.Count > 0) Then
- typesSerializer.Serialize(writer, ElementTypes)
- End If
-
- If (Dictionary.Count > 0) Then
- dictionarySerializer.Serialize(writer, Dictionary)
- End If
-
- End Sub
+Public NotInheritable Class BBCodeConfiguration(Of TContext As Class)
+ Implements IXmlSerializable
+
+ Private Shared ReadOnly __CurrentVersion As New System.Version(1, 0)
+
+ Private __Version As System.Version
+ Private __Dictionary As BBCodeElementDictionary
+ Private __ElementTypes As BBCodeElementTypeDictionary(Of TContext)
+
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Friend Sub New()
+ __Version = New Version(1, 0)
+ End Sub
+
+ '''
+ ''' Gets the version of the configuration file.
+ '''
+ Public Property Version() As System.Version
+ Get
+ Return __Version
+ End Get
+ Private Set(ByVal value As System.Version)
+ If (value > __CurrentVersion) Then
+ Throw New ArgumentException("Unrecognized version.")
+ End If
+ __Version = value
+ End Set
+ End Property
+
+ '''
+ ''' Gets the dictionary configuration.
+ '''
+ _
+ Public ReadOnly Property Dictionary() As BBCodeElementDictionary
+ Get
+ If (__Dictionary Is Nothing) Then
+ __Dictionary = New BBCodeElementDictionary()
+ End If
+ Return __Dictionary
+ End Get
+ End Property
+
+ '''
+ ''' Gets the factory configuration.
+ '''
+ _
+ Public ReadOnly Property ElementTypes() As BBCodeElementTypeDictionary(Of TContext)
+ Get
+ If (__ElementTypes Is Nothing) Then
+ __ElementTypes = New BBCodeElementTypeDictionary(Of TContext)()
+ End If
+ Return __ElementTypes
+ End Get
+ End Property
+
+ ''' This method is reserved and should not be used. When implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the to the class.
+ ''' An that describes the XML representation of the object that is produced by the method and consumed by the method.
+ Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
+ Return Nothing
+ End Function
+
+ ''' Generates an object from its XML representation.
+ ''' The stream from which the object is deserialized.
+ Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
+
+ '*
+ '* Check the name of the element
+ '*
+ If (reader.NamespaceURI <> STR_BBCodeSchemaNamespace) OrElse (reader.LocalName <> STR_BBCodeConfigurationXmlElement) Then
+ Exit Sub
+ End If
+
+ '*
+ '* Gets the version of the configuration
+ '*
+ Dim versionString = reader.GetAttribute("version")
+ If (Not String.IsNullOrEmpty(versionString)) Then
+ Me.Version = New System.Version(versionString)
+ End If
+
+ '*
+ '* Move to the first item
+ '*
+ reader.Read()
+
+ Dim dictionarySerializer = New XmlSerializer(GetType(BBCodeElementDictionary))
+ Dim typesSerializer = New XmlSerializer(GetType(BBCodeElementTypeDictionary(Of TContext)))
+
+ __ElementTypes = Nothing
+ __Dictionary = Nothing
+
+ If (reader.LocalName = STR_BBCodeElementTypesXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
+ __ElementTypes = typesSerializer.Deserialize(reader)
+ End If
+
+ If (reader.LocalName = STR_BBCodeDictionaryXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
+ __Dictionary = dictionarySerializer.Deserialize(reader)
+ End If
+
+ If (__ElementTypes Is Nothing AndAlso reader.LocalName = STR_BBCodeElementTypesXmlElement AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace) Then
+ __ElementTypes = typesSerializer.Deserialize(reader)
+ End If
+
+ End Sub
+
+ ''' Converts an object into its XML representation.
+ ''' The stream to which the object is serialized.
+ Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
+
+ Dim dictionarySerializer = New XmlSerializer(GetType(BBCodeElementDictionary))
+ Dim typesSerializer = New XmlSerializer(GetType(BBCodeElementTypeDictionary(Of TContext)))
+
+ If (ElementTypes.Count > 0) Then
+ typesSerializer.Serialize(writer, ElementTypes)
+ End If
+
+ If (Dictionary.Count > 0) Then
+ dictionarySerializer.Serialize(writer, Dictionary)
+ End If
+
+ End Sub
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeDocument.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeDocument.vb
index 7b2cf31..f66839f 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeDocument.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeDocument.vb
@@ -18,77 +18,77 @@
'''
''' Represents a document writen in BBCode.
'''
-Public NotInheritable Class BBCodeDocument
+Public NotInheritable Class BBCodeDocument(Of TContext As Class)
- Private __Text As String
- Private __Parser As BBCodeParser
- Private __Nodes As BBCodeNodeCollection
+ Private __Text As String
+ Private __Parser As BBCodeParser(Of TContext)
+ Private __Nodes As BBCodeNodeCollection(Of TContext)
- ''' Initializes an instance of the class.
- ''' The that created this instance.
- Friend Sub New(ByVal parser As BBCodeParser)
- __Parser = parser
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The that created this instance.
+ Friend Sub New(ByVal parser As BBCodeParser(Of TContext))
+ __Parser = parser
+ End Sub
- '''
- ''' Gets the that is responsible for this .
- '''
- Friend ReadOnly Property Parser() As BBCodeParser
- Get
- Return __Parser
- End Get
- End Property
+ '''
+ ''' Gets the that is responsible for this .
+ '''
+ Friend ReadOnly Property Parser() As BBCodeParser(Of TContext)
+ Get
+ Return __Parser
+ End Get
+ End Property
- '''
- ''' Gets or sets the BBCode of the document.
- '''
- Public Property Text() As String
- Get
- Return __Text
- End Get
- Set(ByVal value As String)
- __Text = value
- Nodes.Clear()
- Nodes.AddRange(Me.Parser.Parse(value).Nodes)
- End Set
- End Property
+ '''
+ ''' Gets or sets the BBCode of the document.
+ '''
+ Public Property Text() As String
+ Get
+ Return __Text
+ End Get
+ Set(ByVal value As String)
+ __Text = value
+ Nodes.Clear()
+ Nodes.AddRange(Me.Parser.Parse(value).Nodes)
+ End Set
+ End Property
- '''
- ''' Gets the generated ba the BBCode text.
- '''
- ''' A that represents the parsed text of the document.
- Public ReadOnly Property Nodes() As BBCodeNodeCollection
- Get
- If (__Nodes Is Nothing) Then
- __Nodes = New BBCodeNodeCollection()
- End If
- Return __Nodes
- End Get
- End Property
+ '''
+ ''' Gets the generated ba the BBCode text.
+ '''
+ ''' A that represents the parsed text of the document.
+ Public ReadOnly Property Nodes() As BBCodeNodeCollection(Of TContext)
+ Get
+ If (__Nodes Is Nothing) Then
+ __Nodes = New BBCodeNodeCollection(Of TContext)()
+ End If
+ Return __Nodes
+ End Get
+ End Property
- '''
- ''' Returns the formatted text.
- '''
- ''' The formatted text.
- Public Function Format() As String
- Return Format(New BBCodeHtmlFormatter())
- End Function
+ '''
+ ''' Returns the formatted text.
+ '''
+ ''' The formatted text.
+ Public Function Format(ByVal context As TContext) As String
+ Return Format(context, New BBCodeHtmlFormatter())
+ End Function
- '''
- ''' Returns the formatted text, using the specified .
- '''
- ''' An object that implements the interface.
- ''' The formatted text.
- Public Function Format(ByVal formatter As ITextFormatter) As String
- Dim sb As New Text.StringBuilder()
- For Each n In Nodes
- sb.Append(n.Format(formatter))
- Next
- Return sb.ToString()
- End Function
+ '''
+ ''' Returns the formatted text, using the specified .
+ '''
+ ''' An object that implements the interface.
+ ''' The formatted text.
+ Public Function Format(ByVal context As TContext, ByVal formatter As ITextFormatter) As String
+ Dim sb As New Text.StringBuilder()
+ For Each n In Nodes
+ sb.Append(n.Format(context, formatter))
+ Next
+ Return sb.ToString()
+ End Function
- Friend Sub SetText(ByVal text As String)
- __Text = text
- End Sub
+ Friend Sub SetText(ByVal text As String)
+ __Text = text
+ End Sub
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElement.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElement.vb
index c63cde3..e8e2495 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElement.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElement.vb
@@ -21,241 +21,241 @@ Imports System.Text.RegularExpressions
'''
''' Represents an BBCode element.
'''
-Public Class BBCodeElement
- Inherits BBCodeNode
+Public Class BBCodeElement(Of TContext As Class)
+ Inherits BBCodeNode(Of TContext)
- Private __Name As String
- Private __Nodes As BBCodeNodeCollection
- Private __Attributes As BBCodeAttributeDictionary
- Private __ReplacementFormat As String = String.Empty
- Private __RequireClosingTag As TriState = TriState.UseDefault
- Private __IsValueFormatted As Boolean
+ Private __Name As String
+ Private __Nodes As BBCodeNodeCollection(Of TContext)
+ Private __Attributes As BBCodeAttributeDictionary
+ Private __ReplacementFormat As String = String.Empty
+ Private __RequireClosingTag As TriState = TriState.UseDefault
+ Private __IsValueFormatted As Boolean
- Private Shared ReadOnly __RxAttribute As New Regex("\{(?[_a-zA-Z0-9].*?)\}")
+ Private Shared ReadOnly __RxAttribute As New Regex("\{(?[_a-zA-Z0-9].*?)\}")
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Friend Sub New()
- End Sub
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Friend Sub New()
+ End Sub
- ''' Initializes an instance of the class.
- ''' The name of the element.
- Protected Sub New(ByVal name As String)
- __Name = name.ToUpperInvariant()
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The name of the element.
+ Protected Sub New(ByVal name As String)
+ __Name = name.ToUpperInvariant()
+ End Sub
- ''' Initializes an instance of the class.
- ''' The parser used to create this element.
- Friend Sub New(ByVal parser As BBCodeParser)
- MyBase.New(parser)
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The parser used to create this element.
+ Friend Sub New(ByVal parser As BBCodeParser(Of TContext))
+ MyBase.New(parser)
+ End Sub
- '''
- ''' Gets the name of the element.
- '''
- Public ReadOnly Property Name() As String
- Get
- Return __Name
- End Get
- End Property
+ '''
+ ''' Gets the name of the element.
+ '''
+ Public ReadOnly Property Name() As String
+ Get
+ Return __Name
+ End Get
+ End Property
- '''
- ''' Gets the replacement format for this element.
- '''
- ''' The replacement format.
- '''
- ''' In order to use the any parameter in the replacement format use the following syntax: {paramName}.
- '''
- ''' The parameter names are case insensitive.
- '''
- ''' There are two reserved parameter keywords for formatting: DEFAULT and VALUE.
- ''' DEFAULT : The text following the first equal sign after the name of the BBCode element.
- ''' VALUE: The HTML generated by the BBCode between the start and end element tag.
- ''' [url=http://tempuri.org]text[/url]
- ''' In the example above the parameter DEFAULT would have the value "http://tempuri.org", while VALUE would be "text".
- '''
- ''' To replace [url=http://tempuri.org]text[/url] the with <a href="http://tempuri.org">text</a> the following ReplacementFormat should be used:
- '''
- ''' <a href="{default|value}">{value|default}</a>
- '''
- ''' The example above, will set the href attribute with either the default value or the text inside the [url] element. The pipe (|) implies in finding the first non-empty attribute.
- '''
- Public ReadOnly Property ReplacementFormat() As String
- Get
- If (String.IsNullOrEmpty(__ReplacementFormat)) Then
- If (Me.Parser.Dictionary.ContainsKey(Me.Name)) Then
- __ReplacementFormat = Me.Parser.Dictionary(Me.Name).ReplacementFormat
- End If
- End If
- Return __ReplacementFormat
- End Get
- End Property
+ '''
+ ''' Gets the replacement format for this element.
+ '''
+ ''' The replacement format.
+ '''
+ ''' In order to use the any parameter in the replacement format use the following syntax: {paramName}.
+ '''
+ ''' The parameter names are case insensitive.
+ '''
+ ''' There are two reserved parameter keywords for formatting: DEFAULT and VALUE.
+ ''' DEFAULT : The text following the first equal sign after the name of the BBCode element.
+ ''' VALUE: The HTML generated by the BBCode between the start and end element tag.
+ ''' [url=http://tempuri.org]text[/url]
+ ''' In the example above the parameter DEFAULT would have the value "http://tempuri.org", while VALUE would be "text".
+ '''
+ ''' To replace [url=http://tempuri.org]text[/url] the with <a href="http://tempuri.org">text</a> the following ReplacementFormat should be used:
+ '''
+ ''' <a href="{default|value}">{value|default}</a>
+ '''
+ ''' The example above, will set the href attribute with either the default value or the text inside the [url] element. The pipe (|) implies in finding the first non-empty attribute.
+ '''
+ Public ReadOnly Property ReplacementFormat() As String
+ Get
+ If (String.IsNullOrEmpty(__ReplacementFormat)) Then
+ If (Me.Parser.Dictionary.ContainsKey(Me.Name)) Then
+ __ReplacementFormat = Me.Parser.Dictionary(Me.Name).ReplacementFormat
+ End If
+ End If
+ Return __ReplacementFormat
+ End Get
+ End Property
- '''
- ''' Gets a value indicating if the element requires a closing tag.
- '''
- ''' True if the element requires a closing tag; otherwise False.
- Public ReadOnly Property RequireClosingTag() As Boolean
- Get
- If (__RequireClosingTag = TriState.UseDefault) Then
- If (Not String.IsNullOrEmpty(Me.Name) AndAlso Me.Parser.Dictionary.ContainsKey(Me.Name)) Then
- __RequireClosingTag = If(Me.Parser.Dictionary(Me.Name).RequireClosingTag, TriState.True, TriState.False)
- ElseIf (Not String.IsNullOrEmpty(Me.Name) AndAlso Me.Parser.ElementTypes.ContainsKey(Me.Name)) Then
- __RequireClosingTag = If(Me.Parser.ElementTypes(Me.Name).RequireClosingTag, TriState.True, TriState.False)
- End If
- End If
- Return (__RequireClosingTag = TriState.True)
- End Get
- End Property
+ '''
+ ''' Gets a value indicating if the element requires a closing tag.
+ '''
+ ''' True if the element requires a closing tag; otherwise False.
+ Public ReadOnly Property RequireClosingTag() As Boolean
+ Get
+ If (__RequireClosingTag = TriState.UseDefault) Then
+ If (Not String.IsNullOrEmpty(Me.Name) AndAlso Me.Parser.Dictionary.ContainsKey(Me.Name)) Then
+ __RequireClosingTag = If(Me.Parser.Dictionary(Me.Name).RequireClosingTag, TriState.True, TriState.False)
+ ElseIf (Not String.IsNullOrEmpty(Me.Name) AndAlso Me.Parser.ElementTypes.ContainsKey(Me.Name)) Then
+ __RequireClosingTag = If(Me.Parser.ElementTypes(Me.Name).RequireClosingTag, TriState.True, TriState.False)
+ End If
+ End If
+ Return (__RequireClosingTag = TriState.True)
+ End Get
+ End Property
- '''
- ''' Gets the list of attributes.
- '''
- Public ReadOnly Property Attributes() As BBCodeAttributeDictionary
- Get
- If (__Attributes Is Nothing) Then
- __Attributes = New BBCodeAttributeDictionary
- End If
- Return __Attributes
- End Get
- End Property
+ '''
+ ''' Gets the list of attributes.
+ '''
+ Public ReadOnly Property Attributes() As BBCodeAttributeDictionary
+ Get
+ If (__Attributes Is Nothing) Then
+ __Attributes = New BBCodeAttributeDictionary
+ End If
+ Return __Attributes
+ End Get
+ End Property
- '''
- ''' Gets the list of sub nodes.
- '''
- Public ReadOnly Property Nodes() As BBCodeNodeCollection
- Get
- If (__Nodes Is Nothing) Then
- __Nodes = New BBCodeNodeCollection(Me)
- End If
- Return __Nodes
- End Get
- End Property
+ '''
+ ''' Gets the list of sub nodes.
+ '''
+ Public ReadOnly Property Nodes() As BBCodeNodeCollection(Of TContext)
+ Get
+ If (__Nodes Is Nothing) Then
+ __Nodes = New BBCodeNodeCollection(Of TContext)(Me)
+ End If
+ Return __Nodes
+ End Get
+ End Property
- ''' Transforms this instance of into its desired text representation.
- ''' An object that implements the interface.
- ''' The text formatted by the .
- Public Overrides Function Format(ByVal formatter As ITextFormatter) As String
- IsValueFormatted = False
- Dim sb As New Text.StringBuilder(Me.ReplacementFormat)
- Dim attribs = __RxAttribute.Matches(Me.ReplacementFormat)
- For Each attrib As Match In attribs
- sb.Replace(attrib.Value, GetAttribute(attrib.Groups("name").Value, formatter))
- Next
- If Not IsValueFormatted Then
- sb.Append(GetAttribute("value", formatter))
- End If
- Return sb.ToString()
- End Function
+ ''' Transforms this instance of into its desired text representation.
+ ''' An object that implements the interface.
+ ''' The text formatted by the .
+ Public Overrides Function Format(ByVal context As TContext, ByVal formatter As ITextFormatter) As String
+ IsValueFormatted = False
+ Dim sb As New Text.StringBuilder(Me.ReplacementFormat)
+ Dim attribs = __RxAttribute.Matches(Me.ReplacementFormat)
+ For Each attrib As Match In attribs
+ sb.Replace(attrib.Value, GetAttribute(attrib.Groups("name").Value, context, formatter))
+ Next
+ If Not IsValueFormatted Then
+ sb.Append(GetAttribute("value", context, formatter))
+ End If
+ Return sb.ToString()
+ End Function
- ''' Gets or sets the inner
- ''' The BBCode between the start and end tags.
- Public NotOverridable Overrides Property InnerBBCode() As String
- Get
- Dim sb As New System.Text.StringBuilder()
- For Each n As BBCodeNode In Nodes
- sb.Append(n.OuterBBCode)
- Next
- Return sb.ToString()
- End Get
- Set(ByVal value As String)
- If Not RequireClosingTag Then
- Throw New InvalidOperationException("The InnerBBCode property cannot be set for elements that does not require closing tags.")
- End If
- Me.Nodes.Clear()
- Me.Nodes.AddRange(Me.Parser.Parse(value).Nodes)
- End Set
- End Property
+ ''' Gets or sets the inner
+ ''' The BBCode between the start and end tags.
+ Public NotOverridable Overrides Property InnerBBCode() As String
+ Get
+ Dim sb As New System.Text.StringBuilder()
+ For Each n As BBCodeNode(Of TContext) In Nodes
+ sb.Append(n.OuterBBCode)
+ Next
+ Return sb.ToString()
+ End Get
+ Set(ByVal value As String)
+ If Not RequireClosingTag Then
+ Throw New InvalidOperationException("The InnerBBCode property cannot be set for elements that does not require closing tags.")
+ End If
+ Me.Nodes.Clear()
+ Me.Nodes.AddRange(Me.Parser.Parse(value).Nodes)
+ End Set
+ End Property
- ''' Gets or sets the outer
- ''' The BBCode of this instance of the .
- Public NotOverridable Overrides ReadOnly Property OuterBBCode() As String
- Get
- Dim sb As New Text.StringBuilder()
- sb.Append("[")
- sb.Append(Me.Name)
- If ((Me.Attributes.Count = 1) AndAlso Me.Attributes.ContainsKey("default")) Then
- sb.AppendFormat(CultureInfo.InvariantCulture, "={0}", Quote(Me.Attributes("default")))
- Else
- For Each key In Me.Attributes.Keys
- sb.AppendFormat(CultureInfo.InvariantCulture, " {0}={1}", key, Quote(Me.Attributes(key)))
- Next
- End If
- If (Me.RequireClosingTag) Then
- sb.Append("]")
- sb.Append(Me.InnerBBCode)
- sb.Append("[/")
- sb.Append(Me.Name)
- End If
- sb.Append("]")
- Return sb.ToString()
- End Get
- End Property
+ ''' Gets or sets the outer
+ ''' The BBCode of this instance of the .
+ Public NotOverridable Overrides ReadOnly Property OuterBBCode() As String
+ Get
+ Dim sb As New Text.StringBuilder()
+ sb.Append("[")
+ sb.Append(Me.Name)
+ If ((Me.Attributes.Count = 1) AndAlso Me.Attributes.ContainsKey("default")) Then
+ sb.AppendFormat(CultureInfo.InvariantCulture, "={0}", Quote(Me.Attributes("default")))
+ Else
+ For Each key In Me.Attributes.Keys
+ sb.AppendFormat(CultureInfo.InvariantCulture, " {0}={1}", key, Quote(Me.Attributes(key)))
+ Next
+ End If
+ If (Me.RequireClosingTag) Then
+ sb.Append("]")
+ sb.Append(Me.InnerBBCode)
+ sb.Append("[/")
+ sb.Append(Me.Name)
+ End If
+ sb.Append("]")
+ Return sb.ToString()
+ End Get
+ End Property
- ''' Gets or sets the plain text of the node.
- ''' The plain text between the start and end tags.
- Public NotOverridable Overrides Property InnerText() As String
- Get
- Dim sb As New Text.StringBuilder()
- For Each n In Me.Nodes
- sb.Append(n.InnerText)
- Next
- Return sb.ToString()
- End Get
- Set(ByVal value As String)
- If (Not RequireClosingTag) Then
- Throw New InvalidOperationException("The InnerText property cannot be set for elements that does not require closing tags.")
- End If
+ ''' Gets or sets the plain text of the node.
+ ''' The plain text between the start and end tags.
+ Public NotOverridable Overrides Property InnerText() As String
+ Get
+ Dim sb As New Text.StringBuilder()
+ For Each n In Me.Nodes
+ sb.Append(n.InnerText)
+ Next
+ Return sb.ToString()
+ End Get
+ Set(ByVal value As String)
+ If (Not RequireClosingTag) Then
+ Throw New InvalidOperationException("The InnerText property cannot be set for elements that does not require closing tags.")
+ End If
- '*
- '* Removes all nodex from the element
- '*
- Me.Nodes.Clear()
- If (Not String.IsNullOrEmpty(value)) Then
- '*
- '* Only append a BBCodeText element if the value is not empty
- '*
- Me.Nodes.Add(New BBCodeText(value))
- End If
- End Set
- End Property
+ '*
+ '* Removes all nodex from the element
+ '*
+ Me.Nodes.Clear()
+ If (Not String.IsNullOrEmpty(value)) Then
+ '*
+ '* Only append a BBCodeText element if the value is not empty
+ '*
+ Me.Nodes.Add(New BBCodeText(Of TContext)(value))
+ End If
+ End Set
+ End Property
- '''
- ''' Sets the element name of this instance.
- '''
- ''' The new element name of this instance.
- Friend Sub SetName(ByVal name As String)
- __Name = name
- End Sub
+ '''
+ ''' Sets the element name of this instance.
+ '''
+ ''' The new element name of this instance.
+ Friend Sub SetName(ByVal name As String)
+ __Name = name
+ End Sub
- '''
- ''' Gets a value indicating wheter or not the have been formatted.
- '''
- ''' True if the values have been formatted; otherwise False.
- Private Property IsValueFormatted() As Boolean
- Get
- Return __IsValueFormatted
- End Get
- Set(ByVal value As Boolean)
- __IsValueFormatted = value
- End Set
- End Property
+ '''
+ ''' Gets a value indicating wheter or not the have been formatted.
+ '''
+ ''' True if the values have been formatted; otherwise False.
+ Private Property IsValueFormatted() As Boolean
+ Get
+ Return __IsValueFormatted
+ End Get
+ Set(ByVal value As Boolean)
+ __IsValueFormatted = value
+ End Set
+ End Property
- Private Function GetAttribute(ByVal name As String, ByVal formatter As ITextFormatter) As String
- Dim attribs = name.ToUpperInvariant().Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
- For Each attrib In attribs
- If (String.CompareOrdinal(attrib, "VALUE") = 0) Then
- IsValueFormatted = True
- Dim sb As New Text.StringBuilder()
- For Each node In Me.Nodes
- sb.Append(node.Format(formatter))
- Next
- Return sb.ToString()
- ElseIf (Me.Attributes.ContainsKey(attrib)) Then
- Return (Me.Attributes.Item(attrib))
- End If
- Next
- Return String.Empty
- End Function
+ Private Function GetAttribute(ByVal name As String, ByVal context As TContext, ByVal formatter As ITextFormatter) As String
+ Dim attribs = name.ToUpperInvariant().Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
+ For Each attrib In attribs
+ If (String.CompareOrdinal(attrib, "VALUE") = 0) Then
+ IsValueFormatted = True
+ Dim sb As New Text.StringBuilder()
+ For Each node In Me.Nodes
+ sb.Append(node.Format(context, formatter))
+ Next
+ Return sb.ToString()
+ ElseIf (Me.Attributes.ContainsKey(attrib)) Then
+ Return (Me.Attributes.Item(attrib))
+ End If
+ Next
+ Return String.Empty
+ End Function
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementFactory.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementFactory.vb
index 4a18808..ffae4f7 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementFactory.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementFactory.vb
@@ -18,84 +18,84 @@
'''
''' Creates instances of .
'''
-Friend NotInheritable Class BBCodeElementFactory
+Friend NotInheritable Class BBCodeElementFactory(Of TContext As Class)
- Private __Parser As BBCodeParser
+ Private __Parser As BBCodeParser(Of TContext)
- ''' Initializes an instance of the class.
- ''' The that will utilize the new instance of the .
- Friend Sub New(ByVal parser As BBCodeParser)
- __Parser = parser
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The that will utilize the new instance of the .
+ Friend Sub New(ByVal parser As BBCodeParser(Of TContext))
+ __Parser = parser
+ End Sub
- '''
- ''' Gets the that utilizes this instance of the .
- '''
- Public ReadOnly Property Parser() As BBCodeParser
- Get
- Return __Parser
- End Get
- End Property
+ '''
+ ''' Gets the that utilizes this instance of the .
+ '''
+ Public ReadOnly Property Parser() As BBCodeParser(Of TContext)
+ Get
+ Return __Parser
+ End Get
+ End Property
- '''
- ''' Creates a new .
- '''
- ''' The name of the element.
- ''' The attributes of the element.
- ''' A new .
- Public Function CreateElement(ByVal name As String, ByVal attributes As BBCodeAttributeDictionary) As BBCodeElement
+ '''
+ ''' Creates a new .
+ '''
+ ''' The name of the element.
+ ''' The attributes of the element.
+ ''' A new .
+ Public Function CreateElement(ByVal name As String, ByVal attributes As BBCodeAttributeDictionary) As BBCodeElement(Of TContext)
- Dim el As BBCodeElement
+ Dim el As BBCodeElement(Of TContext)
- '*
- '* Check if we have a different type to create
- '*
- If (Parser.ElementTypes.ContainsKey(name.ToUpperInvariant())) Then
- '*
- '* Gets the type of the element
- '*
- Dim type = Parser.ElementTypes(name.ToUpperInvariant()).Type
+ '*
+ '* Check if we have a different type to create
+ '*
+ If (Parser.ElementTypes.ContainsKey(name.ToUpperInvariant())) Then
+ '*
+ '* Gets the type of the element
+ '*
+ Dim type = Parser.ElementTypes(name.ToUpperInvariant()).Type
- '*
- '* Check if the type IS BBCodeElement
- '*
- If (type.Equals(GetType(BBCodeElement))) Then
- el = New BBCodeElement()
- Else
- '*
- '* Gets the default constructor
- '*
- Dim ctor = type.GetConstructor(New Type() {})
- If (ctor Is Nothing) Then
- Throw New InvalidOperationException("The type " & type.FullName & " does not have a default constructor.")
- End If
+ '*
+ '* Check if the type IS BBCodeElement
+ '*
+ If (type.Equals(GetType(BBCodeElement(Of TContext)))) Then
+ el = New BBCodeElement(Of TContext)()
+ Else
+ '*
+ '* Gets the default constructor
+ '*
+ Dim ctor = type.GetConstructor(New Type() {})
+ If (ctor Is Nothing) Then
+ Throw New InvalidOperationException("The type " & type.FullName & " does not have a default constructor.")
+ End If
- '*
- '* Creates the new element.
- '*
- el = TryCast(ctor.Invoke(New Object() {}), BBCodeElement)
- If (el Is Nothing) Then
- Throw New InvalidOperationException("The type " & type.FullName & " could not be assingned to BBCodeElement.")
- End If
- End If
- Else
- el = New BBCodeElement()
- End If
+ '*
+ '* Creates the new element.
+ '*
+ el = TryCast(ctor.Invoke(New Object() {}), BBCodeElement(Of TContext))
+ If (el Is Nothing) Then
+ Throw New InvalidOperationException("The type " & type.FullName & " could not be assingned to BBCodeElement.")
+ End If
+ End If
+ Else
+ el = New BBCodeElement(Of TContext)()
+ End If
- '*
- '* Set the element properties
- '*
- el.SetName(name)
- el.SetParser(Parser)
- For Each attr In attributes
- el.Attributes.Add(attr.Key, attr.Value)
- Next
+ '*
+ '* Set the element properties
+ '*
+ el.SetName(name)
+ el.SetParser(Parser)
+ For Each attr In attributes
+ el.Attributes.Add(attr.Key, attr.Value)
+ Next
- '*
- '* Returns the created element.
- '*
- Return el
+ '*
+ '* Returns the created element.
+ '*
+ Return el
- End Function
+ End Function
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementTypeDictionary.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementTypeDictionary.vb
index 4ea9ac9..08bec1c 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementTypeDictionary.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeElementTypeDictionary.vb
@@ -24,95 +24,95 @@ Imports System.Diagnostics.CodeAnalysis
'''
_
_
-Public NotInheritable Class BBCodeElementTypeDictionary
- Inherits Dictionary(Of String, BBCodeElementTypeDefinition)
- Implements IXmlSerializable
-
- Private Const STR_ConfigurationItem As String = "element"
-
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Friend Sub New()
- End Sub
-
- ''' Initializes a new instance of the class with serialized data.
- ''' A object containing the information required to serialize the .
- ''' A structure containing the source and destination of the serialized stream associated with the .
- Private Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
- MyBase.New(info, context)
- End Sub
-
- '''
- ''' Adds the specified key and value to the dictionary.
- '''
- ''' The key of the element to add.
- ''' The value of the element to add.
- Private Shadows Sub Add(ByVal tagName As String, ByVal value As BBCodeElementTypeDefinition)
- ValidateTagName(tagName)
- ValidateBBCodeElementType(value.Type)
- MyBase.Add(tagName.ToUpperInvariant(), value)
- End Sub
-
- '''
- ''' Adds the specified key and value to the dictionary.
- '''
- ''' The key of the element to add.
- ''' The value of the element to add.
- Public Shadows Sub Add(ByVal tagName As String, ByVal value As Type, ByVal requireClosingTag As Boolean)
- Add(tagName.ToUpperInvariant(), New BBCodeElementTypeDefinition() With {.TagName = tagName, .Type = value, .RequireClosingTag = requireClosingTag})
- End Sub
-
- ''' This method is reserved and should not be used. When implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the to the class.
- ''' An that describes the XML representation of the object that is produced by the method and consumed by the method.
- Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
- Return Nothing
- End Function
-
- ''' Generates an object from its XML representation.
- ''' The stream from which the object is deserialized.
- Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
-
- '*
- '* Check the name of the element
- '*
- If (reader.NamespaceURI <> STR_BBCodeSchemaNamespace) OrElse (reader.LocalName <> STR_BBCodeElementTypesXmlElement) Then
- Exit Sub
- End If
-
- '*
- '* Reads the items
- '*
- Do While (reader.Read() AndAlso reader.LocalName = STR_ConfigurationItem AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace)
- Dim definition As New BBCodeElementTypeDefinition()
- With definition
- .TagName = reader.GetAttribute("name")
- Boolean.TryParse(reader.GetAttribute("requireClosingTag"), .RequireClosingTag)
- .Type = System.Type.GetType(reader.GetAttribute("type"))
- End With
- If (definition.Type.IsSubclassOf(GetType(BBCodeElement))) Then
- Me.Add(definition.TagName, definition)
- End If
- Loop
-
- If (reader.NodeType = Xml.XmlNodeType.EndElement) Then
- reader.Read()
- End If
-
- End Sub
-
- ''' Converts an object into its XML representation.
- ''' The stream to which the object is serialized.
- _
- Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
-
- For Each it In Me
- writer.WriteStartElement(STR_ConfigurationItem, STR_BBCodeSchemaNamespace)
- writer.WriteAttributeString("name", it.Key.ToLower(CultureInfo.InvariantCulture))
- writer.WriteAttributeString("requireClosingTag", it.Value.RequireClosingTag.ToString())
- writer.WriteAttributeString("type", it.Value.Type.AssemblyQualifiedName)
- writer.WriteEndElement()
- Next
-
- End Sub
+Public NotInheritable Class BBCodeElementTypeDictionary(Of TContext As Class)
+ Inherits Dictionary(Of String, BBCodeElementTypeDefinition)
+ Implements IXmlSerializable
+
+ Private Const STR_ConfigurationItem As String = "element"
+
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Friend Sub New()
+ End Sub
+
+ ''' Initializes a new instance of the class with serialized data.
+ ''' A object containing the information required to serialize the .
+ ''' A structure containing the source and destination of the serialized stream associated with the .
+ Private Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext)
+ MyBase.New(info, context)
+ End Sub
+
+ '''
+ ''' Adds the specified key and value to the dictionary.
+ '''
+ ''' The key of the element to add.
+ ''' The value of the element to add.
+ Private Shadows Sub Add(ByVal tagName As String, ByVal value As BBCodeElementTypeDefinition)
+ ValidateTagName(tagName)
+ ValidateBBCodeElementType(Of TContext)(value.Type)
+ MyBase.Add(tagName.ToUpperInvariant(), value)
+ End Sub
+
+ '''
+ ''' Adds the specified key and value to the dictionary.
+ '''
+ ''' The key of the element to add.
+ ''' The value of the element to add.
+ Public Shadows Sub Add(ByVal tagName As String, ByVal value As Type, ByVal requireClosingTag As Boolean)
+ Add(tagName.ToUpperInvariant(), New BBCodeElementTypeDefinition() With {.TagName = tagName, .Type = value, .RequireClosingTag = requireClosingTag})
+ End Sub
+
+ ''' This method is reserved and should not be used. When implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the to the class.
+ ''' An that describes the XML representation of the object that is produced by the method and consumed by the method.
+ Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
+ Return Nothing
+ End Function
+
+ ''' Generates an object from its XML representation.
+ ''' The stream from which the object is deserialized.
+ Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
+
+ '*
+ '* Check the name of the element
+ '*
+ If (reader.NamespaceURI <> STR_BBCodeSchemaNamespace) OrElse (reader.LocalName <> STR_BBCodeElementTypesXmlElement) Then
+ Exit Sub
+ End If
+
+ '*
+ '* Reads the items
+ '*
+ Do While (reader.Read() AndAlso reader.LocalName = STR_ConfigurationItem AndAlso reader.NamespaceURI = STR_BBCodeSchemaNamespace)
+ Dim definition As New BBCodeElementTypeDefinition()
+ With definition
+ .TagName = reader.GetAttribute("name")
+ Boolean.TryParse(reader.GetAttribute("requireClosingTag"), .RequireClosingTag)
+ .Type = System.Type.GetType(reader.GetAttribute("type"))
+ End With
+ If (definition.Type.IsSubclassOf(GetType(BBCodeElement(Of TContext)))) Then
+ Me.Add(definition.TagName, definition)
+ End If
+ Loop
+
+ If (reader.NodeType = Xml.XmlNodeType.EndElement) Then
+ reader.Read()
+ End If
+
+ End Sub
+
+ ''' Converts an object into its XML representation.
+ ''' The stream to which the object is serialized.
+ _
+ Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
+
+ For Each it In Me
+ writer.WriteStartElement(STR_ConfigurationItem, STR_BBCodeSchemaNamespace)
+ writer.WriteAttributeString("name", it.Key.ToLower(CultureInfo.InvariantCulture))
+ writer.WriteAttributeString("requireClosingTag", it.Value.RequireClosingTag.ToString())
+ writer.WriteAttributeString("type", it.Value.Type.AssemblyQualifiedName)
+ writer.WriteEndElement()
+ Next
+
+ End Sub
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNode.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNode.vb
index 4a04b93..c32f358 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNode.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNode.vb
@@ -18,84 +18,84 @@
'''
''' Represents the basic node of an BBCode document.
'''
-Public MustInherit Class BBCodeNode
+Public MustInherit Class BBCodeNode(Of TContext As Class)
- Private __Parent As BBCodeNode
- Private __Parser As BBCodeParser
+ Private __Parent As BBCodeNode(Of TContext)
+ Private __Parser As BBCodeParser(Of TContext)
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Protected Sub New()
- End Sub
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Protected Sub New()
+ End Sub
- ''' Initializes an instance of the class.
- ''' The parser used to create this element.
- Protected Sub New(ByVal parser As BBCodeParser)
- __Parser = parser
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The parser used to create this element.
+ Protected Sub New(ByVal parser As BBCodeParser(Of TContext))
+ __Parser = parser
+ End Sub
- '''
- ''' Gets the parent node.
- '''
- Public ReadOnly Property Parent() As BBCodeNode
- Get
- Return __Parent
- End Get
- End Property
+ '''
+ ''' Gets the parent node.
+ '''
+ Public ReadOnly Property Parent() As BBCodeNode(Of TContext)
+ Get
+ Return __Parent
+ End Get
+ End Property
- '''
- ''' Gets the that create this instance of the .
- '''
- Protected Friend ReadOnly Property Parser() As BBCodeParser
- Get
- Return __Parser
- End Get
- End Property
+ '''
+ ''' Gets the that create this instance of the .
+ '''
+ Protected Friend ReadOnly Property Parser() As BBCodeParser(Of TContext)
+ Get
+ Return __Parser
+ End Get
+ End Property
- '''
- ''' When implemented in a derived class, transforms this instance of into its desired text representation.
- '''
- ''' An object that implements the interface.
- ''' The text formatted by the .
- Public MustOverride Function Format(ByVal formatter As ITextFormatter) As String
+ '''
+ ''' When implemented in a derived class, transforms this instance of into its desired text representation.
+ '''
+ ''' An object that implements the interface.
+ ''' The text formatted by the .
+ Public MustOverride Function Format(ByVal context As TContext, ByVal formatter As ITextFormatter) As String
- '''
- ''' When implemented in a derived class, gets or sets the inner BBCode.
- '''
- ''' The BBCode between the start and end tags.
- Public MustOverride Property InnerBBCode() As String
+ '''
+ ''' When implemented in a derived class, gets or sets the inner BBCode.
+ '''
+ ''' The BBCode between the start and end tags.
+ Public MustOverride Property InnerBBCode() As String
- '''
- ''' When implemented in a derived class, gets the outer BBCode.
- '''
- ''' The BBCode of this instance of the .
- Public MustOverride ReadOnly Property OuterBBCode() As String
+ '''
+ ''' When implemented in a derived class, gets the outer BBCode.
+ '''
+ ''' The BBCode of this instance of the .
+ Public MustOverride ReadOnly Property OuterBBCode() As String
- '''
- ''' When implemented in a derived class, gets or sets the plain text of the node.
- '''
- ''' The plain text between the start and end tags.
- Public MustOverride Property InnerText() As String
+ '''
+ ''' When implemented in a derived class, gets or sets the plain text of the node.
+ '''
+ ''' The plain text between the start and end tags.
+ Public MustOverride Property InnerText() As String
- '''
- ''' Sets the of this instance.
- '''
- ''' The new parser of this instance.
- Friend Sub SetParser(ByVal parser As BBCodeParser)
- __Parser = parser
- End Sub
+ '''
+ ''' Sets the of this instance.
+ '''
+ ''' The new parser of this instance.
+ Friend Sub SetParser(ByVal parser As BBCodeParser(Of TContext))
+ __Parser = parser
+ End Sub
- '''
- ''' The the parent node of this instance of the .
- '''
- ''' The parent node.
- Protected Friend Sub SetParent(ByVal parentNode As BBCodeNode)
- Dim element = TryCast(parentNode, BBCodeElement)
- If (element Is Nothing) OrElse (String.IsNullOrEmpty(element.Name)) Then
- __Parent = Nothing
- Else
- __Parent = element
- End If
- End Sub
+ '''
+ ''' The the parent node of this instance of the .
+ '''
+ ''' The parent node.
+ Protected Friend Sub SetParent(ByVal parentNode As BBCodeNode(Of TContext))
+ Dim element = TryCast(parentNode, BBCodeElement(Of TContext))
+ If (element Is Nothing) OrElse (String.IsNullOrEmpty(element.Name)) Then
+ __Parent = Nothing
+ Else
+ __Parent = element
+ End If
+ End Sub
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNodeCollection.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNodeCollection.vb
index 7d0130b..62ebd4c 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNodeCollection.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeNodeCollection.vb
@@ -18,78 +18,78 @@
'''
''' Represents a collection of .
'''
-Public Class BBCodeNodeCollection
- Inherits ObjectModel.Collection(Of BBCodeNode)
+Public Class BBCodeNodeCollection(Of TContext As Class)
+ Inherits ObjectModel.Collection(Of BBCodeNode(Of TContext))
- Private __Owner As BBCodeNode
+ Private __Owner As BBCodeNode(Of TContext)
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Friend Sub New()
- End Sub
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Friend Sub New()
+ End Sub
- ''' Initializes an instance of the class.
- ''' The collection owner.
- ''' The argument is .
- Friend Sub New(ByVal owner As BBCodeNode)
- If (owner Is Nothing) Then
- Throw New ArgumentNullException("owner")
- End If
- __Owner = owner
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The collection owner.
+ ''' The argument is .
+ Friend Sub New(ByVal owner As BBCodeNode(Of TContext))
+ If (owner Is Nothing) Then
+ Throw New ArgumentNullException("owner")
+ End If
+ __Owner = owner
+ End Sub
- '''
- ''' Gets or sets the owner of the collection.
- '''
- Friend ReadOnly Property Owner() As BBCodeNode
- Get
- Return __Owner
- End Get
- End Property
+ '''
+ ''' Gets or sets the owner of the collection.
+ '''
+ Friend ReadOnly Property Owner() As BBCodeNode(Of TContext)
+ Get
+ Return __Owner
+ End Get
+ End Property
- ''' Adds an object to the end of the .
- ''' The object to be added to the end of the .
- ''' The argument is .
- Public Shadows Sub Add(ByVal node As BBCodeNode)
- If (node Is Nothing) Then
- Throw New ArgumentNullException("node")
- End If
- node.SetParent(Me.Owner)
- MyBase.Add(node)
- End Sub
+ ''' Adds an object to the end of the .
+ ''' The object to be added to the end of the .
+ ''' The argument is .
+ Public Shadows Sub Add(ByVal node As BBCodeNode(Of TContext))
+ If (node Is Nothing) Then
+ Throw New ArgumentNullException("node")
+ End If
+ node.SetParent(Me.Owner)
+ MyBase.Add(node)
+ End Sub
- ''' Adds the elements of the specified collection to the end of the .
- ''' The collection whose elements should be added to the end of the .
- ''' The argument is .
- Public Shadows Sub AddRange(ByVal collection As IEnumerable(Of BBCodeNode))
- If (collection Is Nothing) Then
- Throw New ArgumentNullException("collection")
- End If
- For Each n In collection
- Me.Add(n)
- Next
- End Sub
+ ''' Adds the elements of the specified collection to the end of the .
+ ''' The collection whose elements should be added to the end of the .
+ ''' The argument is .
+ Public Shadows Sub AddRange(ByVal collection As IEnumerable(Of BBCodeNode(Of TContext)))
+ If (collection Is Nothing) Then
+ Throw New ArgumentNullException("collection")
+ End If
+ For Each n In collection
+ Me.Add(n)
+ Next
+ End Sub
- '''
- ''' Inserts an element into the at the specified index.
- '''
- ''' The zero-based index at which item should be inserted.
- ''' The object to insert.
- Public Shadows Sub Insert(ByVal index As Integer, ByVal node As BBCodeNode)
- node.SetParent(Me.Owner)
- MyBase.Insert(index, node)
- End Sub
+ '''
+ ''' Inserts an element into the at the specified index.
+ '''
+ ''' The zero-based index at which item should be inserted.
+ ''' The object to insert.
+ Public Shadows Sub Insert(ByVal index As Integer, ByVal node As BBCodeNode(Of TContext))
+ node.SetParent(Me.Owner)
+ MyBase.Insert(index, node)
+ End Sub
- '''
- ''' Inserts the elements of a collection into the at the specified index.
- '''
- ''' The zero-based index at which item should be inserted.
- ''' The collection whose elements should be inserted into the .
- Public Shadows Sub InsertRange(ByVal index As Integer, ByVal collection As IEnumerable(Of BBCodeNode))
- For Each node In collection
- node.SetParent(Me.Owner)
- Next
- MyBase.Insert(index, collection)
- End Sub
+ '''
+ ''' Inserts the elements of a collection into the at the specified index.
+ '''
+ ''' The zero-based index at which item should be inserted.
+ ''' The collection whose elements should be inserted into the .
+ Public Shadows Sub InsertRange(ByVal index As Integer, ByVal collection As IEnumerable(Of BBCodeNode(Of TContext)))
+ For Each node In collection
+ node.SetParent(Me.Owner)
+ Next
+ MyBase.Insert(index, collection)
+ End Sub
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeParser.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeParser.vb
index 5ea6d8a..d5c2060 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeParser.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeParser.vb
@@ -21,320 +21,320 @@ Imports System.Diagnostics.CodeAnalysis
'''
''' The parser of
'''
-Public NotInheritable Class BBCodeParser
-
- Private __Factory As BBCodeElementFactory
- Private __Configuration As BBCodeConfiguration
-
- Private Shared ReadOnly __ConfigSerializer As New System.Xml.Serialization.XmlSerializer(GetType(BBCodeConfiguration))
- Private Shared ReadOnly __Tokenizer As Tokenization.Tokenizer = PrepareTokenizer()
-
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Public Sub New()
- End Sub
-
- '''
- ''' Gets the dictionary of elements to be replaced by the .
- '''
- Public ReadOnly Property Dictionary() As BBCodeElementDictionary
- Get
- If (__Configuration Is Nothing) Then
- __Configuration = New BBCodeConfiguration()
- End If
- Return __Configuration.Dictionary
- End Get
- End Property
-
- '''
- ''' Gets the dictionary of types created by the parser.
- '''
- Public ReadOnly Property ElementTypes() As BBCodeElementTypeDictionary
- Get
- If (__Configuration Is Nothing) Then
- __Configuration = New BBCodeConfiguration()
- End If
- Return __Configuration.ElementTypes
- End Get
- End Property
+Public NotInheritable Class BBCodeParser(Of TContext As Class)
+
+ Private __Factory As BBCodeElementFactory(Of TContext)
+ Private __Configuration As BBCodeConfiguration(Of TContext)
+
+ Private Shared ReadOnly __ConfigSerializer As New System.Xml.Serialization.XmlSerializer(GetType(BBCodeConfiguration(Of TContext)))
+ Private Shared ReadOnly __Tokenizer As Tokenization.Tokenizer = PrepareTokenizer()
+
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Public Sub New()
+ End Sub
+
+ '''
+ ''' Gets the dictionary of elements to be replaced by the .
+ '''
+ Public ReadOnly Property Dictionary() As BBCodeElementDictionary
+ Get
+ If (__Configuration Is Nothing) Then
+ __Configuration = New BBCodeConfiguration(Of TContext)()
+ End If
+ Return __Configuration.Dictionary
+ End Get
+ End Property
+
+ '''
+ ''' Gets the dictionary of types created by the parser.
+ '''
+ Public ReadOnly Property ElementTypes() As BBCodeElementTypeDictionary(Of TContext)
+ Get
+ If (__Configuration Is Nothing) Then
+ __Configuration = New BBCodeConfiguration(Of TContext)()
+ End If
+ Return __Configuration.ElementTypes
+ End Get
+ End Property
#Region " LoadConfiguration Methods "
- '''
- ''' Loads the configuration from the specified filename.
- '''
- ''' The name of the file to read the dictionary from.
- Public Sub LoadConfiguration(ByVal fileName As String)
- If (String.IsNullOrEmpty(fileName)) Then
- Throw New ArgumentNullException("fileName")
- End If
- Using fileStream As New IO.FileStream(fileName, IO.FileMode.Open)
- LoadConfiguration(fileStream)
- End Using
- End Sub
-
- '''
- ''' Loads the configuration from the specified .
- '''
- ''' A to read the dictionary from.
- Public Sub LoadConfiguration(ByVal stream As IO.Stream)
- LoadConfiguration(New IO.StreamReader(stream, Text.Encoding.UTF8, True))
- End Sub
-
- '''
- ''' Loads the configuration from the specified .
- '''
- ''' The to read the dictionary from.
- Public Sub LoadConfiguration(ByVal reader As IO.TextReader)
- Dim dic = __ConfigSerializer.Deserialize(reader)
- If (dic IsNot Nothing) Then
- __Configuration = dic
- End If
- End Sub
+ '''
+ ''' Loads the configuration from the specified filename.
+ '''
+ ''' The name of the file to read the dictionary from.
+ Public Sub LoadConfiguration(ByVal fileName As String)
+ If (String.IsNullOrEmpty(fileName)) Then
+ Throw New ArgumentNullException("fileName")
+ End If
+ Using fileStream As New IO.FileStream(fileName, IO.FileMode.Open)
+ LoadConfiguration(fileStream)
+ End Using
+ End Sub
+
+ '''
+ ''' Loads the configuration from the specified .
+ '''
+ ''' A to read the dictionary from.
+ Public Sub LoadConfiguration(ByVal stream As IO.Stream)
+ LoadConfiguration(New IO.StreamReader(stream, Text.Encoding.UTF8, True))
+ End Sub
+
+ '''
+ ''' Loads the configuration from the specified .
+ '''
+ ''' The to read the dictionary from.
+ Public Sub LoadConfiguration(ByVal reader As IO.TextReader)
+ Dim dic = __ConfigSerializer.Deserialize(reader)
+ If (dic IsNot Nothing) Then
+ __Configuration = dic
+ End If
+ End Sub
#End Region
#Region " SaveConfiguration Methods "
- '''
- ''' Saves the conficuration to the specified file.
- '''
- ''' The name of the file to save the dictionary.
- Public Sub SaveConfiguration(ByVal fileName As String)
- If (String.IsNullOrEmpty(fileName)) Then
- Throw New ArgumentNullException("fileName")
- End If
- Using fileStream As New IO.FileStream(fileName, IO.FileMode.Create)
- SaveConfiguration(fileStream)
- End Using
- End Sub
-
- '''
- ''' Saves the conficuration to the specified .
- '''
- ''' The to save the dictionary.
- Public Sub SaveConfiguration(ByVal stream As IO.Stream)
- SaveConfiguration(New IO.StreamWriter(stream, Text.Encoding.UTF8))
- End Sub
-
- '''
- ''' Saves the conficuration to the specified .
- '''
- ''' The to save the dictionary.
- Public Sub SaveConfiguration(ByVal writer As IO.TextWriter)
- __ConfigSerializer.Serialize(writer, __Configuration)
- End Sub
+ '''
+ ''' Saves the conficuration to the specified file.
+ '''
+ ''' The name of the file to save the dictionary.
+ Public Sub SaveConfiguration(ByVal fileName As String)
+ If (String.IsNullOrEmpty(fileName)) Then
+ Throw New ArgumentNullException("fileName")
+ End If
+ Using fileStream As New IO.FileStream(fileName, IO.FileMode.Create)
+ SaveConfiguration(fileStream)
+ End Using
+ End Sub
+
+ '''
+ ''' Saves the conficuration to the specified .
+ '''
+ ''' The to save the dictionary.
+ Public Sub SaveConfiguration(ByVal stream As IO.Stream)
+ SaveConfiguration(New IO.StreamWriter(stream, Text.Encoding.UTF8))
+ End Sub
+
+ '''
+ ''' Saves the conficuration to the specified .
+ '''
+ ''' The to save the dictionary.
+ Public Sub SaveConfiguration(ByVal writer As IO.TextWriter)
+ __ConfigSerializer.Serialize(writer, __Configuration)
+ End Sub
#End Region
#Region " Parse Methods "
- '''
- ''' Parses the specified text, returning a collection of .
- '''
- ''' The text to be parsed.
- ''' A containing the parsed text.
- Public Function Parse(ByVal text As String) As BBCodeDocument
- Using reader As New IO.StringReader(text)
- Return Parse(reader)
- End Using
- End Function
-
- '''
- ''' Parses the specified stream, returning a collection of .
- '''
- ''' The to be parsed.
- ''' A containing the parsed .
- Public Function Parse(ByVal stream As IO.Stream) As BBCodeDocument
- Return Parse(stream, Text.Encoding.UTF8)
- End Function
-
- '''
- ''' Parses the specified stream, returning a collection of .
- '''
- ''' The to be parsed.
- ''' The encoding of the stream.
- ''' A containing the parsed .
- Public Function Parse(ByVal stream As IO.Stream, ByVal encoding As Text.Encoding) As BBCodeDocument
- Return Parse(New IO.StreamReader(stream, encoding))
- End Function
-
- '''
- ''' Parses the specified , returning a collection of .
- '''
- ''' The to be parsed.
- ''' A containing the parsed .
- Public Function Parse(ByVal reader As IO.TextReader) As BBCodeDocument
-
- Dim doc = New BBCodeDocument(Me)
- Dim rootElement As New BBCodeElement(Me)
- Dim currentElement As BBCodeElement = rootElement
-
- Dim tk As Tokenization.Token
- Dim sb As New Text.StringBuilder()
- Dim sbText As New Text.StringBuilder()
- Do While (reader.Peek() <> -1)
- Dim line As String = reader.ReadLine() & vbCrLf
- sbText.AppendLine(line)
- Do
- '*
- '* Get the next token
- '*
- tk = Tokenizer.GetToken(line)
- If (tk Is Nothing) Then
- Exit Do
- End If
-
- Dim tag = New BBCodeTag(tk.Value)
-
- ParseElement(rootElement, currentElement, tk, sb, tag)
- Loop
- Loop
-
- '*
- '* Add the text node
- '*
- If (sb.Length > 0) Then
- currentElement.Nodes.Add(New BBCodeText(sb.ToString()))
- End If
-
- '*
- '* Add the nodes to the document
- '*
- doc.Nodes.AddRange(rootElement.Nodes)
-
- '*
- '* Sets the source text
- '*
- doc.SetText(sbText.ToString())
-
- Return doc
-
- End Function
+ '''
+ ''' Parses the specified text, returning a collection of .
+ '''
+ ''' The text to be parsed.
+ ''' A containing the parsed text.
+ Public Function Parse(ByVal text As String) As BBCodeDocument(Of TContext)
+ Using reader As New IO.StringReader(text)
+ Return Parse(reader)
+ End Using
+ End Function
+
+ '''
+ ''' Parses the specified stream, returning a collection of .
+ '''
+ ''' The to be parsed.
+ ''' A containing the parsed .
+ Public Function Parse(ByVal stream As IO.Stream) As BBCodeDocument(Of TContext)
+ Return Parse(stream, Text.Encoding.UTF8)
+ End Function
+
+ '''
+ ''' Parses the specified stream, returning a collection of .
+ '''
+ ''' The to be parsed.
+ ''' The encoding of the stream.
+ ''' A containing the parsed .
+ Public Function Parse(ByVal stream As IO.Stream, ByVal encoding As Text.Encoding) As BBCodeDocument(Of TContext)
+ Return Parse(New IO.StreamReader(stream, encoding))
+ End Function
+
+ '''
+ ''' Parses the specified , returning a collection of .
+ '''
+ ''' The to be parsed.
+ ''' A containing the parsed .
+ Public Function Parse(ByVal reader As IO.TextReader) As BBCodeDocument(Of TContext)
+
+ Dim doc = New BBCodeDocument(Of TContext)(Me)
+ Dim rootElement As New BBCodeElement(Of TContext)(Me)
+ Dim currentElement As BBCodeElement(Of TContext) = rootElement
+
+ Dim tk As Tokenization.Token
+ Dim sb As New Text.StringBuilder()
+ Dim sbText As New Text.StringBuilder()
+ Do While (reader.Peek() <> -1)
+ Dim line As String = reader.ReadLine() & vbCrLf
+ sbText.AppendLine(line)
+ Do
+ '*
+ '* Get the next token
+ '*
+ tk = Tokenizer.GetToken(line)
+ If (tk Is Nothing) Then
+ Exit Do
+ End If
+
+ Dim tag = New BBCodeTag(tk.Value)
+
+ ParseElement(rootElement, currentElement, tk, sb, tag)
+ Loop
+ Loop
+
+ '*
+ '* Add the text node
+ '*
+ If (sb.Length > 0) Then
+ currentElement.Nodes.Add(New BBCodeText(Of TContext)(sb.ToString()))
+ End If
+
+ '*
+ '* Add the nodes to the document
+ '*
+ doc.Nodes.AddRange(rootElement.Nodes)
+
+ '*
+ '* Sets the source text
+ '*
+ doc.SetText(sbText.ToString())
+
+ Return doc
+
+ End Function
#End Region
- '''
- ''' Gets the .
- '''
- Private Shared ReadOnly Property Tokenizer() As Tokenization.Tokenizer
- Get
- Return __Tokenizer
- End Get
- End Property
-
- '''
- ''' Gets the .
- '''
- Private ReadOnly Property Factory() As BBCodeElementFactory
- Get
- If (__Factory Is Nothing) Then
- __Factory = New BBCodeElementFactory(Me)
- End If
- Return __Factory
- End Get
- End Property
-
- Private Sub ParseElement(ByVal rootElement As BBCodeElement, ByRef currentElement As BBCodeElement, ByVal token As Tokenization.Token, ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
-
- '*
- '* Check the token Type
- '*
- Select Case token.RuleType
- Case 0, -1
- '*
- '* Empty tag or char
- '*
- sb.Append(token.Value)
- Case 1
- '*
- '* Closing tag
- '*
-
- ParseClosingTag(rootElement, currentElement, token, sb, tag)
- Case 2, 3, 4
- '*
- '* Value Tag, Parametrized Tag, Generic Tag
- '*
- ParseTag(currentElement, sb, tag)
- End Select
-
- End Sub
-
- Private Sub ParseTag(ByRef currentElement As BBCodeElement, ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
-
- '*
- '* Add the text previous to the current element
- '*
- If (sb.Length > 0) Then
- currentElement.Nodes.Add(New BBCodeText(sb.ToString()))
- sb.Remove(0, sb.Length)
- End If
-
- '*
- '* Add the new element to the list of nodes
- '*
- Dim el = Factory.CreateElement(tag.Name, tag.Paramters)
- currentElement.Nodes.Add(el)
-
- '*
- '* Change the current element, if it requires an closing tag
- '*
- If (el.RequireClosingTag) Then
- currentElement = el
- End If
-
- End Sub
-
- Private Shared Sub ParseClosingTag(ByVal rootElement As BBCodeElement, ByRef currentElement As BBCodeElement, ByVal token As Tokenization.Token, ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
-
- '*
- '* Check if the closing tag is closing a previously open tag
- '*
- If currentElement.RequireClosingTag AndAlso (String.CompareOrdinal(currentElement.Name, tag.Name) = 0) Then
- '*
- '* Add the inner text
- '*
- If (sb.Length > 0) Then
- currentElement.Nodes.Add(New BBCodeText(sb.ToString()))
- sb.Remove(0, sb.Length)
- End If
-
- '*
- '* Move up a level
- '*
- currentElement = If(currentElement.Parent, rootElement)
- Else
- '*
- '* Adds to the text
- '*
- sb.Append(token.Value)
- End If
-
- End Sub
-
- Private Shared Function PrepareTokenizer() As Tokenization.Tokenizer
- Dim tk As New Tokenization.Tokenizer
- '*
- '* Prepares the BBCode Grammar
- '*
- With tk
- '*
- '* Define the grammar macros
- '*
- AddTokenizerBaseMacros(tk)
-
- '*
- '* Define the grammar rules
- '*
- .AddRule("EmptyTag", 0, "\[{w}\]")
- .AddRule("ClosingTag", 1, "\[/{name}\]")
- .AddRule("ValueTag", 2, "\[{param}\]")
- .AddRule("ParamsTag", 3, "\[{name}{params}\]")
- .AddRule("Tag", 4, "\[[^ \t\r\n\f\]]+?\]")
- .AddRule("Char", -1, ".")
- End With
- Return tk
- End Function
+ '''
+ ''' Gets the .
+ '''
+ Private Shared ReadOnly Property Tokenizer() As Tokenization.Tokenizer
+ Get
+ Return __Tokenizer
+ End Get
+ End Property
+
+ '''
+ ''' Gets the .
+ '''
+ Private ReadOnly Property Factory() As BBCodeElementFactory(Of TContext)
+ Get
+ If (__Factory Is Nothing) Then
+ __Factory = New BBCodeElementFactory(Of TContext)(Me)
+ End If
+ Return __Factory
+ End Get
+ End Property
+
+ Private Sub ParseElement(ByVal rootElement As BBCodeElement(Of TContext), ByRef currentElement As BBCodeElement(Of TContext), ByVal token As Tokenization.Token, ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
+
+ '*
+ '* Check the token Type
+ '*
+ Select Case token.RuleType
+ Case 0, -1
+ '*
+ '* Empty tag or char
+ '*
+ sb.Append(token.Value)
+ Case 1
+ '*
+ '* Closing tag
+ '*
+
+ ParseClosingTag(rootElement, currentElement, token, sb, tag)
+ Case 2, 3, 4
+ '*
+ '* Value Tag, Parametrized Tag, Generic Tag
+ '*
+ ParseTag(currentElement, sb, tag)
+ End Select
+
+ End Sub
+
+ Private Sub ParseTag(ByRef currentElement As BBCodeElement(Of TContext), ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
+
+ '*
+ '* Add the text previous to the current element
+ '*
+ If (sb.Length > 0) Then
+ currentElement.Nodes.Add(New BBCodeText(Of TContext)(sb.ToString()))
+ sb.Remove(0, sb.Length)
+ End If
+
+ '*
+ '* Add the new element to the list of nodes
+ '*
+ Dim el = Factory.CreateElement(tag.Name, tag.Paramters)
+ currentElement.Nodes.Add(el)
+
+ '*
+ '* Change the current element, if it requires an closing tag
+ '*
+ If (el.RequireClosingTag) Then
+ currentElement = el
+ End If
+
+ End Sub
+
+ Private Shared Sub ParseClosingTag(ByVal rootElement As BBCodeElement(Of TContext), ByRef currentElement As BBCodeElement(Of TContext), ByVal token As Tokenization.Token, ByVal sb As Text.StringBuilder, ByVal tag As BBCodeTag)
+
+ '*
+ '* Check if the closing tag is closing a previously open tag
+ '*
+ If currentElement.RequireClosingTag AndAlso (String.CompareOrdinal(currentElement.Name, tag.Name) = 0) Then
+ '*
+ '* Add the inner text
+ '*
+ If (sb.Length > 0) Then
+ currentElement.Nodes.Add(New BBCodeText(Of TContext)(sb.ToString()))
+ sb.Remove(0, sb.Length)
+ End If
+
+ '*
+ '* Move up a level
+ '*
+ currentElement = If(currentElement.Parent, rootElement)
+ Else
+ '*
+ '* Adds to the text
+ '*
+ sb.Append(token.Value)
+ End If
+
+ End Sub
+
+ Private Shared Function PrepareTokenizer() As Tokenization.Tokenizer
+ Dim tk As New Tokenization.Tokenizer
+ '*
+ '* Prepares the BBCode Grammar
+ '*
+ With tk
+ '*
+ '* Define the grammar macros
+ '*
+ AddTokenizerBaseMacros(tk)
+
+ '*
+ '* Define the grammar rules
+ '*
+ .AddRule("EmptyTag", 0, "\[{w}\]")
+ .AddRule("ClosingTag", 1, "\[/{name}\]")
+ .AddRule("ValueTag", 2, "\[{param}\]")
+ .AddRule("ParamsTag", 3, "\[{name}{params}\]")
+ .AddRule("Tag", 4, "\[[^ \t\r\n\f\]]+?\]")
+ .AddRule("Char", -1, ".")
+ End With
+ Return tk
+ End Function
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeText.vb b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeText.vb
index 8ebc004..df1204e 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeText.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Classes/BBCodeText.vb
@@ -18,64 +18,64 @@
'''
''' Represents a simple text in the BBCode.
'''
-Public NotInheritable Class BBCodeText
- Inherits BBCodeNode
+Public NotInheritable Class BBCodeText(Of TContext As Class)
+ Inherits BBCodeNode(Of TContext)
- Private __InnerText As String
+ Private __InnerText As String
- ''' Initializes an instance of the class.
- ''' This is the default constructor for this class.
- Friend Sub New()
- End Sub
+ ''' Initializes an instance of the class.
+ ''' This is the default constructor for this class.
+ Friend Sub New()
+ End Sub
- ''' Initializes an instance of the class.
- ''' The text of the .
- Friend Sub New(ByVal text As String)
- Me.InnerText = text
- End Sub
+ ''' Initializes an instance of the class.
+ ''' The text of the .
+ Friend Sub New(ByVal text As String)
+ Me.InnerText = text
+ End Sub
- ''' Transforms this instance of into its desired text representation.
- ''' An object that implements the interface.
- ''' The text formatted by the .
- Public Overrides Function Format(ByVal formatter As ITextFormatter) As String
- Return formatter.Format(__InnerText)
- End Function
+ ''' Transforms this instance of into its desired text representation.
+ ''' An object that implements the interface.
+ ''' The text formatted by the .
+ Public Overrides Function Format(ByVal context As TContext, ByVal formatter As ITextFormatter) As String
+ Return formatter.Format(__InnerText)
+ End Function
- ''' Gets or sets the inner BBCode.
- ''' The BBCode between the start and end tags.
- Public Overrides Property InnerBBCode() As String
- Get
- Return Me.InnerText
- End Get
- Set(ByVal value As String)
- Me.InnerText = value
- End Set
- End Property
+ ''' Gets or sets the inner BBCode.
+ ''' The BBCode between the start and end tags.
+ Public Overrides Property InnerBBCode() As String
+ Get
+ Return Me.InnerText
+ End Get
+ Set(ByVal value As String)
+ Me.InnerText = value
+ End Set
+ End Property
- ''' Gets or sets the plain text of the node.
- ''' The plain text between the start and end tags.
- Public Overrides Property InnerText() As String
- Get
- Return __InnerText
- End Get
- Set(ByVal value As String)
- __InnerText = value
- End Set
- End Property
+ ''' Gets or sets the plain text of the node.
+ ''' The plain text between the start and end tags.
+ Public Overrides Property InnerText() As String
+ Get
+ Return __InnerText
+ End Get
+ Set(ByVal value As String)
+ __InnerText = value
+ End Set
+ End Property
- ''' Gets the outer BBCode.
- ''' The BBCode of this instance of the .
- Public Overrides ReadOnly Property OuterBBCode() As String
- Get
- Return Me.InnerText
- End Get
- End Property
+ ''' Gets the outer BBCode.
+ ''' The BBCode of this instance of the .
+ Public Overrides ReadOnly Property OuterBBCode() As String
+ Get
+ Return Me.InnerText
+ End Get
+ End Property
- ''' Returns a that represents the current .
- ''' A that represents the current .
- ''' 2
- Public Overrides Function ToString() As String
- Return Me.InnerText
- End Function
+ ''' Returns a that represents the current .
+ ''' A that represents the current .
+ ''' 2
+ Public Overrides Function ToString() As String
+ Return Me.InnerText
+ End Function
End Class
diff --git a/ThirdParty/PJonDevelopment.BBCode/Modules/Utils.vb b/ThirdParty/PJonDevelopment.BBCode/Modules/Utils.vb
index 4d1c22c..8840d6a 100644
--- a/ThirdParty/PJonDevelopment.BBCode/Modules/Utils.vb
+++ b/ThirdParty/PJonDevelopment.BBCode/Modules/Utils.vb
@@ -20,392 +20,392 @@ Imports System.Diagnostics.CodeAnalysis
Friend Module Utils
- Public Const STR_BBCodeSchemaNamespace As String = "" '= "http://pjondevelopment.50webs.com/schema/bbcode"
- Public Const STR_BBCodeDictionaryXmlElement As String = "Dictionary"
- Public Const STR_BBCodeElementTypesXmlElement As String = "ElementTypes"
- Public Const STR_BBCodeConfigurationXmlElement As String = "Configuration"
+ Public Const STR_BBCodeSchemaNamespace As String = "" '= "http://pjondevelopment.50webs.com/schema/bbcode"
+ Public Const STR_BBCodeDictionaryXmlElement As String = "Dictionary"
+ Public Const STR_BBCodeElementTypesXmlElement As String = "ElementTypes"
+ Public Const STR_BBCodeConfigurationXmlElement As String = "Configuration"
- '''
- ''' Returns the specified text between quotes.
- '''
- ''' The text to be placed between quotes.
- ''' The text between quotes.
- Public Function Quote(ByVal text As String) As String
- Return "'" & text.Replace("'", "''") & "'"
- End Function
+ '''
+ ''' Returns the specified text between quotes.
+ '''
+ ''' The text to be placed between quotes.
+ ''' The text between quotes.
+ Public Function Quote(ByVal text As String) As String
+ Return "'" & text.Replace("'", "''") & "'"
+ End Function
- '''
- ''' Unquotes the specified text.
- '''
- ''' The text to be unquoted.
- ''' The unquoted text.
- Public Function UnQuote(ByVal text As String) As String
- Dim rx As New Text.RegularExpressions.Regex("^(?'(?(?:''|[^'])*)')|(?""(?(?:""""|[^""])*)"")$")
- Dim m = rx.Match(text)
- If (Not m.Success) Then
- Return text
- End If
- If (m.Groups("quote").Success) Then
- Return m.Groups("text").Value.Replace("''", "'")
- End If
- Return m.Groups("text").Value.Replace("""""", """")
- End Function
+ '''
+ ''' Unquotes the specified text.
+ '''
+ ''' The text to be unquoted.
+ ''' The unquoted text.
+ Public Function UnQuote(ByVal text As String) As String
+ Dim rx As New Text.RegularExpressions.Regex("^(?'(?(?:''|[^'])*)')|(?""(?(?:""""|[^""])*)"")$")
+ Dim m = rx.Match(text)
+ If (Not m.Success) Then
+ Return text
+ End If
+ If (m.Groups("quote").Success) Then
+ Return m.Groups("text").Value.Replace("''", "'")
+ End If
+ Return m.Groups("text").Value.Replace("""""", """")
+ End Function
- '''
- ''' Validates the specified tag name.
- '''
- ''' The tagname to be validated.
- Public Sub ValidateTagName(ByVal tagName As String)
- If (String.IsNullOrEmpty(tagName)) Then
- Throw New ArgumentNullException("tagName")
- End If
- If (tagName.IndexOf("=", StringComparison.Ordinal) <> -1) OrElse (tagName.IndexOf("[", StringComparison.Ordinal) <> -1) OrElse (tagName.IndexOf("]", StringComparison.Ordinal) <> -1) Then
- Throw New ArgumentException("Invalid tag name. The tag name cannot contain '=' '[' or ']'.", "tagName")
- End If
- End Sub
+ '''
+ ''' Validates the specified tag name.
+ '''
+ ''' The tagname to be validated.
+ Public Sub ValidateTagName(ByVal tagName As String)
+ If (String.IsNullOrEmpty(tagName)) Then
+ Throw New ArgumentNullException("tagName")
+ End If
+ If (tagName.IndexOf("=", StringComparison.Ordinal) <> -1) OrElse (tagName.IndexOf("[", StringComparison.Ordinal) <> -1) OrElse (tagName.IndexOf("]", StringComparison.Ordinal) <> -1) Then
+ Throw New ArgumentException("Invalid tag name. The tag name cannot contain '=' '[' or ']'.", "tagName")
+ End If
+ End Sub
- '''
- ''' Validates the specified type to ensure that it is a subclass of .
- '''
- ''' The to be validated.
- Public Sub ValidateBBCodeElementType(ByVal value As Type)
+ '''
+ ''' Validates the specified type to ensure that it is a subclass of .
+ '''
+ ''' The to be validated.
+ Public Sub ValidateBBCodeElementType(Of TContext As Class)(ByVal value As Type)
- '*
- '* Validate is nothing
- '*
- If (value Is Nothing) Then
- Throw New ArgumentNullException("value")
- End If
+ '*
+ '* Validate is nothing
+ '*
+ If (value Is Nothing) Then
+ Throw New ArgumentNullException("value")
+ End If
- '*
- '* Validates the BBCodeElement itself
- '*
- Dim bbcodeType = GetType(BBCodeElement)
- If (value.Equals(bbcodeType)) Then
- Exit Sub
- End If
+ '*
+ '* Validates the BBCodeElement itself
+ '*
+ Dim bbcodeType = GetType(BBCodeElement(Of TContext))
+ If (value.Equals(bbcodeType)) Then
+ Exit Sub
+ End If
- '*
- '* Validate subclass
- '*
- If Not bbcodeType.IsAssignableFrom(value) Then
- Throw New InvalidOperationException("The type " & value.FullName & " must be a assingable to BBCodeElement.")
- End If
+ '*
+ '* Validate subclass
+ '*
+ If Not bbcodeType.IsAssignableFrom(value) Then
+ Throw New InvalidOperationException("The type " & value.FullName & " must be a assingable to BBCodeElement.")
+ End If
- '*
- '* Validate default constructor
- '*
- If (value.GetConstructor(New Type() {}) Is Nothing) Then
- Throw New InvalidOperationException("The type " & value.FullName & " does not provide a public default constructor.")
- End If
+ '*
+ '* Validate default constructor
+ '*
+ If (value.GetConstructor(New Type() {}) Is Nothing) Then
+ Throw New InvalidOperationException("The type " & value.FullName & " does not provide a public default constructor.")
+ End If
- End Sub
+ End Sub
- '''
- ''' Encodes the specified text as HTML.
- '''
- ''' The text to be encoded.
- ''' The encoded HTML.
- _
- Public Function HtmlEncode(ByVal text As String) As String
- Dim sb As New Text.StringBuilder(text)
- sb.Replace(ChrW(&H26), "&")
- sb.Replace(ChrW(&H22), """)
- sb.Replace(ChrW(&H27), "'")
- sb.Replace(ChrW(&H3C), "<")
- sb.Replace(ChrW(&H3E), ">")
- sb.Replace(ChrW(&HA0), " ")
- sb.Replace(ChrW(&HA1), "¡")
- sb.Replace(ChrW(&HA2), "¢")
- sb.Replace(ChrW(&HA3), "£")
- sb.Replace(ChrW(&HA4), "¤")
- sb.Replace(ChrW(&HA5), "¥")
- sb.Replace(ChrW(&HA6), "¦")
- sb.Replace(ChrW(&HA7), "§")
- sb.Replace(ChrW(&HA8), "¨")
- sb.Replace(ChrW(&HA9), "©")
- sb.Replace(ChrW(&HAA), "ª")
- sb.Replace(ChrW(&HAB), "«")
- sb.Replace(ChrW(&HAC), "¬")
- sb.Replace(ChrW(&HAD), "")
- sb.Replace(ChrW(&HAE), "®")
- sb.Replace(ChrW(&HAF), "¯")
- sb.Replace(ChrW(&HB0), "°")
- sb.Replace(ChrW(&HB1), "±")
- sb.Replace(ChrW(&HB2), "²")
- sb.Replace(ChrW(&HB3), "³")
- sb.Replace(ChrW(&HB4), "´")
- sb.Replace(ChrW(&HB5), "µ")
- sb.Replace(ChrW(&HB6), "¶")
- sb.Replace(ChrW(&HB7), "·")
- sb.Replace(ChrW(&HB8), "¸")
- sb.Replace(ChrW(&HB9), "¹")
- sb.Replace(ChrW(&HBA), "º")
- sb.Replace(ChrW(&HBB), "»")
- sb.Replace(ChrW(&HBC), "¼")
- sb.Replace(ChrW(&HBD), "½")
- sb.Replace(ChrW(&HBE), "¾")
- sb.Replace(ChrW(&HBF), "¿")
- sb.Replace(ChrW(&HC0), "À")
- sb.Replace(ChrW(&HC1), "Á")
- sb.Replace(ChrW(&HC2), "Â")
- sb.Replace(ChrW(&HC3), "Ã")
- sb.Replace(ChrW(&HC4), "Ä")
- sb.Replace(ChrW(&HC5), "Å")
- sb.Replace(ChrW(&HC6), "Æ")
- sb.Replace(ChrW(&HC7), "Ç")
- sb.Replace(ChrW(&HC8), "È")
- sb.Replace(ChrW(&HC9), "É")
- sb.Replace(ChrW(&HCA), "Ê")
- sb.Replace(ChrW(&HCB), "Ë")
- sb.Replace(ChrW(&HCC), "Ì")
- sb.Replace(ChrW(&HCD), "Í")
- sb.Replace(ChrW(&HCE), "Î")
- sb.Replace(ChrW(&HCF), "Ï")
- sb.Replace(ChrW(&HD0), "Ð")
- sb.Replace(ChrW(&HD1), "Ñ")
- sb.Replace(ChrW(&HD2), "Ò")
- sb.Replace(ChrW(&HD3), "Ó")
- sb.Replace(ChrW(&HD4), "Ô")
- sb.Replace(ChrW(&HD5), "Õ")
- sb.Replace(ChrW(&HD6), "Ö")
- sb.Replace(ChrW(&HD7), "×")
- sb.Replace(ChrW(&HD8), "Ø")
- sb.Replace(ChrW(&HD9), "Ù")
- sb.Replace(ChrW(&HDA), "Ú")
- sb.Replace(ChrW(&HDB), "Û")
- sb.Replace(ChrW(&HDC), "Ü")
- sb.Replace(ChrW(&HDD), "Ý")
- sb.Replace(ChrW(&HDE), "Þ")
- sb.Replace(ChrW(&HDF), "ß")
- sb.Replace(ChrW(&HE0), "à")
- sb.Replace(ChrW(&HE1), "á")
- sb.Replace(ChrW(&HE2), "â")
- sb.Replace(ChrW(&HE3), "ã")
- sb.Replace(ChrW(&HE4), "ä")
- sb.Replace(ChrW(&HE5), "å")
- sb.Replace(ChrW(&HE6), "æ")
- sb.Replace(ChrW(&HE7), "ç")
- sb.Replace(ChrW(&HE8), "è")
- sb.Replace(ChrW(&HE9), "é")
- sb.Replace(ChrW(&HEA), "ê")
- sb.Replace(ChrW(&HEB), "ë")
- sb.Replace(ChrW(&HEC), "ì")
- sb.Replace(ChrW(&HED), "í")
- sb.Replace(ChrW(&HEE), "î")
- sb.Replace(ChrW(&HEF), "ï")
- sb.Replace(ChrW(&HF0), "ð")
- sb.Replace(ChrW(&HF1), "ñ")
- sb.Replace(ChrW(&HF2), "ò")
- sb.Replace(ChrW(&HF3), "ó")
- sb.Replace(ChrW(&HF4), "ô")
- sb.Replace(ChrW(&HF5), "õ")
- sb.Replace(ChrW(&HF6), "ö")
- sb.Replace(ChrW(&HF7), "÷")
- sb.Replace(ChrW(&HF8), "ø")
- sb.Replace(ChrW(&HF9), "ù")
- sb.Replace(ChrW(&HFA), "ú")
- sb.Replace(ChrW(&HFB), "û")
- sb.Replace(ChrW(&HFC), "ü")
- sb.Replace(ChrW(&HFD), "ý")
- sb.Replace(ChrW(&HFE), "þ")
- sb.Replace(ChrW(&HFF), "ÿ")
- sb.Replace(ChrW(&H152), "Œ")
- sb.Replace(ChrW(&H153), "œ")
- sb.Replace(ChrW(&H160), "Š")
- sb.Replace(ChrW(&H161), "š")
- sb.Replace(ChrW(&H178), "Ÿ")
- sb.Replace(ChrW(&H192), "ƒ")
- sb.Replace(ChrW(&H2C6), "ˆ")
- sb.Replace(ChrW(&H2DC), "˜")
- sb.Replace(ChrW(&H391), "Α")
- sb.Replace(ChrW(&H392), "Β")
- sb.Replace(ChrW(&H393), "Γ")
- sb.Replace(ChrW(&H394), "Δ")
- sb.Replace(ChrW(&H395), "Ε")
- sb.Replace(ChrW(&H396), "Ζ")
- sb.Replace(ChrW(&H397), "Η")
- sb.Replace(ChrW(&H398), "Θ")
- sb.Replace(ChrW(&H399), "Ι")
- sb.Replace(ChrW(&H39A), "Κ")
- sb.Replace(ChrW(&H39B), "Λ")
- sb.Replace(ChrW(&H39C), "Μ")
- sb.Replace(ChrW(&H39D), "Ν")
- sb.Replace(ChrW(&H39E), "Ξ")
- sb.Replace(ChrW(&H39F), "Ο")
- sb.Replace(ChrW(&H3A0), "Π")
- sb.Replace(ChrW(&H3A1), "Ρ")
- sb.Replace(ChrW(&H3A3), "Σ")
- sb.Replace(ChrW(&H3A4), "Τ")
- sb.Replace(ChrW(&H3A5), "Υ")
- sb.Replace(ChrW(&H3A6), "Φ")
- sb.Replace(ChrW(&H3A7), "Χ")
- sb.Replace(ChrW(&H3A8), "Ψ")
- sb.Replace(ChrW(&H3A9), "Ω")
- sb.Replace(ChrW(&H3B1), "α")
- sb.Replace(ChrW(&H3B2), "β")
- sb.Replace(ChrW(&H3B3), "γ")
- sb.Replace(ChrW(&H3B4), "δ")
- sb.Replace(ChrW(&H3B5), "ε")
- sb.Replace(ChrW(&H3B6), "ζ")
- sb.Replace(ChrW(&H3B7), "η")
- sb.Replace(ChrW(&H3B8), "θ")
- sb.Replace(ChrW(&H3B9), "ι")
- sb.Replace(ChrW(&H3BA), "κ")
- sb.Replace(ChrW(&H3BB), "λ")
- sb.Replace(ChrW(&H3BC), "μ")
- sb.Replace(ChrW(&H3BD), "ν")
- sb.Replace(ChrW(&H3BE), "ξ")
- sb.Replace(ChrW(&H3BF), "ο")
- sb.Replace(ChrW(&H3C0), "π")
- sb.Replace(ChrW(&H3C1), "ρ")
- sb.Replace(ChrW(&H3C2), "ς")
- sb.Replace(ChrW(&H3C3), "σ")
- sb.Replace(ChrW(&H3C4), "τ")
- sb.Replace(ChrW(&H3C5), "υ")
- sb.Replace(ChrW(&H3C6), "φ")
- sb.Replace(ChrW(&H3C7), "χ")
- sb.Replace(ChrW(&H3C8), "ψ")
- sb.Replace(ChrW(&H3C9), "ω")
- sb.Replace(ChrW(&H3D1), "ϑ")
- sb.Replace(ChrW(&H3D2), "ϒ")
- sb.Replace(ChrW(&H3D6), "ϖ")
- sb.Replace(ChrW(&H2002), " ")
- sb.Replace(ChrW(&H2003), " ")
- sb.Replace(ChrW(&H2009), " ")
- sb.Replace(ChrW(&H200C), "")
- sb.Replace(ChrW(&H200D), "")
- sb.Replace(ChrW(&H200E), "")
- sb.Replace(ChrW(&H200F), "")
- sb.Replace(ChrW(&H2013), "–")
- sb.Replace(ChrW(&H2014), "—")
- sb.Replace(ChrW(&H2018), "‘")
- sb.Replace(ChrW(&H2019), "’")
- sb.Replace(ChrW(&H201A), "‚")
- sb.Replace(ChrW(&H201C), "“")
- sb.Replace(ChrW(&H201D), "”")
- sb.Replace(ChrW(&H201E), "„")
- sb.Replace(ChrW(&H2020), "†")
- sb.Replace(ChrW(&H2021), "‡")
- sb.Replace(ChrW(&H2022), "•")
- sb.Replace(ChrW(&H2026), "…")
- sb.Replace(ChrW(&H2030), "‰")
- sb.Replace(ChrW(&H2032), "′")
- sb.Replace(ChrW(&H2033), "″")
- sb.Replace(ChrW(&H2039), "‹")
- sb.Replace(ChrW(&H203A), "›")
- sb.Replace(ChrW(&H203E), "‾")
- sb.Replace(ChrW(&H2044), "⁄")
- sb.Replace(ChrW(&H20AC), "€")
- sb.Replace(ChrW(&H2111), "ℑ")
- sb.Replace(ChrW(&H2118), "℘")
- sb.Replace(ChrW(&H211C), "ℜ")
- sb.Replace(ChrW(&H2122), "™")
- sb.Replace(ChrW(&H2135), "ℵ")
- sb.Replace(ChrW(&H2190), "←")
- sb.Replace(ChrW(&H2191), "↑")
- sb.Replace(ChrW(&H2192), "→")
- sb.Replace(ChrW(&H2193), "↓")
- sb.Replace(ChrW(&H2194), "↔")
- sb.Replace(ChrW(&H21B5), "↵")
- sb.Replace(ChrW(&H21D0), "⇐")
- sb.Replace(ChrW(&H21D1), "⇑")
- sb.Replace(ChrW(&H21D2), "⇒")
- sb.Replace(ChrW(&H21D3), "⇓")
- sb.Replace(ChrW(&H21D4), "⇔")
- sb.Replace(ChrW(&H2200), "∀")
- sb.Replace(ChrW(&H2202), "∂")
- sb.Replace(ChrW(&H2203), "∃")
- sb.Replace(ChrW(&H2205), "∅")
- sb.Replace(ChrW(&H2207), "∇")
- sb.Replace(ChrW(&H2208), "∈")
- sb.Replace(ChrW(&H2209), "∉")
- sb.Replace(ChrW(&H220B), "∋")
- sb.Replace(ChrW(&H220F), "∏")
- sb.Replace(ChrW(&H2211), "∑")
- sb.Replace(ChrW(&H2212), "−")
- sb.Replace(ChrW(&H2217), "∗")
- sb.Replace(ChrW(&H221A), "√")
- sb.Replace(ChrW(&H221D), "∝")
- sb.Replace(ChrW(&H221E), "∞")
- sb.Replace(ChrW(&H2220), "∠")
- sb.Replace(ChrW(&H2227), "∧")
- sb.Replace(ChrW(&H2228), "∨")
- sb.Replace(ChrW(&H2229), "∩")
- sb.Replace(ChrW(&H222A), "∪")
- sb.Replace(ChrW(&H222B), "∫")
- sb.Replace(ChrW(&H2234), "∴")
- sb.Replace(ChrW(&H223C), "∼")
- sb.Replace(ChrW(&H2245), "≅")
- sb.Replace(ChrW(&H2248), "≈")
- sb.Replace(ChrW(&H2260), "≠")
- sb.Replace(ChrW(&H2261), "≡")
- sb.Replace(ChrW(&H2264), "≤")
- sb.Replace(ChrW(&H2265), "≥")
- sb.Replace(ChrW(&H2282), "⊂")
- sb.Replace(ChrW(&H2283), "⊃")
- sb.Replace(ChrW(&H2284), "⊄")
- sb.Replace(ChrW(&H2286), "⊆")
- sb.Replace(ChrW(&H2287), "⊇")
- sb.Replace(ChrW(&H2295), "⊕")
- sb.Replace(ChrW(&H2297), "⊗")
- sb.Replace(ChrW(&H22A5), "⊥")
- sb.Replace(ChrW(&H22C5), "⋅")
- sb.Replace(ChrW(&H2308), "⌈")
- sb.Replace(ChrW(&H2309), "⌉")
- sb.Replace(ChrW(&H230A), "⌊")
- sb.Replace(ChrW(&H230B), "⌋")
- sb.Replace(ChrW(&H2329), "〈")
- sb.Replace(ChrW(&H232A), "〉")
- sb.Replace(ChrW(&H25CA), "◊")
- sb.Replace(ChrW(&H2660), "♠")
- sb.Replace(ChrW(&H2663), "♣")
- sb.Replace(ChrW(&H2665), "♥")
- sb.Replace(ChrW(&H2666), "♦")
- sb.Replace(" ", " ")
- Return sb.ToString()
- End Function
+ '''
+ ''' Encodes the specified text as HTML.
+ '''
+ ''' The text to be encoded.
+ ''' The encoded HTML.
+ _
+ Public Function HtmlEncode(ByVal text As String) As String
+ Dim sb As New Text.StringBuilder(text)
+ sb.Replace(ChrW(&H26), "&")
+ sb.Replace(ChrW(&H22), """)
+ sb.Replace(ChrW(&H27), "'")
+ sb.Replace(ChrW(&H3C), "<")
+ sb.Replace(ChrW(&H3E), ">")
+ sb.Replace(ChrW(&HA0), " ")
+ sb.Replace(ChrW(&HA1), "¡")
+ sb.Replace(ChrW(&HA2), "¢")
+ sb.Replace(ChrW(&HA3), "£")
+ sb.Replace(ChrW(&HA4), "¤")
+ sb.Replace(ChrW(&HA5), "¥")
+ sb.Replace(ChrW(&HA6), "¦")
+ sb.Replace(ChrW(&HA7), "§")
+ sb.Replace(ChrW(&HA8), "¨")
+ sb.Replace(ChrW(&HA9), "©")
+ sb.Replace(ChrW(&HAA), "ª")
+ sb.Replace(ChrW(&HAB), "«")
+ sb.Replace(ChrW(&HAC), "¬")
+ sb.Replace(ChrW(&HAD), "")
+ sb.Replace(ChrW(&HAE), "®")
+ sb.Replace(ChrW(&HAF), "¯")
+ sb.Replace(ChrW(&HB0), "°")
+ sb.Replace(ChrW(&HB1), "±")
+ sb.Replace(ChrW(&HB2), "²")
+ sb.Replace(ChrW(&HB3), "³")
+ sb.Replace(ChrW(&HB4), "´")
+ sb.Replace(ChrW(&HB5), "µ")
+ sb.Replace(ChrW(&HB6), "¶")
+ sb.Replace(ChrW(&HB7), "·")
+ sb.Replace(ChrW(&HB8), "¸")
+ sb.Replace(ChrW(&HB9), "¹")
+ sb.Replace(ChrW(&HBA), "º")
+ sb.Replace(ChrW(&HBB), "»")
+ sb.Replace(ChrW(&HBC), "¼")
+ sb.Replace(ChrW(&HBD), "½")
+ sb.Replace(ChrW(&HBE), "¾")
+ sb.Replace(ChrW(&HBF), "¿")
+ sb.Replace(ChrW(&HC0), "À")
+ sb.Replace(ChrW(&HC1), "Á")
+ sb.Replace(ChrW(&HC2), "Â")
+ sb.Replace(ChrW(&HC3), "Ã")
+ sb.Replace(ChrW(&HC4), "Ä")
+ sb.Replace(ChrW(&HC5), "Å")
+ sb.Replace(ChrW(&HC6), "Æ")
+ sb.Replace(ChrW(&HC7), "Ç")
+ sb.Replace(ChrW(&HC8), "È")
+ sb.Replace(ChrW(&HC9), "É")
+ sb.Replace(ChrW(&HCA), "Ê")
+ sb.Replace(ChrW(&HCB), "Ë")
+ sb.Replace(ChrW(&HCC), "Ì")
+ sb.Replace(ChrW(&HCD), "Í")
+ sb.Replace(ChrW(&HCE), "Î")
+ sb.Replace(ChrW(&HCF), "Ï")
+ sb.Replace(ChrW(&HD0), "Ð")
+ sb.Replace(ChrW(&HD1), "Ñ")
+ sb.Replace(ChrW(&HD2), "Ò")
+ sb.Replace(ChrW(&HD3), "Ó")
+ sb.Replace(ChrW(&HD4), "Ô")
+ sb.Replace(ChrW(&HD5), "Õ")
+ sb.Replace(ChrW(&HD6), "Ö")
+ sb.Replace(ChrW(&HD7), "×")
+ sb.Replace(ChrW(&HD8), "Ø")
+ sb.Replace(ChrW(&HD9), "Ù")
+ sb.Replace(ChrW(&HDA), "Ú")
+ sb.Replace(ChrW(&HDB), "Û")
+ sb.Replace(ChrW(&HDC), "Ü")
+ sb.Replace(ChrW(&HDD), "Ý")
+ sb.Replace(ChrW(&HDE), "Þ")
+ sb.Replace(ChrW(&HDF), "ß")
+ sb.Replace(ChrW(&HE0), "à")
+ sb.Replace(ChrW(&HE1), "á")
+ sb.Replace(ChrW(&HE2), "â")
+ sb.Replace(ChrW(&HE3), "ã")
+ sb.Replace(ChrW(&HE4), "ä")
+ sb.Replace(ChrW(&HE5), "å")
+ sb.Replace(ChrW(&HE6), "æ")
+ sb.Replace(ChrW(&HE7), "ç")
+ sb.Replace(ChrW(&HE8), "è")
+ sb.Replace(ChrW(&HE9), "é")
+ sb.Replace(ChrW(&HEA), "ê")
+ sb.Replace(ChrW(&HEB), "ë")
+ sb.Replace(ChrW(&HEC), "ì")
+ sb.Replace(ChrW(&HED), "í")
+ sb.Replace(ChrW(&HEE), "î")
+ sb.Replace(ChrW(&HEF), "ï")
+ sb.Replace(ChrW(&HF0), "ð")
+ sb.Replace(ChrW(&HF1), "ñ")
+ sb.Replace(ChrW(&HF2), "ò")
+ sb.Replace(ChrW(&HF3), "ó")
+ sb.Replace(ChrW(&HF4), "ô")
+ sb.Replace(ChrW(&HF5), "õ")
+ sb.Replace(ChrW(&HF6), "ö")
+ sb.Replace(ChrW(&HF7), "÷")
+ sb.Replace(ChrW(&HF8), "ø")
+ sb.Replace(ChrW(&HF9), "ù")
+ sb.Replace(ChrW(&HFA), "ú")
+ sb.Replace(ChrW(&HFB), "û")
+ sb.Replace(ChrW(&HFC), "ü")
+ sb.Replace(ChrW(&HFD), "ý")
+ sb.Replace(ChrW(&HFE), "þ")
+ sb.Replace(ChrW(&HFF), "ÿ")
+ sb.Replace(ChrW(&H152), "Œ")
+ sb.Replace(ChrW(&H153), "œ")
+ sb.Replace(ChrW(&H160), "Š")
+ sb.Replace(ChrW(&H161), "š")
+ sb.Replace(ChrW(&H178), "Ÿ")
+ sb.Replace(ChrW(&H192), "ƒ")
+ sb.Replace(ChrW(&H2C6), "ˆ")
+ sb.Replace(ChrW(&H2DC), "˜")
+ sb.Replace(ChrW(&H391), "Α")
+ sb.Replace(ChrW(&H392), "Β")
+ sb.Replace(ChrW(&H393), "Γ")
+ sb.Replace(ChrW(&H394), "Δ")
+ sb.Replace(ChrW(&H395), "Ε")
+ sb.Replace(ChrW(&H396), "Ζ")
+ sb.Replace(ChrW(&H397), "Η")
+ sb.Replace(ChrW(&H398), "Θ")
+ sb.Replace(ChrW(&H399), "Ι")
+ sb.Replace(ChrW(&H39A), "Κ")
+ sb.Replace(ChrW(&H39B), "Λ")
+ sb.Replace(ChrW(&H39C), "Μ")
+ sb.Replace(ChrW(&H39D), "Ν")
+ sb.Replace(ChrW(&H39E), "Ξ")
+ sb.Replace(ChrW(&H39F), "Ο")
+ sb.Replace(ChrW(&H3A0), "Π")
+ sb.Replace(ChrW(&H3A1), "Ρ")
+ sb.Replace(ChrW(&H3A3), "Σ")
+ sb.Replace(ChrW(&H3A4), "Τ")
+ sb.Replace(ChrW(&H3A5), "Υ")
+ sb.Replace(ChrW(&H3A6), "Φ")
+ sb.Replace(ChrW(&H3A7), "Χ")
+ sb.Replace(ChrW(&H3A8), "Ψ")
+ sb.Replace(ChrW(&H3A9), "Ω")
+ sb.Replace(ChrW(&H3B1), "α")
+ sb.Replace(ChrW(&H3B2), "β")
+ sb.Replace(ChrW(&H3B3), "γ")
+ sb.Replace(ChrW(&H3B4), "δ")
+ sb.Replace(ChrW(&H3B5), "ε")
+ sb.Replace(ChrW(&H3B6), "ζ")
+ sb.Replace(ChrW(&H3B7), "η")
+ sb.Replace(ChrW(&H3B8), "θ")
+ sb.Replace(ChrW(&H3B9), "ι")
+ sb.Replace(ChrW(&H3BA), "κ")
+ sb.Replace(ChrW(&H3BB), "λ")
+ sb.Replace(ChrW(&H3BC), "μ")
+ sb.Replace(ChrW(&H3BD), "ν")
+ sb.Replace(ChrW(&H3BE), "ξ")
+ sb.Replace(ChrW(&H3BF), "ο")
+ sb.Replace(ChrW(&H3C0), "π")
+ sb.Replace(ChrW(&H3C1), "ρ")
+ sb.Replace(ChrW(&H3C2), "ς")
+ sb.Replace(ChrW(&H3C3), "σ")
+ sb.Replace(ChrW(&H3C4), "τ")
+ sb.Replace(ChrW(&H3C5), "υ")
+ sb.Replace(ChrW(&H3C6), "φ")
+ sb.Replace(ChrW(&H3C7), "χ")
+ sb.Replace(ChrW(&H3C8), "ψ")
+ sb.Replace(ChrW(&H3C9), "ω")
+ sb.Replace(ChrW(&H3D1), "ϑ")
+ sb.Replace(ChrW(&H3D2), "ϒ")
+ sb.Replace(ChrW(&H3D6), "ϖ")
+ sb.Replace(ChrW(&H2002), " ")
+ sb.Replace(ChrW(&H2003), " ")
+ sb.Replace(ChrW(&H2009), " ")
+ sb.Replace(ChrW(&H200C), "")
+ sb.Replace(ChrW(&H200D), "")
+ sb.Replace(ChrW(&H200E), "")
+ sb.Replace(ChrW(&H200F), "")
+ sb.Replace(ChrW(&H2013), "–")
+ sb.Replace(ChrW(&H2014), "—")
+ sb.Replace(ChrW(&H2018), "‘")
+ sb.Replace(ChrW(&H2019), "’")
+ sb.Replace(ChrW(&H201A), "‚")
+ sb.Replace(ChrW(&H201C), "“")
+ sb.Replace(ChrW(&H201D), "”")
+ sb.Replace(ChrW(&H201E), "„")
+ sb.Replace(ChrW(&H2020), "†")
+ sb.Replace(ChrW(&H2021), "‡")
+ sb.Replace(ChrW(&H2022), "•")
+ sb.Replace(ChrW(&H2026), "…")
+ sb.Replace(ChrW(&H2030), "‰")
+ sb.Replace(ChrW(&H2032), "′")
+ sb.Replace(ChrW(&H2033), "″")
+ sb.Replace(ChrW(&H2039), "‹")
+ sb.Replace(ChrW(&H203A), "›")
+ sb.Replace(ChrW(&H203E), "‾")
+ sb.Replace(ChrW(&H2044), "⁄")
+ sb.Replace(ChrW(&H20AC), "€")
+ sb.Replace(ChrW(&H2111), "ℑ")
+ sb.Replace(ChrW(&H2118), "℘")
+ sb.Replace(ChrW(&H211C), "ℜ")
+ sb.Replace(ChrW(&H2122), "™")
+ sb.Replace(ChrW(&H2135), "ℵ")
+ sb.Replace(ChrW(&H2190), "←")
+ sb.Replace(ChrW(&H2191), "↑")
+ sb.Replace(ChrW(&H2192), "→")
+ sb.Replace(ChrW(&H2193), "↓")
+ sb.Replace(ChrW(&H2194), "↔")
+ sb.Replace(ChrW(&H21B5), "↵")
+ sb.Replace(ChrW(&H21D0), "⇐")
+ sb.Replace(ChrW(&H21D1), "⇑")
+ sb.Replace(ChrW(&H21D2), "⇒")
+ sb.Replace(ChrW(&H21D3), "⇓")
+ sb.Replace(ChrW(&H21D4), "⇔")
+ sb.Replace(ChrW(&H2200), "∀")
+ sb.Replace(ChrW(&H2202), "∂")
+ sb.Replace(ChrW(&H2203), "∃")
+ sb.Replace(ChrW(&H2205), "∅")
+ sb.Replace(ChrW(&H2207), "∇")
+ sb.Replace(ChrW(&H2208), "∈")
+ sb.Replace(ChrW(&H2209), "∉")
+ sb.Replace(ChrW(&H220B), "∋")
+ sb.Replace(ChrW(&H220F), "∏")
+ sb.Replace(ChrW(&H2211), "∑")
+ sb.Replace(ChrW(&H2212), "−")
+ sb.Replace(ChrW(&H2217), "∗")
+ sb.Replace(ChrW(&H221A), "√")
+ sb.Replace(ChrW(&H221D), "∝")
+ sb.Replace(ChrW(&H221E), "∞")
+ sb.Replace(ChrW(&H2220), "∠")
+ sb.Replace(ChrW(&H2227), "∧")
+ sb.Replace(ChrW(&H2228), "∨")
+ sb.Replace(ChrW(&H2229), "∩")
+ sb.Replace(ChrW(&H222A), "∪")
+ sb.Replace(ChrW(&H222B), "∫")
+ sb.Replace(ChrW(&H2234), "∴")
+ sb.Replace(ChrW(&H223C), "∼")
+ sb.Replace(ChrW(&H2245), "≅")
+ sb.Replace(ChrW(&H2248), "≈")
+ sb.Replace(ChrW(&H2260), "≠")
+ sb.Replace(ChrW(&H2261), "≡")
+ sb.Replace(ChrW(&H2264), "≤")
+ sb.Replace(ChrW(&H2265), "≥")
+ sb.Replace(ChrW(&H2282), "⊂")
+ sb.Replace(ChrW(&H2283), "⊃")
+ sb.Replace(ChrW(&H2284), "⊄")
+ sb.Replace(ChrW(&H2286), "⊆")
+ sb.Replace(ChrW(&H2287), "⊇")
+ sb.Replace(ChrW(&H2295), "⊕")
+ sb.Replace(ChrW(&H2297), "⊗")
+ sb.Replace(ChrW(&H22A5), "⊥")
+ sb.Replace(ChrW(&H22C5), "⋅")
+ sb.Replace(ChrW(&H2308), "⌈")
+ sb.Replace(ChrW(&H2309), "⌉")
+ sb.Replace(ChrW(&H230A), "⌊")
+ sb.Replace(ChrW(&H230B), "⌋")
+ sb.Replace(ChrW(&H2329), "〈")
+ sb.Replace(ChrW(&H232A), "〉")
+ sb.Replace(ChrW(&H25CA), "◊")
+ sb.Replace(ChrW(&H2660), "♠")
+ sb.Replace(ChrW(&H2663), "♣")
+ sb.Replace(ChrW(&H2665), "♥")
+ sb.Replace(ChrW(&H2666), "♦")
+ sb.Replace(" ", " ")
+ Return sb.ToString()
+ End Function
- Sub AddTokenizerBaseMacros(ByVal tokenizer As Tokenization.Tokenizer)
+ Sub AddTokenizerBaseMacros(ByVal tokenizer As Tokenization.Tokenizer)
- '*
- '* Prepares the BBCode Grammar
- '*
- With tokenizer
- .Options = RegexOptions.Singleline Or RegexOptions.IgnoreCase
+ '*
+ '* Prepares the BBCode Grammar
+ '*
+ With tokenizer
+ .Options = RegexOptions.Singleline Or RegexOptions.IgnoreCase
- '*
- '* Define the grammar macros
- '*
- .AddMacro("h", "[0-9a-f]")
- .AddMacro("nl", "\n|\r\n|\r|\f")
- .AddMacro("space", "[ \t\r\n\f]+")
- .AddMacro("s", "[ \t\r\n\f]*")
- .AddMacro("w", "{s}?")
- .AddMacro("nonascii", "[\u0080-\uffff]")
- .AddMacro("unicode", "\\{h}{1,6}(\r\n|[ \t\r\n\f])?")
- .AddMacro("escape", "{unicode}|\\[^\r\n\f0-9a-f]")
- .AddMacro("nmstart", "[_a-z]|{nonascii}|{escape}")
- .AddMacro("nmchar", "[_a-z0-9-]|{nonascii}|{escape}")
- .AddMacro("string1", "\""([^\n\r\f\\""]|\\{nl}|{escape})*\""")
- .AddMacro("string2", "\'([^\n\r\f\\']|\\{nl}|{escape})*\'")
- .AddMacro("invalid1", "\""([^\n\r\f\\""]|\\{nl}|{escape})*")
- .AddMacro("invalid2", "\'([^\n\r\f\\']|\\{nl}|{escape})*")
- .AddMacro("name", "{nmchar}+")
- .AddMacro("num", "[0-9]+|[0-9]*\.[0-9]+")
- .AddMacro("string", "{string1}|{string2}")
- .AddMacro("invalid", "{invalid1}|{invalid2}")
- .AddMacro("url", "(ftp|https?://)" & _
- "(([0-9a-z_!~*'().&=+$%-]+):([0-9a-z_!~*'().&=+$%-]+@))?" & _
- "(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})" & _
- "(:[0-9]{1,4})?" & _
- "((/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?|(/?))")
- .AddMacro("mail", "(?:mailto:)?[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}")
- .AddMacro("value", "{string}|{mail}|{url}|{num}|{name}")
- .AddMacro("param", "{name}{w}={w}{value}")
- .AddMacro("params", "({space}({param}|{name}))+")
+ '*
+ '* Define the grammar macros
+ '*
+ .AddMacro("h", "[0-9a-f]")
+ .AddMacro("nl", "\n|\r\n|\r|\f")
+ .AddMacro("space", "[ \t\r\n\f]+")
+ .AddMacro("s", "[ \t\r\n\f]*")
+ .AddMacro("w", "{s}?")
+ .AddMacro("nonascii", "[\u0080-\uffff]")
+ .AddMacro("unicode", "\\{h}{1,6}(\r\n|[ \t\r\n\f])?")
+ .AddMacro("escape", "{unicode}|\\[^\r\n\f0-9a-f]")
+ .AddMacro("nmstart", "[_a-z]|{nonascii}|{escape}")
+ .AddMacro("nmchar", "[_a-z0-9-]|{nonascii}|{escape}")
+ .AddMacro("string1", "\""([^\n\r\f\\""]|\\{nl}|{escape})*\""")
+ .AddMacro("string2", "\'([^\n\r\f\\']|\\{nl}|{escape})*\'")
+ .AddMacro("invalid1", "\""([^\n\r\f\\""]|\\{nl}|{escape})*")
+ .AddMacro("invalid2", "\'([^\n\r\f\\']|\\{nl}|{escape})*")
+ .AddMacro("name", "{nmchar}+")
+ .AddMacro("num", "[0-9]+|[0-9]*\.[0-9]+")
+ .AddMacro("string", "{string1}|{string2}")
+ .AddMacro("invalid", "{invalid1}|{invalid2}")
+ .AddMacro("url", "(ftp|https?://)" & _
+ "(([0-9a-z_!~*'().&=+$%-]+):([0-9a-z_!~*'().&=+$%-]+@))?" & _
+ "(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})" & _
+ "(:[0-9]{1,4})?" & _
+ "((/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?|(/?))")
+ .AddMacro("mail", "(?:mailto:)?[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}")
+ .AddMacro("value", "{string}|{mail}|{url}|{num}|{name}")
+ .AddMacro("param", "{name}{w}={w}{value}")
+ .AddMacro("params", "({space}({param}|{name}))+")
- End With
- End Sub
+ End With
+ End Sub
End Module