[code: ] tags show when using syntax highlighting in BlogEngine 1.3

I came across another problem with the syntax highlighting in BlogEngine.Net. Whenever I used code blocks like so:

[ code:c#]

//some c# code 

[ /code]

the formatting tags would be included in the output: 


I fixed this in CodeFormatter.cs by modifying the regular expressions that are used to remove the formatting tags. I'm definitely not a regular expression guru but all I did was allow the expression to match extra 'nbsp;' and '<br />' elements that may be inserted after the [ code:c#] tags.

Both of the expressions below are the result after replacing all occurences of (\s|) with (\s|&nbsp;|<br />)*: 

#region RegEx
...
    private Regex codeBeginTagRegex = new Regex(
    @"(<p>\r\n<div class=""code"">\n\[code:.*?\](\s|&nbsp;|<br />)*\r\n</p>\r\n|"
    + @"<p>\r\n<div class=""code"">\n\[code:.*?\](\s|&nbsp;|<br />)*<br /><br /><br />)",
...
    private Regex codeEndTagRegex = new Regex(
    @"(<p>\r\n\[/code\]</div>(\s|)\r\n</p>\r\n|<br /><br /><br />\[/code\]</div>(\s|)\r\n</p>\r\n)",
...

#endregion

[/code]

 

This seems to work in most cases however the tags have popped up a couple of times but this has always been resolved by editing the post and minimizing the white space and carriage returns that follow or precede one of the formatting tags.

Go here for the bug report on the BlogEngine.Net project site

Jimmy 

Related posts

Comments

April 18. 2011 08:58

Pingback from watchtvonmypc.org

traffic travis discount

watchtvonmypc.org

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

February 6. 2012 06:07

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012