/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { // format the url tags: [url=http://www.nopCommerce.com]my site[/url] // becomes: <a href="http://www.nopCommerce.com">my site</a> text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); // format the url tags: [url]http://www.nopCommerce.com[/url] // becomes: <a href="http://www.nopCommerce.com">http://www.nopCommerce.com</a> text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (replaceCode) { //Text = CodeFormatHelper.FormatText(Text); text = CodeFormatHelper.FormatTextSimple(text); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><p class=\"quote\">$2</p>"); } } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <param name="replaceImg">A value indicating whether to replace Img</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { var newWindow = EngineContext.Current.Resolve <CommonSettings>().BbcodeEditorOpenLinksInNewWindow; text = regexUrl1.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$2</a>", newWindow ? " target=_blank" : "")); text = regexUrl2.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$1</a>", newWindow ? " target=_blank" : "")); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><div class=\"quote\">$2</div>"); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } if (replaceImg) { text = regexImg.Replace(text, "<img src=\"$1\" class=\"user-posted-image\" alt=\"\">"); } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <param name="replaceImg">A value indicating whether to replace Img</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><div class=\"quote\">$2</div>"); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } if (replaceImg) { text = regexImg.Replace(text, "<img src=\"$1\" class=\"user-posted-image\" alt=\"\"></img>"); } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { // format the url tags: [url=http://www.insearch.kz]my site[/url] // becomes: <a href="http://www.insearch.kz">my site</a> text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); // format the url tags: [url]http://www.InSearch.com[/url] // becomes: <a href="http://www.insearch.kz">http://www.insearch.kz</a> text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (replaceQuote) { text = regexQuote.Replace(text, "<blockquote class='muted'>$1</blockquote>"); } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } return(text); }
public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { var newWindow = EngineContext.Current.Resolve <GenelAyarlar>().BbcodeEditorYeniPenceredeAçılsın; text = regexUrl1.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$2</a>", newWindow ? " target=_blank" : "")); text = regexUrl2.Replace(text, string.Format("<a href=\"$1\" rel=\"nofollow\"{0}>$1</a>", newWindow ? " target=_blank" : "")); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><div class=\"quote\">$2</div>"); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } if (replaceImg) { // format the img tags: [img]http://www.nopCommerce.com/Content/Images/Image.jpg[/img] // becomes: <img src="http://www.nopCommerce.com/Content/Images/Image.jpg"> text = regexImg.Replace(text, "<img src=\"$1\" class=\"user-posted-image\" alt=\"\">"); } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="str">Text</param> /// <returns>Formatted text</returns> public static string FormatText(string Text, bool ReplaceBold, bool ReplaceItalic, bool ReplaceUnderLine, bool ReplaceUrl, bool ReplaceCode) { if (String.IsNullOrEmpty(Text)) { return(string.Empty); } if (ReplaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> Text = regexBold.Replace(Text, "<strong>$1</strong>"); } if (ReplaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> Text = regexItalic.Replace(Text, "<em>$1</em>"); } if (ReplaceUnderLine) { // format the underline tags: [u][/u] // becomes: <u></u> Text = regexUnderLine.Replace(Text, "<u>$1</u>"); } if (ReplaceUrl) { // format the url tags: [url=http://www.nopCommerce.com]my site[/url] // becomes: <a href="http://www.nopCommerce.com">my site</a> Text = regexUrl1.Replace(Text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); // format the url tags: [url]http://www.nopCommerce.com[/url] // becomes: <a href="http://www.nopCommerce.com">http://www.nopCommerce.com</a> Text = regexUrl2.Replace(Text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (ReplaceCode) { //Text = CodeFormatHelper.FormatText(Text); Text = CodeFormatHelper.FormatTextSimple(Text); } return(Text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <param name="replaceImg">A value indicating whether to replace Img</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg) { if (string.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { var newWindow = EngineContext.Current.Resolve <CommonSettings>().BbcodeEditorOpenLinksInNewWindow; // format the URL tags: [url=https://apratim.azurewebsites.net]my site[/url] // becomes: <a href="https://apratim.azurewebsites.net">my site</a> text = regexUrl1.Replace(text, $"<a href=\"$1\" rel=\"nofollow\"{(newWindow ? " target=_blank" : "")}>$2</a>"); // format the URL tags: [url]https://apratim.azurewebsites.net[/url] // becomes: <a href="https://apratim.azurewebsites.net">https://apratim.azurewebsites.net</a> text = regexUrl2.Replace(text, $"<a href=\"$1\" rel=\"nofollow\"{(newWindow ? " target=_blank" : "")}>$1</a>"); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><div class=\"quote\">$2</div>"); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } if (replaceImg) { // format the img tags: [img]https://apratim.azurewebsites.net/Content/Images/Image.jpg[/img] // becomes: <img src="https://apratim.azurewebsites.net/Content/Images/Image.jpg"> text = regexImg.Replace(text, "<img src=\"$1\" class=\"user-posted-image\" alt=\"\">"); } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <returns>Formatted text</returns> public static string ToHtml( string text, bool replaceBold = true, bool replaceItalic = true, bool replaceUnderline = true, bool replaceUrl = true, bool replaceCode = true, bool replaceQuote = true) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { // format the url tags: [url=http://www.smartstore.com]my site[/url] // becomes: <a href="http://www.smartstore.com">my site</a> text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); // format the url tags: [url]http://www.smartstore.com[/url] // becomes: <a href="http://www.smartstore.com">http://www.smartstore.com</a> text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, (m) => { var from = m.Groups[1].Value; var quote = m.Groups[2].Value; if (quote.IsEmpty()) { return(""); } string result = ""; if (from.HasValue()) { //result += "<span class='quotefrom'>{0}:</span>".FormatCurrent(from.Substring(1)); result += "<span class='quotefrom'>{0}:</span>".FormatWith(from.Substring(1)); } //result += "<blockquote class='muted'>{0}</blockquote>".FormatCurrent(quote); result += "<blockquote class='muted'>{0}</blockquote>".FormatWith(quote); return(result); }); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } return(text); }
/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="replaceBold">A value indicating whether to replace Bold</param> /// <param name="replaceItalic">A value indicating whether to replace Italic</param> /// <param name="replaceUnderline">A value indicating whether to replace Underline</param> /// <param name="replaceUrl">A value indicating whether to replace URL</param> /// <param name="replaceCode">A value indicating whether to replace Code</param> /// <param name="replaceQuote">A value indicating whether to replace Quote</param> /// <param name="replaceImg">A value indicating whether to replace Img</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool replaceBold, bool replaceItalic, bool replaceUnderline, bool replaceUrl, bool replaceCode, bool replaceQuote, bool replaceImg) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } if (replaceBold) { // format the bold tags: [b][/b] // becomes: <strong></strong> text = regexBold.Replace(text, "<strong>$1</strong>"); } if (replaceItalic) { // format the italic tags: [i][/i] // becomes: <em></em> text = regexItalic.Replace(text, "<em>$1</em>"); } if (replaceUnderline) { // format the underline tags: [u][/u] // becomes: <u></u> text = regexUnderLine.Replace(text, "<u>$1</u>"); } if (replaceUrl) { // format the url tags: [url=https://www.google.com]my site[/url] // becomes: <a href="https://www.google.com">my site</a> text = regexUrl1.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$2</a>"); // format the url tags: [url]https://www.google.com[/url] // becomes: <a href="https://www.google.com">https://www.google.com</a> text = regexUrl2.Replace(text, "<a href=\"$1\" rel=\"nofollow\">$1</a>"); } if (replaceQuote) { while (regexQuote.IsMatch(text)) { text = regexQuote.Replace(text, "<b>$1 wrote:</b><div class=\"quote\">$2</div>"); } } if (replaceCode) { text = CodeFormatHelper.FormatTextSimple(text); } if (replaceImg) { // format the img tags: [img]https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png[/img] // becomes: <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"></img> text = regexImg.Replace(text, "<img src=\"$1\" class=\"user-posted-image\" alt=\"\"></img>"); } return(text); }