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

rehype-prism-plus

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-prism-plus

rehype plugin to highlight code blocks in HTML with Prism (via refractor) with line highlighting and line numbers

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
162K
increased by6.94%
Maintainers
1
Weekly downloads
 
Created

What is rehype-prism-plus?

rehype-prism-plus is a plugin for the rehype ecosystem that integrates Prism.js for syntax highlighting in HTML. It allows you to easily add syntax highlighting to your HTML content using Prism.js, which supports a wide range of programming languages and themes.

What are rehype-prism-plus's main functionalities?

Syntax Highlighting

This feature allows you to add syntax highlighting to your HTML content. The code sample demonstrates how to use rehype-prism-plus to highlight JavaScript code within a <pre><code> block.

const rehype = require('rehype');
const rehypePrism = require('rehype-prism-plus');

rehype()
  .use(rehypePrism)
  .process('<pre><code class="language-js">const x = 42;</code></pre>')
  .then((file) => {
    console.log(String(file));
  });

Custom Themes

This feature allows you to use custom themes for syntax highlighting. The code sample demonstrates how to apply the 'twilight' theme to the highlighted code.

const rehype = require('rehype');
const rehypePrism = require('rehype-prism-plus');

rehype()
  .use(rehypePrism, { theme: 'twilight' })
  .process('<pre><code class="language-js">const x = 42;</code></pre>')
  .then((file) => {
    console.log(String(file));
  });

Line Numbers

This feature allows you to display line numbers alongside the highlighted code. The code sample demonstrates how to enable line numbers for the highlighted JavaScript code.

const rehype = require('rehype');
const rehypePrism = require('rehype-prism-plus');

rehype()
  .use(rehypePrism, { showLineNumbers: true })
  .process('<pre><code class="language-js">const x = 42;</code></pre>')
  .then((file) => {
    console.log(String(file));
  });

Other packages similar to rehype-prism-plus

Keywords

FAQs

Package last updated on 08 Jan 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