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?

  • An alternative could be to use images taken after code is syntax higlighted in sublime text or any other tool . – Mohith Shrivastava Nov 8 '13 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. – Chris Duncombe Nov 8 '13 at 12:15
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

  • Great! But is the code is highlighted in correspondence to the code language? – Dmitry Nikolaev Aug 11 '14 at 8:03
  • No .As you can see its just Pre tab and wont be doing syntax highlighting as the below solution from BOb – Mohith Shrivastava Aug 11 '14 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.