SyntaxHighlighter and Line Break Tags
- by azamsharp
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 = "<code>";
string codeEndPattern = "</code>";
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!