Syntax.js

A lightweight, and easy-to-use, JavaScript library for code syntax highligh...

README

Syntax.js


What features does Syntax.js have?


- Zero-dependencies and extremely lightweight!
- Full API available via public functions.
- Fully styled in CSS/SASS (including the buttons) and compatible with the Bootstrap library.
- Full CSS theme support (using :root variables).
- Custom triggers for actions (when elements are rendered, keywords are clicked, etc).
- 12 of the most popular languages built in by default (you can add your own easily if yours is not supported by default).

What browsers are supported?


All modern browsers (such as Google Chrome, FireFox, and Opera) are fully supported.

What are the most recent changes?


To see a list of all the most recent changes, click here.

How do I get started?


To get started using Syntax.js, do the following steps:

1. Prerequisites:


Make sure you include the "DOCTYPE html" tag at the top of your email, as follows:

  1. ```markdown
  2. DOCTYPE html>
  3. ```

2. Include Files:


  1. ```markdown
  2. <link rel="stylesheet" href="dist/syntax.js.css" />
  3. <script src="dist/syntax.js"></script>
  4. <script src="dist/languages/syntax.javascript.js"></script>
  5. ```

3. Create DOM Container:


  1. ```markdown
  2. <div data-syntax-language="javascript">
  3.     var something = true;

  4.     if ( something ) {
  5.         console.log( "Output is written." ); // Comment
  6.         
  7.         /* Multi-line
  8.         comment */
  9.     }
  10. </div>

  11. <code data-syntax-language="javascript" data-syntax-options="{ 'showCopyButton': false }">
  12.     <pre>
  13.         var something = true;

  14.         if ( something ) {
  15.             console.log( "Output is written." ); // Comment
  16.             
  17.             /* Multi-line
  18.             comment */
  19.         }
  20.     </pre>
  21. </code>
  22. ```

To see a list of all the available options you can use for "data-syntax-options".

To see a list of all the available custom triggers you can use for "data-syntax-options".

4. Finishing Up:


That's it! Nice and simple. Please refer to the code if you need more help (fully documented).

How do I go about customizing Syntax.js?


To customize, and get more out of Syntax.js, please read through the following documentation.

1. Public Functions:


To see a list of all the public functions available.