/// <summary> /// Formats the text /// </summary> /// <param name="text">Text</param> /// <param name="stripTags">A value indicating whether to strip tags</param> /// <param name="convertPlainTextToHtml">A value indicating whether HTML is allowed</param> /// <param name="allowHtml">A value indicating whether HTML is allowed</param> /// <param name="allowBBCode">A value indicating whether BBCode is allowed</param> /// <param name="resolveLinks">A value indicating whether to resolve links</param> /// <param name="addNoFollowTag">A value indicating whether to add "noFollow" tag</param> /// <returns>Formatted text</returns> public static string FormatText(string text, bool stripTags, bool convertPlainTextToHtml, bool allowHtml, bool allowBBCode, bool resolveLinks, bool addNoFollowTag) { if (String.IsNullOrEmpty(text)) { return(string.Empty); } try { if (stripTags) { text = StripTags(text); } text = allowHtml ? EnsureOnlyAllowedHtml(text) : HttpUtility.HtmlEncode(text); if (convertPlainTextToHtml) { text = ConvertPlainTextToHtml(text); } if (allowBBCode) { text = BBCodeHelper.FormatText(text, true, true, true, true, true, true, true); } if (resolveLinks) { text = ResolveLinksHelper.FormatText(text); } if (addNoFollowTag) { //add noFollow tag. not implemented } } catch (Exception exc) { text = string.Format("Text cannot be formatted. Error: {0}", exc.Message); } return(text); }