Add Code Examples to Posts

Last Updated on August 2, 2017 by Rakesh Gupta

My Blog QR code

After Spring’14 release you can now add Code samples to posts when the rich text editor is enabled in Chatter Answers and Ideas, and code will display in proper format.

Configure this feature for your organization

To configure it for ideas follow the blow steps

1) Click on Name | Setup | App Setup | Customize | Ideas | Settings
2) Click on Edit

Enable Rich Text Editor For Ideas
Enable Rich Text Editor For Ideas

3) Select “Enable Text-Formatting, Images and Links” checkbox
4) Click on Save

Note :- Once you enabled this setting, you can’t disable it. For Chatter Answers, select Enable Rich Text Editor, You can take help from below image.

Enable Rich Text Editor For Chatter Answer
Enable Rich Text Editor For Chatter Answer

Now it’s time to test this feature

To test this feature follow the below steps

1) Navigate to Idea tab, click on any idea it will drill down you to idea detail page or create a New Idea

Navigate to Ideas
Navigate to Ideas

2) Here you can past sample code ( I will show you first old output then you will come to know that the difference between both )

Old way to post code - Step 1
Old way to post code
public class HelloWorld { 
   public static void main(String[] args) { 
      System.out.println("Hello, World");
   }
}

Paste the sample code and click on Post.

3) Now we will try with new feature, first copy a code sample from any text editor and  click on Icon button to open the Add a code sample text box. Similar to below image

New way to post code By using rich text editor
New way to post code By using rich text editor

4) Click on OK, then click on Post. The code sample appears in the body of the post with its formatting intact.
5) Below image shows the difference between old and new method

Old and New way to post code
Old and New way to post code

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.