Syntax Highlighter on Pages

Topics: Controls
May 13, 2012 at 3:13 AM

I am using BlogEngine.NET v2.5.0.6. I post code on my blog and have used the syntax highlighter in posts. When I try to add code blocks on pages, the syntax highlighter does not work. The editor allows you to enter the code block, the tags are created, however the syntax highlighter does not work. I looked at the HTML source and the js files are not being loaded on pages in the header.

Is there a way to enable the Syntax Highlighter for pages?

Thanks in advance for any help.

May 14, 2012 at 2:09 AM

I edited the SyntaxHighlighter extension and changed the following code that I saw in the Media Handler Extension. It seems to work for pages and posts. Please comment if this was ok or should it be enabled a different way for pages to work with the Syntax Highligher. Thanks.

In SyntaxHighlighter.cs

I changed

    static SyntaxHighlighter()
    {
        Post.Serving += AddSyntaxHighlighter;
        InitSettings();
    }

to:

    static SyntaxHighlighter()
    {
        Post.Serving += AddSyntaxHighlighter;
        BlogEngine.Core.Page.Serving += AddSyntaxHighlighter;
        InitSettings();
    }