You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

markdown-it-async

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-async

_description_

0.1.3
Source
npmnpm
Version published
Weekly downloads
9K
-24.47%
Maintainers
1
Weekly downloads
 
Created
Source

markdown-it-async

npm version npm downloads bundle JSDocs License

Enhance markdown-it to support async highlight function.

Usage

import MarkdownItAsync from 'markdown-it-async'

const md = MarkdownItAsync({
  async highlight(code, lang) {
    const { codeToHtml } = await import('shiki')
    return await codeToHtml(code, { lang, theme: 'vitesse-dark' })
  }
})

const html = await md.renderAsync(markdown)

How it works?

This package is a thin wrapper around markdown-it to support async highlight function. It uses the approch suggested in markdown-it's docs, by putting placeholders in sync mode and then replace them with async results.

The goal is to make it easy to use and absorb the "hack" into the library itself.

Sponsors

License

MIT License © 2024-PRESENT Anthony Fu

FAQs

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