Skip to content

williamtroup/Syntax.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

37a1e53 Β· Dec 5, 2023
Oct 28, 2023
Dec 5, 2023
Dec 5, 2023
Dec 5, 2023
Dec 4, 2023
Nov 28, 2023
Oct 28, 2023
Oct 28, 2023
Oct 28, 2023
Dec 4, 2023
Dec 4, 2023
Oct 28, 2023
Oct 28, 2023
Dec 4, 2023
Dec 4, 2023

Repository files navigation

Syntax.js

Tweet npm nuget license discussions Welcome coded by William Troup

A lightweight, and easy-to-use, JavaScript library for code syntax highlighting!

v1.3.0


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).
  • 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).


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:

<!DOCTYPE html>

2. Include Files:

<link rel="stylesheet" href="dist/syntax.js.css" />
<script src="dist/syntax.js"></script>
<script src="dist/languages/syntax.javascript.js"></script>

3. Create DOM Container:

<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.


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, click here.