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

@expressive-code/core

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressive-code/core

A text marking & annotation engine for presenting source code on the web.

  • 0.32.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55K
increased by13.56%
Maintainers
1
Weekly downloads
 
Created
Source

@expressive-code/core

The core package of Expressive Code, an engine for presenting source code on the web.

Documentation

Read the Expressive Code docs to learn more about the features provided by Expressive Code.

When should I use this?

Using this core package directly is only recommended for advanced use cases.

Unless you're a plugin or integration author, you should probably use a higher-level package like astro-expressive-code or remark-expressive-code instead of this one.

Installation

npm install @expressive-code/core

Usage example

import { ExpressiveCodeEngine } from '@expressive-code/core'
import { toHtml } from 'hast-util-to-html'

const ec = new ExpressiveCodeEngine({
  plugins: [
    // Add your plugins here
  ],
})

const baseStyles = await ec.getBaseStyles()
const themeStyles = await ec.getThemeStyles()

const renderResult = await ec.render({
  code: 'console.log("Hello world!")',
  language: 'js',
})

// Output results to the console
console.dir({
  baseStyles,
  themeStyles,
  blockStyles: renderResult.styles,
  blockHtml: toHtml(renderResult.renderedGroupAst),
})

FAQs

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