Screwturn Wiki 3 Syntax Highlighter 2

Lately I have been very busy with my senior project. I needed to work on with my senior project website first which is using Screwturn Wiki 3.0RC. Unfortunately I didn’t find any good addins for syntax highlighting as the one I’m using on this blog. So, I decided to write it all from scratch. It took me quite a while to understand the lifecycle of formatter plugin in screwturn wiki. But soon I was all set.

You can see the live example at http://projects.prabir.me/compiler/wiki/LLVMHelloworldInC.ashx

Below I have attached the addin that I’m using currently in my wiki which I hope you guys will find it useful. Here are the step required to install the plugin. You will need to download the necessasry files from the end of this post.

  • First of all upload the syntax highlighter files using FTP or any other mechanism to your wiki. In my case I uploaded to /compiler/wiki folder inside my sub-domain.
  • Then go to the administration page.
  • Click the Content Editing tab.
  • Then click HTML Head
  • In the wiki markup type the following code
<link type="text/css" rel="stylesheet" href="/compiler/wiki/styles/shCore.css" />
<link type="text/css" rel="stylesheet" href="/compiler/wiki/styles/shThemeDefault.css" />
<script type="text/javascript" src="/compiler/wiki/scripts/shCore.js">
</script>
<script type="text/javascript" src="/compiler/wiki/scripts/shBrushXml.js">
</script>
<script type="text/javascript" src="/compiler/wiki/scripts/shBrushPlain.js">
</script>
<script type="text/javascript" src="/compiler/wiki/scripts/shBrushCSharp.js">
</script>
<script type="text/javascript"> 
    SyntaxHighlighter.config.clipboardSwf
    = '/compiler/wiki/scripts/clipboard.swf';
    SyntaxHighlighter.all();
</script>
  • Include necessary Javascript files to support your language of choice. shCore.js is compulsory.
  • Then click the Save button.
  • Now click the Providers tab.
  • And in Provider’s DLL Management, select Browse and point to Prabir.ScrewTurn.Wiki.SyntaxHighlighter.dll and click Upload.

That is it. You wiki now supports syntax highlighting.

Writing code in wiki:

The syntax for writing code in wiki is

{@code-language:
write code here
@}

Replace language by necessary language such as text, cpp, c and so on. You can find them in the .js files. Search for aliases.

If you deal with arrays like [x], it may give you a different formatting – not as expected (It tends to use the wiki formatting style). So I recommend you to use the following syntax rather to obtain the best output:

{@code-language:<nowiki>
type your code here
</nowiki>@}

Prabir.ScrewTurn.Wiki.SyntaxHighlighter.zip (3.09 kb) Syntaxhighlighterversion 2.0.320May 03 2009.zip (59.23 kb)

Unfortunatley it doesn't support Screwturn wiki version 2.