Tiny JavaScript Syntax Highlighter

Category: Javascript | June 15, 2020
Author: i8sumPi
Views Total: 489 views
Official Page: Go to website
Last Update: June 15, 2020
License: MIT

Preview:

Tiny JavaScript Syntax Highlighter

Description:

A tiny and easy-to-use syntax highlighter created only for JavaScript code.

How to use it:

1. Download the package and import the index.js into the HTML.

<script src="script.js"></script>

2. Wrap JavaScript snippets into code tag and done.

<code>
  // CSSScript.com
  function highlightAll(){
  var allCodes = document.getElementsByTagName("code");
  for (var i = 0; i < allCodes.length; i++) {
    allCodes[i].className = "code";
    allCodes[i].innerHTML = highlight(allCodes[i].innerHTML);
  }
</code>

You Might Be Interested In:


Leave a Reply