MarkdownSharp.Markdown.EscapeSpecialCharsWithinTagAttributes C# (CSharp) Method

EscapeSpecialCharsWithinTagAttributes() private method

Within tags -- meaning between < and > -- encode [\ ` * _] so they don't conflict with their use in Markdown for code, italics and strong. We're replacing each such character with its corresponding hash value; this is likely overkill, but it should prevent us from colliding with the escape values by accident.
private EscapeSpecialCharsWithinTagAttributes ( string text ) : string
text string
return string
        private string EscapeSpecialCharsWithinTagAttributes(string text)
        {
            var tokens = TokenizeHTML(text);

            // now, rebuild text from the tokens
            var sb = new StringBuilder(text.Length);

            foreach (var token in tokens)
            {
                string value = token.Value;

                if (token.Type == TokenType.Tag)
                {
                    value = value.Replace(@"\", _escapeTable[@"\"]);
                    
                    if (_autoHyperlink && value.StartsWith("<!")) // escape slashes in comments to prevent autolinking there -- http://meta.stackoverflow.com/questions/95987/html-comment-containing-url-breaks-if-followed-by-another-html-comment
                        value = value.Replace("/", _escapeTable["/"]);
                    
                    value = Regex.Replace(value, "(?<=.)</?code>(?=.)", _escapeTable[@"`"]);
                    value = EscapeBoldItalic(value);
                }

                sb.Append(value);
            }

            return sb.ToString();
        }