Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

[UI Script] highlight.js syntax highlighting


#1

Ahoj, heres a basic UI script to enable proper syntax highlighting using latest version of highlight.js

name: highlight.js Syntax Highlighter
description: highlight.js Syntax Highlighter
author: Gerald Reisinger
version: 1.0
includes: 
excludes: dashboard

js:
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css') );
$.getScript("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function () {
  $('code').each(function(i, block) {
    hljs.highlightBlock(block);
  });
});

If you need further supported languages or would enjoy a different theme, go ahead and checkout https://highlightjs.org/ :slight_smile: