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

markdown-it-shiki-twoslash

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-shiki-twoslash

A markdown-it plugin for Shiki with Twoslash code samples

  • 2.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

markdown-it-shiki-twoslash

Sets up markdown code blocks to run through shiki which means it gets the VS Code quality syntax highlighting mixed with the twoslash JavaScript tooling from the TypeScript website.

Plugin Setup

  1. Install the dependency: yarn add markdown-it-shiki-twoslash

  2. Include "markdown-it-shiki-twoslash" in the plugins section of the markdown-it parser:

    import shikiTwoslash from "markdown-it-shiki-twoslash"
    import MarkdownIt from "markdown-it"
    
    const md = MarkdownIt()
    md.use(shikiTwoslash, { theme: "nord" })
    
    const html = md.render(file)
    

    or even better:

    import { markdownItShikiTwoslashSetup } from "markdown-it-shiki-twoslash"
    import MarkdownIt from "markdown-it"
    
    const md = MarkdownIt()
    
    const shiki = await markdownItShikiTwoslashSetup({
      theme: "nord",
    })
    
    md.use(shiki)
    const html = md.render(file)
    

    Because shiki uses WASM to handle the syntax highlighting, it has to be async code, this clashes with the markdown-it API which enforces synchronous code. In the first code sample, the plugin uses deasync to convert that async work to sync. It's safe to say that you probably don't want deasync'd code in critical systems.

  3. Follow the steps in npmjs.com/package/remark-shiki-twoslash to add the CSS requirements.

  4. Follow the instructions on npmjs.com/package/remark-shiki-twoslash, this module leaves all the heavy lifting to that module.

FAQs

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