Code Snippets in Knowledge Base

hanaphouse
Giga Guru

How do we properly display "code snippets" in the Knowledge Base? This will be very useful for software developers or programmers.

2 REPLIES 2

byoung
Tera Contributor

Hello Charles,


I know this is a bit late, but I am currently looking for something similar without much luck. Hopefully you already have a solution, but perhaps this could help out other people looking to do the same.



I was able to embed code snippets in a knowledge article (helsinki release) by editing the HTML source code for the article and wrapping my code with the <pre><code></code></pre> tags. Doing this allowed me to enter my formatted code into a box. It is not quite like what you would have on say Slack and does not use colored mark-up, but at least it gave us something, I will update you if I find anything else on the topic.



I also found this website which will build the HTML for you, including syntax.


Source code beautifier / syntax highlighter — convert code snippets to HTML « hilite.me


You are correct. I found the solution when we were working in Service Portal where I bumped into bootstrap and flexbox. Both <pre></pre> and <code></code> are based on CSS Bootstrap.



All bootstrap styles are applicable.