The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.

Create a free forum like this one.

Colorize the code tags

View previous topic View next topic Go down

Colorize the code tags

Post by Ange Tuteur on November 20th 2015, 1:24 pm

Colorize the code tags

This tutorial will help you with coloring the contents of the code tags just like in the following example :

1. Installing the JavaScript

Firstly, you must create a new script by going to Modules > JavaScript codes management. Make sure JS codes management is enabled and then create a new script with the following settings.

Title : Code syntax highlighter
Placement : In the topics
$(function(){var a=$("dl.codebox dd").find("code, div.cont_code");0!=a.length&&$.ajax({url:"",cache:!0,dataType:"script",success:function(){hljs.configure({useBR:!0});a.each(function(a,b){hljs.highlightBlock(b)})}})});

Save the script when you're finished.

2. Installing the CSS

Lastly, you need to add a bit of CSS to your stylesheet to color the formatted code. Go to Display > Colors > CSS stylesheet and paste the following CSS rules* :
.hljs {
  display: inline-block;
  padding: 0.5em;
  color: #333;
  background: #f8f8f8;
.diff .hljs-header,
.hljs-javadoc {
  color: #998;
  font-style: italic;
.css .rule .hljs-keyword,
.javascript .hljs-title,
.nginx .hljs-title,
.hljs-status {
  color: #333;
  font-weight: bold;
.ruby .hljs-constant {
  color: #099;
.hljs-tag .hljs-value,
.tex .hljs-formula {
  color: #d14;
.coffeescript .hljs-params,
.scss .hljs-preprocessor {
  color: #900;
  font-weight: bold;
.javascript .hljs-title,
.lisp .hljs-title,
.clojure .hljs-title,
.hljs-subst {
  font-weight: normal;
.hljs-class .hljs-title,
.haskell .hljs-type,
.vhdl .hljs-literal,
.tex .hljs-command {
  color: #458;
  font-weight: bold;
.hljs-tag .hljs-title,
.hljs-rules .hljs-property,
.django .hljs-tag .hljs-keyword {
  color: #000080;
  font-weight: normal;
.lisp .hljs-body {
  color: #008080;
.hljs-regexp {
  color: #009926;
.ruby .hljs-symbol .hljs-string,
.lisp .hljs-keyword,
.tex .hljs-special,
.hljs-prompt {
  color: #990073;
.lisp .hljs-title,
.clojure .hljs-built_in {
  color: #0086b3;
.hljs-cdata {
  color: #999;
  font-weight: bold;
.hljs-deletion {
  background: #fdd;
.hljs-addition {
  background: #dfd;
.diff .hljs-change {
  background: #0086b3;
.hljs-chunk {
  color: #aaa;

Click submit when you're done, and it is now installed ! Yes

*You can preview the other themes here, and the corresponding CSS files via Github.

Ange Tuteur

Male Posts : 13174
Reputation : 2870
Language : EN10, FR5
Location : Macungie, PA

Back to top Go down

View previous topic View next topic Back to top

Permissions in this forum:
You cannot reply to topics in this forum