Syntax Highlighting

Prism.js

Code fragments can be displayed with automatic syntax highlighting

Simply use the normal fence ticks in markdown and add the language like this.

   ```cpp
   void loop(void) {
     MDNS.update();
     server.handleClient();
   }
   ```

Many languages are supported here but not all that are available from the full set available. This installation supports the following:

  • arduino
  • basic
  • c
  • clike
  • cmake
  • gcode
  • git
  • ini
  • javascript
  • json
  • jsonp
  • makefile
  • markup
  • matlab
  • processing
  • python
  • sql
  • vbnet

Here are some examples.

C++

void loop(void) {
  MDNS.update();
  server.handleClient();
}

BASIC

5 LET S = 0
10 MAT INPUT V
20 LET N = NUM
30 IF N = 0 THEN 99
40 FOR I = 1 TO N
45 LET S = S + V(I)
50 NEXT I
60 PRINT S/N
70 GO TO 5
99 END

PYTHON

# Python program to check if the input number is odd or even.
# A number is even if division by 2 gives a remainder of 0.
# If the remainder is 1, it is an odd number.

num = int(input("Enter a number: "))
if (num % 2) == 0:
   print("{0} is Even".format(num))
else:
   print("{0} is Odd".format(num))

HTML

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Operators</h2>
<p>The + operator concatenates (adds) strings.</p>
<p id="demo"></p>
</body>
</html>

JAVASCRIPT

var person = {
  firstName:"John",
  lastName: "Doe",
  fullName: function () {
    return this.firstName + " " + this.lastName;
  }
}
person.fullName();   // Will return "John Doe"

Syntax highlighting was done using prism.js and the WP Prism Syntax Highlighter plugin

Custom prism.css and prism.js files were downloaded from the Prismjs download site

Or you could choose to modfy your theme directly as described in Prism js with WordPress