šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@shikijs/engine-javascript

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shikijs/engine-javascript

Engine for Shiki using JavaScript's native RegExp

3.4.2
latest
Source
npm
Version published
Weekly downloads
1.6M
2.06%
Maintainers
3
Weekly downloads
Ā 
Created

What is @shikijs/engine-javascript?

@shikijs/engine-javascript is a syntax highlighting engine specifically designed for JavaScript. It is part of the Shiki library, which is a beautiful syntax highlighter. This package allows you to highlight JavaScript code with ease, providing a visually appealing and readable format.

What are @shikijs/engine-javascript's main functionalities?

Basic Syntax Highlighting

This feature allows you to highlight JavaScript code using a specified theme. In this example, the 'nord' theme is used to highlight a simple JavaScript code snippet.

const shiki = require('shiki');

shiki.getHighlighter({ theme: 'nord' }).then(highlighter => {
  const code = `const x = 10;`;
  console.log(highlighter.codeToHtml(code, { lang: 'js' }));
});

Custom Themes

This feature allows you to load and use custom themes for syntax highlighting. The example demonstrates how to load a custom theme from a JSON file and use it to highlight JavaScript code.

const shiki = require('shiki');

shiki.loadTheme('./path/to/custom-theme.json').then(theme => {
  return shiki.getHighlighter({ theme });
}).then(highlighter => {
  const code = `const y = 20;`;
  console.log(highlighter.codeToHtml(code, { lang: 'js' }));
});

Highlighting with Line Numbers

This feature allows you to include line numbers in the highlighted code output. The example shows how to highlight a JavaScript function with line numbers using the 'nord' theme.

const shiki = require('shiki');

shiki.getHighlighter({ theme: 'nord' }).then(highlighter => {
  const code = `function add(a, b) {
  return a + b;
}`;
  console.log(highlighter.codeToHtml(code, { lang: 'js', lineNumbers: true }));
});

Other packages similar to @shikijs/engine-javascript

Keywords

shiki

FAQs

Package last updated on 16 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts