Easy Flexible Syntax Highlighting Plugin For jQuery - Syntaxy.js

File Size: 401 KB
Views Total: 811
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Easy Flexible Syntax Highlighting Plugin For jQuery - Syntaxy.js

Syntaxy.js is a simple, flexible, extensible, themeable code syntax highlighter designed for all syntax languages. Can be used as a jQuery plugin or a standalone JavaScript library. Currently comes with 3 themes and you can create your own themes easily.

How to use it:

1. Load a theme CSS of your choice in the head section of the html page.

<link rel="stylesheet" href="syntaxy.dark.min.css">
<link rel="stylesheet" href="syntaxy.light.min.css">
<link rel="stylesheet" href="syntaxy.purple.min.css">

2. Load the core JavaScript file in the page. jQuery library is optional.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="src/js/syntaxy.js"></script>

3. Wrap your code snippets into the pre tag and specify the language type using data-type attribute.

<pre id="codebox" data-type="default">
    // some code here

4. Initialize the syntax highlight with default options.


5. All default configuration options.


  // special tag open delimeter
  tagOpen     : '«', 

  // special tag split delimeter
  tagSplit    : '≈', 

  // special tag close delimeter
  tagClose    : '»', 

  // final markup tag name
  tagName     : 'span', 

  // syntaxy css class prefix
  classPrefix : 'stx-', 

  // title to show on code box header
  codeTitle   : 'Source code', 

  // default syntax type to be used
  codeType    : '', 

  // min height of syntax scroll container
  minHeight   : '100px', 

  // max height of syntax scroll container
  maxHeight   : '600px', 

  // if rendering inline code containers
  isInline    : false, 

  // wrap long lines
  wordWrap    : false, 

  // line to statrt counting from
  startLine   : 1, 

  // comma separated line numbers to debug (flash)
  debugLines  : '', 

Change log:


  • Fixed issue with converting tabs to spaces causing space characters (\s) to be shown in syntax highlighter.


  • Fixed syntaxy container header text color to use theme text color instead of inherit.


  • Fixed line numbers column showing a preppended 0 on first line.

This awesome jQuery plugin is developed by rainner. For more Advanced Usages, please check the demo page or visit the official website.