Sitecore Stuff and Such

- by Christian Kay Linkhusen


Syntax highlighting with highlight.js

Highlight.js supplies a javascript library for syntax highlighting your code snippets on the web. The solution is hosted and is setup with inserting 3 lines of code. 

Include the Javascript, stylesheet and initialize the highlighting, by inserting the following 3 lines to the head section of your page:

<link rel="stylesheet" href=""> <script src=""></script> <script type="text/javascript">hljs.initHighlightingOnLoad();</script>

All you have to do now, is to mark up your code snippet in the content with <pre><code>[content]</code</pre> and you are up and running.
If you want to read more about highlight.js see the website for more information, on selecting different stylesheets, different usages of the library, customizing the code and more...  
Below are examples of different syntax highlights with highlight.js and the visual studio stylesheet:
Example with C#:
// Hello1.cs
public class Hello1
   public static void Main()
      System.Console.WriteLine("Hello, World!");

Example with XML:
    <blogProvider defaultProvider="XmlBlogProvider" fileStoreProvider="XmlBlogProvider">
        <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core" />
        <add connectionStringName="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" />
    <blogFileSystemProvider defaultProvider="XmlBlogProvider">
        <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlFileSystemProvider, BlogEngine.Core" />
        <add storageVariable="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbFileSystemProvider, BlogEngine.Core" />
        <!--<add storageVariable="\\UNCPath\BlogFiles" description="UNC Path Provider" name="UNCBlogProvider" type="BlogEngine.Core.Providers.UNCFileSystemProvider, BlogEngine.Core" />-->

Add comment