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

refractor

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refractor

Lightweight, robust, elegant virtual syntax highlighting using Prism

  • 2.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
increased by2.59%
Maintainers
1
Weekly downloads
 
Created

What is refractor?

Refractor is a lightweight, robust, and extensible syntax highlighter that works in both Node.js and the browser. It is built on top of the Prism syntax highlighter and provides a way to highlight code syntax in various programming languages.

What are refractor's main functionalities?

Syntax Highlighting

This feature allows you to highlight code syntax for a given programming language. The example highlights a simple JavaScript code snippet.

const refractor = require('refractor');
const html = refractor.highlight('const x = 42;', 'javascript');
console.log(html);

Registering Languages

You can register additional languages for syntax highlighting. This example registers the Python language and highlights a Python code snippet.

const refractor = require('refractor');
const python = require('refractor/lang/python');
refractor.register(python);
const html = refractor.highlight('print("Hello, World!")', 'python');
console.log(html);

Syntax Highlighting with Plugins

Refractor supports plugins to extend its functionality. This example uses the line-numbers plugin to add line numbers to the highlighted code.

const refractor = require('refractor');
const lineNumbers = require('refractor/plugins/line-numbers');
refractor.use(lineNumbers);
const html = refractor.highlight('const x = 42;', 'javascript');
console.log(html);

Other packages similar to refractor

Keywords

FAQs

Package last updated on 31 Jul 2018

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