SyntaxHighlighter and Line Break Tags

Posted by azamsharp on Stack Overflow See other posts from Stack Overflow or by azamsharp
Published on 2010-04-24T03:01:09Z Indexed on 2010/04/24 3:03 UTC
Read the original article Hit count: 390

Filed under:

I am using the following syntax highligher:

http://alexgorbatchev.com/wiki/SyntaxHighlighter

For some reason when it encounter <br> it simply prints out <br> tags. I cannot replace the whole thing with System.Environment.NewLine since it will mess up the complete description. Here is my code:

public static string GetDescription(string description)
        {
            string codeStartPattern = "&lt;code&gt;";
            string codeEndPattern = "&lt;/code&gt;";           

            Regex reg = new Regex(codeStartPattern);
            description = reg.Replace(description, ReplaceWithStartDiv);

            reg = new Regex(codeEndPattern);
            description = reg.Replace(description, ReplaceWithEndDiv);

            return description; 
        }

 private static string ReplaceWithStartDiv(Match m)
        {
            return "<script type='syntaxhighlighter' class='brush: csharp'><![CDATA[";
        }

        private static string ReplaceWithEndDiv(Match m)
        {
            return "]]></script>"; 
        }

I guess I only need to replace <br> with System.Environment.Newline with the code that is between the <code> snippet here </code>

Thanks!

© Stack Overflow or respective owner

Related posts about syntax-highlighting