Created
August 5, 2009 08:31
-
-
Save JeffreyZhao/162592 to your computer and use it in GitHub Desktop.
Convert inline <pre /> to <br />
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string DoPre(string content) | |
{ | |
return Regex.Replace(content, @"(<pre[^>]*>)([\s\S]*?)(</pre>)", match => | |
{ | |
return | |
match.Groups[1].Value + | |
String.Join("<br />", match.Groups[2].Value.Split('\n').Select(p => p.Replace(" ", " ").Trim()).ToArray()) + | |
match.Groups[3].Value; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment