Changeable SyntaxHighlighter Theme on BlogEngine.NET using Extension

Alex Gorbatchev create a great tool, write on JavaScript, to highlight our code on blog posting. But how to implement SyntaxHighlighter on every post in our BlogEngine.NET? There is a good Windows Live Writer Plugin by David Pokluda that implement SyntaxHighlighter into BlogEngine.NET using the Extension.

But the extension by Pokluda doesn’t have the ability to change the SyntaxHighlighter Theme, by 30 July 2009, SyntaxHighlighter have 6 built in theme, please check at the web. Therefore i want to extend the extension by Pokluda to have an ability to change the theme.

Basically, to do this we need a setting for the extension, using ExtensionSettings class would be the answer.

// Code by Rudy Setyo Purnomo
// http://rudysetyo.it

ExtensionSettings settings = new ExtensionSettings(“SyntaxHighlighter”);

settings.AddParameter(
    "shTheme", 
    "shTheme", 
    50, 
    true, 
    true, 
    ParameterType.RadioGroup);
settings.AddValue(
    "shTheme", 
    new string[] 
        { 
            "shThemeDefault",
            "shThemeDjango", 
            "shThemeEmacs", 
            "shThemeFadeToGrey",
            "shThemeMidnight",
            "shThemeRDark"
        }, 
    "shThemeDefault");

settings.Help = "SyntaxHighlighter Theme";

ExtensionManager.ImportSettings(settings);

If you see the original code by Pokluda, you’ll see that the AddStylesheetToPage method only have one parameter, i add one more parameter to set the Theme.

// Code by Rudy Setyo Purnomo
// http://rudysetyo.it

private void AddStylesheetToPage(Page page, string theme)
{
    HtmlLink css = new HtmlLink();
    css.Attributes["type"] = "text/css";
    css.Attributes["rel"] = "stylesheet";
    css.Attributes["href"] = GetAbsoluteFromRelativeUrl("SyntaxHighlighter/Styles/shCore.css");
    page.Header.Controls.Add(css);

    css = new HtmlLink();
    css.Attributes["type"] = "text/css";
    css.Attributes["rel"] = "stylesheet";
    css.Attributes["href"] = GetAbsoluteFromRelativeUrl("SyntaxHighlighter/Styles/" + theme + ".css");
    page.Header.Controls.Add(css);
}

// and use this code to receive Theme name from setting parameter.

string theme = _settings.GetSingleValue("shTheme");

These screenshot is the setting screen to change the theme

setting

And the is the 6 theme:

shThemeDefault
shThemeDefault

shThemeDjango
shThemeDjango

shThemeEmacs
shThemeEmacs

shThemeFadeToGrey
shThemeFadeToGrey

shThemeMidnight
shThemeMidnight

shThemeRDark
shThemeRDark

You could find the full code here, put the SyntaxHighlighter.cs at App_Code/Extensions folder.

