Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shikijs/engine-javascript

Package Overview
Dependencies
Maintainers
3
Versions
14
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

  • 1.22.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
667K
increased by10.05%
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

FAQs

Package last updated on 28 Oct 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc