@expressive-code/core
TypeScript icon, indicating that this package has built-in type declarations

0.38.3 • Public • Published

@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 rehype-expressive-code instead of this one.

Installation

npm install @expressive-code/core

Usage example

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

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),
})

Readme

Keywords

none

Package Sidebar

Install

npm i @expressive-code/core

Weekly Downloads

35,216

Version

0.38.3

License

MIT

Unpacked Size

624 kB

Total Files

9

Last publish

Collaborators

  • hippotastic