Simlpe Syntax Highlighter Using Unicode – Unilight

Category: Javascript , Recommended | November 10, 2022
Views Total:73 views
Official Page:Go to website
Last Update:November 10, 2022


Simlpe Syntax Highlighter Using Unicode – Unilight


Unilight is a simple syntax highlighter that uses only Unicode variations to highlight code blocks on the page.

It makes the code look good and easy to read without 3rd-party syntax highlighting libraries, while still making the syntax understandable.

How to use it:

1. Install and import the Unilight.

$ npm i unilight
// CommonJS
const { highlight } = require('unilight');
// Browser
<script src="./dist/index.js"></script>

2. Initialize the Unilight on your code block and define an array of keywords which should be highlighted as follows:

const code = `
 // your code here
const output = highlight(code, [
  // ...

You Might Be Interested In:

Leave a Reply