X
dnn.blog.
Back

Syntax Highlighting with Live Writer

Showing code is a very fundamental thing for a blogger writing about developing code. I like blogs with syntax highlighted code and there are a lot plugins for windows live writer outside which show code formatted well. But if you ever want to copy some of this code to clipboard for your own usage, you have to strip out html-tags, blank lines and all this format staff. This blog post is about how to do it in a better way.

Google is my friend

With Google I found a solution on codeplex which is build in two parts. One part is the  WLW-Plugin, which enables you to insert your code in a window and choose some options. The other part is a plugin for Blogengine.NET , based on SyntaxHighlighter  from Alex Gorbatchev. I installed the blog engine on my test machine and yeah ! This was cool!  You have a smart display, can copy or print source code without a hassle.

using System;
using System.Collections.Generic;
using System.Text;

namespace CSharp
{
	public class Class1
	{
		public static void Main(string[] args)
		{
		}
	}
}

But.. if I want to use Blogengine.NET together with my dnn web page, I have to skin the blog engine template like my dnn skin, have to synchronize the menus and deal with double logins. Not the best solution at all. So I started Google again and found a blog about how to use the FCK-Editor together with SyntaxHighlighter from Alex Gorbatchev. With this information and the knowledge that the DNN-Blog-Module is able to communicate with live writer I have everything I need!

How to install

First download the following :

Install Highlighter Files in DNN installation

  1. Create directory /styles/sh in  DNN installation
  2. Unzip Syntax Highlighter archive to harddisk
  3. Copy all files from styles-subdir to /styles/sh
  4. Create subdirectory sh in existing directory /js
  5. Copy all files from scripts-subdir to /js/sh

Inserting references to highlighter scripts and css-files in page

This can be done in different ways. We can “inject” some code in the page if we use Page settings – Advanced settings – Page Header Tags. But this field is limited to 500 chars (DNN 5.5.1) and normally that is not enough for what we need to do. We need to insert in the page header the following :

<link href="/styles/sh/shCore.css" rel="stylesheet" type="text/css">
<link href="/styles/sh/shThemeDefault.css" rel="stylesheet" type="text/css">

Altogether this is 546 bytes long, 46 bytes to long for the header field. So you can leave out one brush file or use an injector module like WillStrohl.Injection Module . Because I needed all brushes and don't want to install another module, I took another approach:

Modifying Skin Files

We can add the CSS-Files to the skin by using the [STYLE]-SkinObject. Open your skin .ascx with your favorite editor  and add the following @Register directive (if not present)

<%@ Register TagPrefix="dnn" TagName="STYLES" Src="~/Admin/Skins/Styles.ascx" %>

Then add the following to the bottom of the page:

<dnn:styles useskinpath="false" stylesheet="/styles/sh/shCore.css" name="ShCoreStyle" id="ShCoreStyle" runat="server"/>
<dnn:styles useskinpath="false" stylesheet="/styles/sh/shThemeDefault.css" name="ShThemeStyle" id="ShThemeStyle" runat="server"/>

Now you can leave out the first 2 lines of the page injection code and that's enough for me !  If you need more Brushes (Erlang, Ruby,Perl and so on…) you have to go the way with an injector module.

Modify blog module

Now open the module settings of your blog module, navigate to “advanced settings” and insert the following into the Header-Field:

Install WLW-Plugin

Last thing to do is installing the wlw-plugin. Unzip the codeplex zipfile and locate WindowsLiveWriter.SourceCode.dll

Copy WindowsLiveWriter.SourceCode.dll into your Windows Live Writer plugin folder:
    * 32-bit systems: C:\Program Files\Windows Live\Writer\Plugins
    * 64-bit systems: C:\Program Files (x86)\Windows Live\Writer\Plugins

Back
Total: 8 Comment(s)
essa
Really very brilliant share! All of the elements with this share could be very great and effortless to appreciate.The particular publish has quite a lot of expertise a couple of new trend matter. Maintain up the fine work. http://www.writemyessayz.co > custom essay writing service Thanks for all you could do.
Thursday, March 22, 2018 · reply ·
AdilahBisar
I have read in another post that you can simply notice the line and column figure for each point in the code clip to make sure that you are highlighting the https://www.perfectcv.ae/cover-letter-writing/ correct position or that you don’t exceed your selected snippet size.
Tuesday, April 10, 2018 · reply ·
Richard Davidson
HTTP Injector APK Download https://httpinjector.co/
Tuesday, June 5, 2018 · reply ·
kams9
www.google.com thanks for this post.
Tuesday, September 11, 2018 · reply ·
Chayce
You need to highlight something else so that you can know what things are going on here and it will be great to be achieve on https://www.topreviewstars.com/best-essay-writing-services/. I need to try it too.
Thursday, January 10, 2019 · reply ·
Business Plan consultants in UAE
The UAE has become a popular destination for entrepreneurs. The government has launched great schemes and Plans that encourage entrepreneurship. These enterprises have the capability to drive the economy forward and generate employment. Obviously, to succeed in this competitive market, any company needs a great business plan and under our Business Plan Writing Help in Dubai Service we create such plans for you.
Monday, April 29, 2019 · reply ·
Business Plan consultants in UAE
The UAE has become a popular destination for entrepreneurs. The government has launched great schemes and Plans that encourage entrepreneurship. These enterprises have the capability to drive the economy forward and generate employment. Obviously, to succeed in this competitive market, any company needs a great business plan and under our Business Plan Writing Help in Dubai Service we create such plans for you. https://www.writing4u.ae/
Monday, April 29, 2019 · reply ·
PhD Thesis Help
Medical Dissertation writing help in Dubai, UAE is ready to provide the right support and mentoring needed by all our clients. We always believe in providing one-stop-solution for all ethical academic assistance to all of our clients. Medical Dissertation Writing Company in Dubai, UAE provides the most comprehensive solution to your dissertation report writing and extensive mentoring for dissertation help. https://www.gulfdissertation.com/
Monday, April 29, 2019 · reply ·

about.me.

Torsten WeggenMy name is Torsten Weggen and I am CEO of indisoftware GmbH in Hanover, Germany. I'm into DNN since 2008. Before this, I did a lot of desktop stuff mainly coded with Visual Foxpro (see http://www.auktionsbuddy.de). 

I'm programmer, husband, father + born in 1965.

Please feel free to contact me if you have questions.

Latest Posts

DNN module development with Angular 2+ (Part 7)
6/10/2018 1:43 PM | Torsten Weggen
DNN module development with AngularJS (Part 6)
12/16/2016 7:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 5)
12/16/2016 6:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 4)
12/16/2016 5:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 3)
12/16/2016 4:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 2)
12/16/2016 3:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 1)
12/15/2016 7:19 AM | Torsten Weggen
Blogging in DNN with Markdown Monster by Rick Strahl
11/27/2016 1:14 PM | Torsten Weggen
Creating a global token engine
11/18/2016 10:25 AM | Torsten Weggen
DnnImagehandler - Hot or not ?
2/21/2015 11:52 PM | Torsten Weggen

My Twitter

Torsten Weggen 3/17/2019

You can make a real difference in Abir ’s life. Join me on @Kiva https://t.co/NlCTgIAZAN

Torsten Weggen 2/2/2019

As a freelance developer I often get invites from headhunters. This one should be very interesting... https://t.co/CNrEXBTBuJ

Torsten Weggen 10/11/2018

Evernote or OneDrive user and love #markdown #markdownmonster ? Take a look at Joplin! https://t.co/4bzkiD6CHn