dp.SyntaxHighlighter in Community Server

I was trying to integrate dp.SyntaxHighlighter (the highlighting system that I use for my source code in this blog) into Community Server. I’ve never before had a look at the inner workings of Community Server, so I may certainly be missing something.

To integrate the highlighter into a blog, two things need to be done:

  1. A stylesheet must be added to (the head of) pages that want to use highlighting.
  2. JavaScript code must be added to those same pages, preferably right at the end, but certainly after all elements (normally textareas) that contain code that needs to be highlighted.

The first thing I was trying to understand is how CS builds its pages. I found that with the default blog theme, the main body of a blog post page is rendered by the file ThemesBlogsdefaultBlogMaster.ascx. In that file, right in front of the tag </CS:Head>, I added my new stylesheet reference:

   <CS:Style  runat="server" Href="/syntaxhighlighting/SyntaxHighlighter.css" ID="Style3" Enqueue="true"/>

At the end, in front of </CS:MPContent>, I added the block of references to JavaScript code and also the final call to the highlighting code:

/syntaxhighlighting/shCore.js
/syntaxhighlighting/shBrushCSharp.js
/syntaxhighlighting/shBrushXml.js
/syntaxhighlighting/shBrushVb.js
/syntaxhighlighting/shBrushSql.js
/syntaxhighlighting/shBrushDelphi.js
/syntaxhighlighting/shBrushJScript.js

  
 

Obviously Community Server doesn’t normally allow the necessary textarea tag in user posts, so I had to edit communityserver.config and add the entry <textarea name = "true" class = "true" /> to the <html> list under <MarkUp>. That done, I was able to create a post with a textarea and some C# code in it, and it was rendered correctly by the dp.SyntaxHighlighter code. Great stuff!

Now, the bad news is that once the theme for the blog is switched, my changes are useless. Why’s that? I switched to the theme PoisonIvy/Fire, and although there’s no other BlogMaster.ascx there, it doesn’t seem to use the one from the default theme. Apparently it doesn’t use any BlogMaster.ascx at all. Oh well. I wonder if there’s another mechanism that makes it possible to make changes in a place where they’ll be used automatically for all blog pages, regardless of the themes. Nobody in the Community Server Forums seems to care, or maybe I’m using the wrong search terms.

1 Comment on dp.SyntaxHighlighter in Community Server

  1. I think the file other skins use is LayoutTemplate.ascx.I hope this helps.

    Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s