Skip to content

Syntax highlighting

Josh Bruce edited this page Aug 27, 2016 · 5 revisions

It is possible to add syntax highlighting to blocks of code within comments you make.

  1. Three tick marks (```) in a row are translated into <code><pre>, which means whitespace is preserved without extra HTML.
  2. Three tick marks followed by a language specifier allows GitHub Markdown to highlight the code.
/**
  *
  * This is an example using ```JavaScript
  *
**/
var HelloWorld = function() { }

HelloWorld.prototype = {
    sayHello: function(label) {
        return 'Hello ' + label;
    }
}

var helloGitHub = HelloWorld.sayHello('GitHub');
console.log(helloGitHub);
// Should result in "Hello GitHub" appearing in your browser's console.
/**
  *
  * This example uses ```CSS
  *
**/
body {
    margin: 0;
    padding: 0;
    background-color: #cccccc;
}
Clone this wiki locally