13

We are planning to move our current knowledge base to Salesforce Knowledge. One of the main concerns is that we have tons of sample code in different languages (C#, JavaScript, VB, Delphi) and it seems that SF Knowledge does not provide a built-in syntax highlight feature.

Does anyone know whether there is a way to add syntax highlight for code contained in a Salesforce Knowledge article?

2
  • An alternative could be to use images taken after code is syntax higlighted in sublime text or any other tool . Commented Nov 8, 2013 at 11:49
  • 1
    I know this isn't Ideal, but in cases like this we've had some success in just having using copy the formatted text form another program, and paste into a rich text field for the article. Again, not ideal, but a possible workaround. Commented Nov 8, 2013 at 12:15

2 Answers 2

1

You can't do this using any built-in functionality of Salesforce knowledge, but you can use an external JavaScript syntax highlighter in conjunction with a Visualforce page to display the knowledge article.

I've integrated Alex Gorbatchev's Syntax Highlighter (http://alexgorbatchev.com/SyntaxHighlighter/) which produces the output shown below when I render an article containing code:

enter image description here

This is using the java brush - you may find you prefer one of the others.

I've written up how to achieve this in a blog post at:

http://bobbuzzard.blogspot.co.uk/2014/01/syntax-highlighting-in-knowledge.html

1

This feature is now native after summer 14 release

enter image description here

There is a code sample button where one can add code

2
  • Great! But is the code is highlighted in correspondence to the code language? Commented Aug 11, 2014 at 8:03
  • No .As you can see its just Pre tab and wont be doing syntax highlighting as the below solution from BOb Commented Aug 11, 2014 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .