New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@justinribeiro/code-block

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@justinribeiro/code-block

A web component that utilizes Prism.js and Lit to display nicely formatted code.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-38.89%
Maintainers
1
Weekly downloads
 
Created
Source

npm version

<code-block>

A web component that displays colorfully formatted code with Prism.js and Lit.

screenshot of code-block

Features

  • Loads Prism.js language definitions on demand via dynamic imports from node_modules/prismjs/components/
  • Loads Prism.js custom themes
  • Built as a web component on Lit

Install

This web component is built with ES modules in mind and is available on NPM:

Install code-block:

npm i @justinribeiro/code-block
# or
yarn add @justinribeiro/code-block

After install, import into your project:

import '@justinribeiro/code-block';

Finally, use as required:

<code-block language="javascript">
function helloWorld(say) {
  console.log(say);
}

helloWorld('Hi there!');
</code-block>

Attributes

The web component allows certain attributes to be give a little additional flexibility.

NameDescriptionDefault
languageCode language you wish to utilize from Prismclike
themePath to Prism CSS theme file/node_modules/prismjs/themes/prism.css

Building

If you want the ability to load the full spectrum of languages that Prism supports, you'll want to make sure your build script includes the /node_modules/prismjs/**, as there are many many language resources (and you don't want them all in your bundle, utilize the dynamic loading).

Keywords

FAQs

Package last updated on 04 Jan 2023

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