Simlpe Syntax Highlighter Using Unicode – Unilight

Category: Javascript , Recommended | November 10, 2022
Author:felippe-regazio
Views Total:45 views
Official Page:Go to website
Last Update:November 10, 2022
License:MIT

Preview:

Simlpe Syntax Highlighter Using Unicode – Unilight

Description:

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
$ 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, [
  'await',
  'break',
  'case',
  'catch',
  // ...
]);

You Might Be Interested In:


Leave a Reply