Argentini.Halide.H3Text.ConvertToHtml C# (CSharp) Метод

ConvertToHtml() публичный статический Метод

sequences or
tags, except between [nofeed][/nofeed] tags. URLs and domain names can be converted to true hyperLinks if specified. Use the [nolink][/nolink] tag to skip specific areas of the string when scanning for linkable text. ]]>
public static ConvertToHtml ( string strVal, bool lineFeeds, string feedType, bool hyperLinks, string linkParams ) : String
strVal string Text to process.
lineFeeds bool Convert lineFeeds to HTML equivalents (true or false).
feedType string /// " or "
". /// ]]> ///
hyperLinks bool Convert urls and domain names to hyperLinks (true or false).
linkParams string If converting urls and domain names to hyperLinks, add these params to the anchor tags.
Результат String
        public static String ConvertToHtml(string strVal, bool lineFeeds, string feedType, bool hyperLinks, string linkParams)
        {
            string final = strVal;
            string section = String.Empty;
            int checkTAGS = 0;
            int checkAMP = 0;
            Regex regex;

            if(final.Length > 0)
            {
                if(hyperLinks) final = AutoHyperlinks(final, linkParams);

                if(InStr(final, "<") >= 0)
                {
                    regex = new Regex(@"<([^>]*)>", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);

                    MatchCollection theMatches = regex.Matches(final);

                    if(theMatches.Count > 0) checkTAGS = 1;

                    for (int index = 0; index < theMatches.Count; index++)
                    {
                        if(checkAMP == 0 && InStr(theMatches[index].ToString(), "&") >= 0) checkAMP = 1;

                        section = theMatches[index].ToString().Replace("&", "[[[pk:amp]]]");
                        section = section.Replace("<", "[[[pk:lt]]]");
                        section = section.Replace(">", "[[[pk:gt]]]");

                        final = final.Replace(theMatches[index].ToString(), section);
                    }
                }

                if(InStr(final, ">") >= 0) final = final.Replace(">", "&gt;");
                if(InStr(final, "<") >= 0) final = final.Replace("<", "&lt;");

                if(InStr(final, "&") >= 0)
                {
                    checkAMP = 1;

                    regex = new Regex(@"&([A-Za-z0-9]*);", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);

                    MatchCollection theMatches = regex.Matches(final);

                    for (int index = 0; index < theMatches.Count; index++)
                    {
                        section = theMatches[index].ToString().Replace("&", "[[[pk:amp]]]");
                        final = final.Replace(theMatches[index].ToString(), section);
                    }

                    final = final.Replace("&", "&amp;");
                }

                for(int x = 128; x < 256; x++)
                {
                    if(InStr(final, Convert.ToString(Convert.ToChar(x))) >= 0)
                    {
                        final = final.Replace(Convert.ToString(Convert.ToChar(x)), "&#" + x.ToString() + ";");
                    }
                }

                if(checkAMP == 1) final = final.Replace("[[[pk:amp]]]", "&");

                if(checkTAGS == 1)
                {
                    final = final.Replace("[[[pk:lt]]]", "<");
                    final = final.Replace("[[[pk:gt]]]", ">");
                }

                if(lineFeeds)
                {
                    final = ConvertLinefeeds(final, feedType);
                }
            }

            return(final);
        }

Same methods

H3Text::ConvertToHtml ( string strVal, bool lineFeeds, string feedType ) : String