117 Comments

  • thanks the information that i gather from your site.

  • blogengine is good for blogging?

  • That is really fascinating, You're a very skilled blogger. I have joined your rss feed and stay up for searching for extra of your excellent post. Additionally, I have shared your web site in my social networks

  • This is really interesting, You're a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your web site in my social networks!

  • I have been surfing on-line greater than three hours these
    days, yet I never discovered any fascinating article like yours.

    It's lovely worth enough for me. In my view, if all site owners and bloggers made excellent content material as you did, the net shall be much more useful than ever before.

  • My partner and I stumbled over here from a different web address and
    thought I may as well check things out. I like
    what I see so now i'm following you. Look forward to looking into your web page repeatedly.

  • When someone writes an paragraph he/she maintains the idea
    of a user in his/her mind that how a user can understand it.
    So that's why this post is perfect. Thanks!

  • If some one desires expert view concerning running a blog then
    i advise him/her to pay a visit this blog, Keep up the good work.

  • Wow, amazing blog layout! How lengthy have you ever been running a blog for?
    you make running a blog look easy. The entire look
    of your site is magnificent, let alone the content material!

  • Remarkable! Its in fact awesome piece of writing, I have got much clear idea concerning from this
    paragraph.

  • Have you ever thought about including a little bit more than just your articles?
    I mean, what you say is important and everything.

    But imagine if you added some great photos or videos to give your
    posts more, "pop"! Your content is excellent but with images and clips, this website could definitely be one of the greatest in its niche.
    Great blog!

  • Way cool! Some very valid points! I appreciate you writing this article and also
    the rest of the site is also very good.

  • It's actually very difficult in this active life to listen news on TV, so I just use world wide web for that purpose, and get the hottest news.

  • Superb, what a blog it is! This weblog provides helpful data to us, keep it up.

  • obviously like your web site but you have to take a look at the spelling on several of your posts.
    A number of them are rife with spelling problems and I to find it very bothersome to tell the reality
    nevertheless I'll certainly come again again.

  • Hello to every one, the contents present at this website are actually remarkable for people knowledge, well, keep up the good work fellows.

  • Now I am going away to do my breakfast, afterward having my breakfast coming over again to read additional news.

  • I don't comment, however I browsed a few comments on Changeable SyntaxHighlighter Theme on BlogEngine.NET using Extension - Rudy Setyo Purnomo. I actually do have 2 questions for you if you tend not to mind. Could it be only me or do some of these remarks appear like they are left by brain dead visitors? :-P And, if you are posting on other online social sites, I'd like to follow you.
    Would you list of all of your social community pages like your
    linkedin profile, Facebook page or twitter feed?

  • Appreciating the dedication you put into your blog and detailed
    information you present. It's great to come across a blog every once in a while that isn't the same
    old rehashed material. Great read! I've saved your site and I'm adding your RSS
    feeds to my Google account.

  • Hi, i think that i saw you visited my website thus i came to “return the
    favor”.I'm attempting to find things to improve my web site!I suppose its ok to use a few of your ideas!!

  • Hey, I think your website might be having browser compatibility issues.
    When I look at your blog in Ie, it looks fine but when opening in Internet Explorer, it has
    some overlapping. I just wanted to give you a quick heads up!
    Other then that, very good blog!

  • Hello to all, how is all, I think every one is getting more from this site, and your views are nice in favor
    of new visitors.

  • I got this site from my friend who told me concerning
    this web page and at the moment this time I am browsing this site and reading very informative content at this
    place.

  • Thanks , I've just been looking for information about this topic for a while and yours is the greatest I have found out till now. But, what about the conclusion? Are you sure in regards to the source?

  • Nice post. I learn something totally new and challenging on blogs I stumbleupon everyday.
    It will always be helpful to read through articles from other writers and use a little something from their sites.

  • Heya i am for the first time here. I found this board and I find It truly useful & it helped me out much.
    I hope to give something back and aid others like you aided me.

  • Heya just wanted to give you a brief heads up and let
    you know a few of the images aren't loading properly. I'm not sure why but I think its a linking issue.
    I've tried it in two different browsers and both show the same outcome.

  • Heya i am for the first time here. I found this board and
    I find It truly useful & it helped me out a lot. I hope
    to give something back and help others like you aided me.

  • An outstanding share! I have just forwarded this onto a co-worker who has been conducting
    a little research on this. And he actually ordered me lunch simply because I discovered it for him.
    .. lol. So allow me to reword this.... Thanks for the meal!
    ! But yeah, thanks for spending time to talk about this matter
    here on your web site.

  • Good day I am so thrilled I found your web site,
    I really found you by error, while I was looking on Bing for something else, Anyways I am here now and would just like to say thanks a lot for a marvelous post and
    a all round thrilling blog (I also love the theme/design),
    I don’t have time to read it all at the moment but I have book-marked it and also included your RSS feeds, so when I
    have time I will be back to read a great deal more,
    Please do keep up the excellent jo.

  • Unquestionably imagine that that you said.
    Your favorite reason appeared to be on the web the simplest factor to have in mind of.

    I say to you, I certainly get annoyed while other folks consider worries that they plainly do
    not recognise about. You managed to hit the nail upon the top as neatly as outlined out the whole
    thing without having side effect , other people can take a signal.

    Will probably be back to get more. Thanks

  • Thankfulness to my father who stated to me about
    this web site, this weblog is in fact amazing.

  • Hello to every single one, it's in fact a fastidious for me to pay a visit this site, it contains useful Information.

  • I think that what you said made a ton of sense. But, consider this, suppose
    you added a little information? I am not saying your
    information is not solid, however what if you added a headline that
    grabbed people's attention? I mean Changeable SyntaxHighlighter Theme on BlogEngine.NET using Extension - Rudy Setyo Purnomo is kinda boring. You might glance at Yahoo's
    home page and watch how they create post headlines to grab people to
    open the links. You might add a related video or a pic or two to
    get people interested about everything've written. In my opinion, it might make your website a little livelier.

  • Hmm is anyone else experiencing problems with the images on this blog loading?
    I'm trying to determine if its a problem on my end or if it's the blog.

    Any feedback would be greatly appreciated.

  • Appreciate the recommendation. Let me try it out.

  • Wow, awesome blog layout! How long have you been blogging for?
    you make blogging look easy. The overall look of your website
    is great, let alone the content!

  • Hi, just wanted to tell you, I liked this post. It was inspiring.
    Keep on posting!

  • This is my first time pay a quick visit at here and i am in fact pleassant to read all at alone place.

  • Hello, yup this article is actually nice and I have learned lot
    of things from it concerning blogging. thanks.

  • You should take part in a contest for one of the greatest websites online.
    I'm going to highly recommend this website!

  • These are really impressive ideas in concerning blogging.
    You have touched some pleasant points here. Any way
    keep up wrinting.

  • Pretty nice post. I simply stumbled upon your blog and wished to say that I've truly loved surfing around your weblog posts. After all I'll be subscribing in your feed and I hope you write once more very soon!

  • I am really enjoying the theme/design of your site.
    Do you ever run into any web browser compatibility issues?
    A couple of my blog audience have complained about my website not working correctly in Explorer but looks great
    in Chrome. Do you have any ideas to help fix this issue?

  • Superb post however I was wondering if you could write
    a litte more on this subject? I'd be very thankful if you could elaborate a little bit more. Kudos!

  • Hello there, You've done an excellent job. I'll certainly digg it and personally recommend to my friends.
    I'm sure they'll be benefited from this site.

  • You actually make it seem so easy with your presentation but I
    find this topic to be actually something that I think I would never understand.
    It seems too complicated and extremely broad for me.
    I'm looking forward for your next post, I'll try to get the
    hang of it!

  • Aw, this was a really good post. Taking a few minutes and actual effort to
    produce a superb article… but what can I say… I procrastinate
    a lot and don't seem to get anything done.

  • Really no matter if someone doesn't know afterward its up to other people that they will help, so here it occurs.

  • I'm really impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you modify it yourself? Anyway keep up the excellent quality writing, it is rare to see a nice blog like this one these days.

  • I'm gone to inform my little brother, that he should also pay a visit this blog on regular basis to obtain updated from most up-to-date news update.

  • Genuinely when someone doesn't understand after that its up to other people that they will help, so here it happens.

  • Hello, I enjoy reading all of your post. I wanted to
    write a little comment to support you.

  • What's up friends, its enormous post on the topic of tutoringand entirely explained, keep it up all the time.

  • Excellent web site you have here.. It's hard to find quality writing like yours nowadays. I really appreciate people like you! Take care!!

  • Undeniably imagine that which you stated.
    Your favorite justification appeared to be on the net the simplest thing to have in mind of.
    I say to you, I definitely get annoyed while other people consider issues that they plainly don't realize about. You managed to hit the nail upon the top as smartly as defined out the entire thing with no need side-effects , people can take a signal. Will likely be again to get more. Thanks

  • Hello friends, how is all, and what you wish for to say regarding this article, in my view its really amazing
    in support of me.

  • Hi there, just wanted to mention, I liked this post. It was funny.
    Keep on posting!

  • I got this web page from my friend who informed me concerning this web site and now
    this time I am browsing this web site and reading very informative content
    at this time.

  • I enjoy what you guys tend to be up too. This type of clever work and coverage!
    Keep up the fantastic works guys I've included you guys to blogroll.

  • We stumbled over here by a different web address and thought I may
    as well check things out. I like what I see so
    now i am following you. Look forward to
    checking out your web page for a second time.

  • It's great that you are getting thoughts from this post as well as from our argument made at this place.

  • I am actually delighted to read this webpage posts which contains
    tons of helpful facts, thanks for providing these information.

  • Hi there it's me, I am also visiting this web site daily, this website is truly fastidious and the users are truly sharing pleasant thoughts.

  • Great blog here! Also your website loads up fast!
    What web host are you using? Can I get your affiliate link to your host?

    I wish my web site loaded up as fast as yours lol

  • Appreciate the recommendation. Will try it out.

  • Very nice post. I just stumbled upon your
    blog and wanted to mention that I have really loved surfing around your
    blog posts. In any case I will be subscribing in your feed
    and I hope you write again very soon!

  • This piece of writing offers clear idea in support of the new visitors of blogging, that
    in fact how to do running a blog.

  • Hi Dear, are you genuinely visiting this web site on a regular basis, if so after
    that you will definitely take fastidious knowledge.

  • Yes! Finally something about kinkos business cards.

  • You actually make it seem so easy with your presentation but I find this matter to be
    actually something that I think I would never understand. It seems too complex and very broad for me.
    I'm looking forward for your next post, I'll try to get the
    hang of it!

  • I relish, lead to I discovered just what
    I was having a look for. You have ended my four day long hunt!
    God Bless you man. Have a nice day. Bye

  • Thanks for sharing your thoughts about beautiful bathrooms.

    Regards

  • Hurrah, that's what I was looking for, what a material! present here at this weblog, thanks admin of this website.

  • Wow, that's what I was exploring for, what a data! present here at this weblog, thanks admin of this website.

  • We are a group of volunteers and opening a new scheme in our community.
    Your website provided us with valuable info to work on.
    You've done a formidable job and our entire community will be grateful to you.

  • What's up, the whole thing is going perfectly here and ofcourse every one is sharing information, that's really good, keep up writing.

  • I do not even know how I ended up here, but I thought this post was good.
    I don't know who you are but definitely you are going to a famous blogger if you aren't
    already ;) Cheers!

  • I visited multiple web pages except the audio quality for audio
    songs current at this web site is in fact excellent.

  • Fine way of explaining, and nice piece of writing to obtain facts concerning my presentation topic, which i
    am going to present in academy.

  • I'm amazed, I have to admit. Seldom do I come across a blog that's both equally educative and interesting, and without
    a doubt, you have hit the nail on the head. The issue
    is an issue that not enough men and women are speaking intelligently about.
    I'm very happy I found this in my hunt for something relating to this.

  • This article is truly a nice one it assists new the
    web users, who are wishing in favor of blogging.

  • If some one needs to be updated with hottest technologies then he must be
    pay a visit this web page and be up to date every day.

  • It's awesome to go to see this site and reading the views of all mates regarding this article, while I am also zealous of getting experience.

  • If you wish for to increase your familiarity just keep visiting this site and be updated with
    the most recent gossip posted here.

  • Hey there would you mind stating which blog
    platform you're working with? I'm planning to start my own blog soon but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I'm looking for something completely unique.
    P.S Apologies for getting off-topic but I had to ask!

  • Hello everyone, it's my first pay a quick visit at this site, and piece of writing is truly fruitful for me, keep up posting such content.

  • May I simply just say what a relief to find an individual who really knows what they are discussing online.
    You definitely know how to bring a problem to light and make it important.
    More people have to check this out and understand this side of the story.
    It's surprising you are not more popular because you most certainly have the gift.

  • Does your website have a contact page? I'm having problems locating it but, I'd like to send you an
    email. I've got some recommendations for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.

  • Hi there i am kavin, its my first occasion to commenting anywhere,
    when i read this piece of writing i thought i could also make comment due to this sensible post.

  • Hi there, for all time i used to check blog posts here in the
    early hours in the dawn, because i like to find out
    more and more.

  • What's up mates, its great paragraph concerning educationand fully defined, keep it up all the time.

  • Hi, after reading this amazing post i am as well glad to
    share my knowledge here with colleagues.

  • Great goods from you, man. I have be mindful your stuff previous to and you're simply extremely great. I actually like what you've
    received here, really like what you are saying and the best way during which you are saying it.
    You make it enjoyable and you still take care of to keep it wise.
    I can't wait to learn much more from you. That is actually a tremendous site.

  • I am really glad to glance at this weblog posts which carries
    tons of helpful information, thanks for providing these kinds of data.

  • Wow, fantastic blog layout! How long have you been running a blog for?
    you make blogging look easy. The entire look of your web site is great,
    let alone the content material!

  • Hello, i think that i noticed you visited my weblog thus i got here to go back the favor?

    .I am attempting to in finding things to enhance my web site!
    I assume its good enough to make use of some of your ideas!
    !

  • Pretty nice post. I just stumbled upon your weblog
    and wished to say that I have really enjoyed browsing your
    blog posts. After all I will be subscribing to your feed and I hope you write again
    very soon!

  • It's really very complex in this full of activity life to listen news on Television, therefore I just use internet for that reason, and obtain the latest news.

  • Link exchange is nothing else except it is only
    placing the other person's webpage link on your page at proper place and other person will also do same for you.

  • I do believe all of the ideas you have offered
    for your post. They are really convincing and can definitely work.
    Nonetheless, the posts are too quick for newbies.
    May you please extend them a bit from next time? Thanks for the post.

  • I constantly emailed this weblog post page to all my contacts, since if like to read it next my
    contacts will too.

  • I really like what you guys are up too. This type of clever work and coverage!
    Keep up the fantastic works guys I've included you guys to my blogroll.

  • Aw, this was an exceptionally nice post. Finding the time and actual effort to make a very good article… but what can
    I say… I procrastinate a whole lot and never manage to get nearly anything done.

  • No matter if some one searches for his necessary thing, thus he/she wants to be available that
    in detail, so that thing is maintained over here.

  • Wonderful beat ! I wish to apprentice while
    you amend your website, how can i subscribe for
    a blog site? The account helped me a acceptable deal. I had been a little bit acquainted
    of this your broadcast provided bright clear idea

  • Good answer back in return of this query with real arguments and describing everything on the
    topic of that.

  • Hello! Would you mind if I share your blog with my twitter group?
    There's a lot of people that I think would really appreciate your content. Please let me know. Cheers

  • Hi my loved one! I wish to say that this post is amazing, great written
    and include approximately all significant infos. I'd like to peer more posts like this .

  • Very rapidly this website will be famous amid all blog users, due to it's fastidious content

  • I drop a comment whenever I like a post
    on a site or if I have something to add to the discussion.
    Usually it is triggered by the passion communicated in the post I read.

    And on this post Changeable SyntaxHighlighter Theme on BlogEngine.
    NET using Extension - Rudy Setyo Purnomo. I was actually moved enough to drop
    a thought :-P I actually do have a few questions for you if it's allright. Is it just me or do a few of these responses appear like left by brain dead people? :-P And, if you are posting on additional online social sites, I would like to keep up with you. Could you make a list the complete urls of all your public sites like your linkedin profile, Facebook page or twitter feed?

  • Hi, yeah this piece of writing is really nice and I have learned lot of things from
    it regarding blogging. thanks.

  • It's going to be end of mine day, except before ending I am reading this impressive post to increase my experience.

  • I like what you guys tend to be up too. This type of clever work and reporting!

    Keep up the amazing works guys I've incorporated you guys to blogroll.

  • Ahaa, its pleasant conversation concerning this piece of writing here at this
    webpage, I have read all that, so now me also commenting here.

  • My spouse and I stumbled over here by a different web address
    and thought I may as well check things out. I
    like what I see so now i'm following you. Look forward to looking over your web page repeatedly.

  • Hurrah! Finally I got a blog from where I know how to truly get helpful data regarding my study and knowledge.

Comments have been disabled for this content.