This project is read-only.

BlogEngine compress SyntaxHighlighter?

Dec 15, 2012 at 5:57 PM
Edited Dec 15, 2012 at 5:58 PM


I notice this behavior using a fresh installation of BlogEngine 2.7:
When creating a new post and pasting in source code to highlight, the generated code inside the editor looks good:

<pre class="brush: c-sharp;">using System;
namespace HelloWorld
    class Hello 
        static void Main() 
            System.Console.WriteLine("Hello World!");

 However, when I open the final post the generated HTML look like this:


<pre class="brush: c-sharp;">using System;
namespace HelloWorld
{class Hello {static void Main() {System.Console.WriteLine("Hello World!");}}

I disabled compressing in the settings and Web.config file but with the same result.
What's going wrong here? 

Dec 19, 2012 at 2:37 PM

No ideas?

Dec 19, 2012 at 3:34 PM

Probably latest TinyMCE editor changed some defaults. You can try to add "pre" tag to extended_valid_elements (similar to this).

Dec 19, 2012 at 11:34 PM
Edited Dec 19, 2012 at 11:35 PM

I added "extended_valid_elements : "pre[class]"," to "tinyMCE.ascx" but with no effect.
I don't think this is the problem because the rendered HTML inside the database is right, but when delivered via BlogEngine it is broken.

Dec 20, 2012 at 3:51 AM

This is due to standard theme removing white spaces without checking "compress html" setting.

To fix it, open /themes/standard/site.master.cs and remove or comment out this line:

html = reg.Replace(html, string.Empty).Trim();

We need to check that setting and also if "pre" tag exists before minifying html, I'll fix it going forward.

Dec 21, 2012 at 12:16 AM

Cool, that fix it!

Apr 21, 2014 at 12:02 PM
Met the exact same issue and fixed by commenting out the line of html = reg.Replace(html, string.Empty).Trim();