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:
- A stylesheet must be added to (the head of) pages that want to use highlighting.
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
/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.