public string MatchEvaluator(Match m) { if (m.Groups["content"].Length == 0) { // It's possible that the "atts" match groups eats the contents // when the user didn't want to give block attributes, but the content // happens to match the syntax. For example: "*(blah)*". if (m.Groups["atts"].Length == 0) { return(m.ToString()); } return("<" + m_tag + ">" + m.Groups["atts"].Value + m.Groups["end"].Value + "</" + m_tag + ">"); } string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, ""); if (m.Groups["cite"].Length > 0) { atts += " cite=\"" + m.Groups["cite"] + "\""; } string res = "<" + m_tag + atts + ">" + m.Groups["content"].Value + m.Groups["end"].Value + "</" + m_tag + ">"; return(res); }
static string ImageFormatMatchEvaluator(Match m) { var atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "img"); if (m.Groups["algn"].Length > 0) { atts += " align=\"" + Globals.ImageAlign[m.Groups["algn"].Value] + "\""; } if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; atts += " alt=\"" + m.Groups["title"].Value + "\""; } else { atts += " alt=\"\""; } // Get Image Size? var res = "<img src=\"" + m.Groups["url"].Value + "\"" + atts + " />"; if (m.Groups["href"].Length > 0) { var href = m.Groups["href"].Value; var end = string.Empty; var endMatch = Regex.Match(href, @"(.*)(?<end>\.|,|;|\))$"); if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value)) { href = href[0..^ 1];
private string HyperLinksFormatMatchEvaluator(Match m) { //TODO: check the URL string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "", UseRestrictedMode); if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; } string linkText = m.Groups["text"].Value.Trim(' '); // Validate the URL. string url = TextileGlobals.EncodeHTMLLink(m.Groups["url"].Value) + m.Groups["slash"].Value; if (url.Contains("\"")) // Disable the URL if someone's trying a cheap hack. { url = "#"; } string str = m.Groups["pre"].Value + "<a "; if (m_rel != null && m_rel != string.Empty) { str += "ref=\"" + m_rel + "\" "; } str += "href=\"" + url + "\"" + atts + ">" + linkText + "</a>" + m.Groups["post"].Value; return(str); }
private string HyperLinksFormatMatchEvaluator(Match m) { var atts = BlockAttributesParser.Parse(m.Groups["atts"].Value, "", UseRestrictedMode); if (m.Groups["title"].Length > 0) { atts += $" title=\"{m.Groups["title"].Value}\""; } var linkText = m.Groups["text"].Value.Trim(' '); var url = TextileGlobals.EncodeHTMLLink(m.Groups["url"].Value) + m.Groups["slash"].Value; if (url.Contains("\"")) { // Disable the URL if someone's trying a cheap hack. url = "#"; } var str = $"{m.Groups["pre"].Value}<a "; if (_rel != null && _rel != string.Empty) { str += $"ref=\"{_rel}\" "; } str += $"href=\"{url}\"{atts}>{linkText}</a>{m.Groups["post"].Value}"; return(str); }
internal static string BuildTagElementString (string content, string attsValue, string matchValue, string tag, string end, string cite) { if (content.Length == 0) { // It's possible that the "atts" match groups eats the contents // when the user didn't want to give block attributes, but the content // happens to match the syntax. For example: "*(blah)*". if (attsValue.Length == 0) { return(matchValue); } return("<" + tag + ">" + attsValue + end + "</" + tag + ">"); } string atts = BlockAttributesParser.ParseBlockAttributes(attsValue, ""); if (cite.Length > 0) { atts += " cite=\"" + cite + "\""; } string res = "<" + tag + atts + ">" + content + end + "</" + tag + ">"; return(res); }
private string ImageFormatMatchEvaluator(Match m) { var atts = new StringBuilder(BlockAttributesParser.Parse(m.Groups["atts"].Value, "", UseRestrictedMode)); if (m.Groups["algn"].Length > 0) { atts.Append($" align=\"{TextileGlobals.ImageAlign[m.Groups["algn"].Value]}\""); } if (m.Groups["title"].Length > 0) { atts.Append($" title=\"{m.Groups["title"].Value}\""); atts.Append($" alt=\"{m.Groups["title"].Value}\""); } else { atts.Append(" alt=\"\""); } // Validate the URL. var url = m.Groups["url"].Value; if (url.Contains("\"")) { // Disable the URL if someone's trying a cheap hack. url = "#"; } string res = $"<img src=\"{url}\"{atts} />"; if (m.Groups["href"].Length > 0) { var href = m.Groups["href"].Value; var end = string.Empty; var endMatch = HrefRegex.Match(href); if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value)) { href = href.Substring(0, href.Length - 1); end = endMatch.Groups["end"].Value; } res = $"<a href=\"{TextileGlobals.EncodeHTMLLink(href)}\">{res}</a>{end}"; } return(res); }
private string ImageFormatMatchEvaluator(Match m) { string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "", UseRestrictedMode); if (m.Groups["algn"].Length > 0) { atts += " align=\"" + TextileGlobals.ImageAlign[m.Groups["algn"].Value] + "\""; } if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; atts += " alt=\"" + m.Groups["title"].Value + "\""; } else { atts += " alt=\"\""; } // Get Image Size? // Validate the URL. string url = m.Groups["url"].Value; if (url.Contains("\"")) // Disable the URL if someone's trying a cheap hack. { url = "#"; } string res = "<img src=\"" + url + "\"" + atts + " />"; if (m.Groups["href"].Length > 0) { string href = m.Groups["href"].Value; string end = string.Empty; Match endMatch = HrefRegex.Match(href); if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value)) { href = href.Substring(0, href.Length - 1); end = endMatch.Groups["end"].Value; } res = "<a href=\"" + TextileGlobals.EncodeHTMLLink(href) + "\">" + res + "</a>" + end; } return(res); }
private string HyperLinksFormatMatchEvaluator(Match m) { //TODO: check the URL string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, ""); if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; } string linkText = m.Groups["text"].Value.Trim(' '); string str = m.Groups["pre"].Value + "<a "; str += "href=\"" + Globals.EncodeHTMLLink(m.Groups["url"].Value) + m.Groups["slash"].Value + "\"" + atts + ">" + linkText + "</a>" + m.Groups["post"].Value; return(str); }
internal static string BuildHyperlinkElementString (string pre, string attsValue, string title, string text, string url, string slash, string post) { //TODO: check the URL string atts = BlockAttributesParser.ParseBlockAttributes(attsValue, ""); if (title.Length > 0) { atts += " title=\"" + title + "\""; } string linkText = text.Trim(' '); string str = pre + "<a "; str += "href=\"" + Globals.EncodeHTMLLink(url) + slash + "\"" + atts + ">" + linkText + "</a>" + post; return(str); }
private string HyperLinksFormatMatchEvaluator(Match m) { //TODO: check the URL var atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "a"); if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; } var linkText = m.Groups["text"].Value.Trim(' '); var str = m.Groups["pre"].Value + "<a "; if (!string.IsNullOrEmpty(m_rel)) { str += "ref=\"" + m_rel + "\" "; } str += "href=\"" + m.Groups["url"].Value + m.Groups["slash"].Value + "\"" + atts + ">" + linkText + "</a>" + m.Groups["post"].Value; return(str); }
static string ImageFormatMatchEvaluator(Match m) { string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, ""); if (m.Groups["algn"].Length > 0) { atts += " align=\"" + Globals.ImageAlign[m.Groups["algn"].Value] + "\""; } if (m.Groups["title"].Length > 0) { atts += " title=\"" + m.Groups["title"].Value + "\""; atts += " alt=\"" + m.Groups["title"].Value + "\""; } else { atts += " alt=\"\""; } // Get Image Size? string res = "<img src=\"" + m.Groups["url"].Value + "\"" + atts + " />"; if (m.Groups["href"].Length > 0) { string href = m.Groups["href"].Value; string end = string.Empty; Match endMatch = Regex.Match(href, @"(.*)(?<end>\.|,|;|\))$"); if (m.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value)) { href = href.Substring(0, href.Length - 1); end = endMatch.Groups["end"].Value; } res = "<a href=\"" + Globals.EncodeHTMLLink(href) + "\">" + res + "</a>" + end; } return(res); }
internal static string BuildImageElementString (string attsValue, string algn, string title, string url, string href) { string atts = BlockAttributesParser.ParseBlockAttributes(attsValue, ""); if (algn.Length > 0) { atts += " align=\"" + Globals.ImageAlign[algn] + "\""; } if (title.Length > 0) { atts += " title=\"" + title + "\""; atts += " alt=\"" + title + "\""; } else { atts += " alt=\"\""; } // Get Image Size? string res = "<img src=\"" + url + "\"" + atts + " />"; if (href.Length > 0) { string end = string.Empty; Match endMatch = Regex.Match(href, @"(.*)(?<end>\.|,|;|\))$"); if (endMatch.Success && !string.IsNullOrEmpty(endMatch.Groups["end"].Value)) { href = href.Substring(0, href.Length - 1); end = endMatch.Groups["end"].Value; } res = "<a href=\"" + Globals.EncodeHTMLLink(href) + "\">" + res + "</a>" + end; } return(res); }
private static string Eval(Match m, string tag, bool restrictedMode) { if (m.Groups["content"].Length == 0) { // It's possible that the "atts" match groups eats the contents // when the user didn't want to give block attributes, but the content // happens to match the syntax. For example: "*(blah)*". if (m.Groups["atts"].Length == 0) { return(m.ToString()); } return($"<{tag}>{m.Groups["atts"].Value}{m.Groups["end"].Value}</{tag}>"); } var atts = BlockAttributesParser.Parse(m.Groups["atts"].Value, "", restrictedMode); if (m.Groups["cite"].Length > 0) { atts += $" cite=\"{m.Groups["cite"]}\""; } return($"<{tag}{atts}>{m.Groups["content"].Value}{m.Groups["end"].Value}</{tag}>"); }