A lightweight, and easy-to-use, JavaScript library for code syntax highlighting!
v1.3.0
- 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).
- Coping and Printing support is available via action buttons.
- 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).
All modern browsers (such as Google Chrome, FireFox, and Opera) are fully supported.
To see a list of all the most recent changes, click here.
To get started using Syntax.js, do the following steps:
Make sure you include the "DOCTYPE html" tag at the top of your email, as follows:
<!DOCTYPE html>
<link rel="stylesheet" href="dist/syntax.js.css" />
<script src="dist/syntax.js"></script>
<script src="dist/languages/syntax.javascript.js"></script>
<div data-syntax-language="javascript">
var something = true;
if ( something ) {
console.log( "Output is written." ); // Comment
/* Multi-line
comment */
}
</div>
<code data-syntax-language="javascript" data-syntax-options="{ 'showCopyButton': false }">
<pre>
var something = true;
if ( something ) {
console.log( "Output is written." ); // Comment
/* Multi-line
comment */
}
</pre>
</code>
To see a list of all the available options you can use for "data-syntax-options", click here.
To see a list of all the available custom triggers you can use for "data-syntax-options", click here.
That's it! Nice and simple. Please refer to the code if you need more help (fully documented).
To customize, and get more out of Syntax.js, please read through the following documentation.
To see a list of all the public functions available, click here.