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

codemirror-textmate

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codemirror-textmate

Textmate based tokenization for CodeMirror

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-53.06%
Maintainers
1
Weekly downloads
 
Created
Source

Textmate grammars support for CodeMirror

Bring TM grammar driven tokenization to your CodeMirror editors.

Say goodbye to the not-so-cool and not-so-accurate syntax highlighting you've been living with and up your game with ease!

WARNING

This package will only work in browsers with WebAssembly support. Here's a recommended way to deal with it:

// 95% of your target audience (developers)
if ('WebAssembly' in window) {
    const [{
            loadWASM
        },
        {
            activateLanguage,
            addGrammar
        }
    ] = await Promise.all([
        import('onigasm'),
        import('codemirror-textmate'),
    ])

    // ... (see https://www.npmjs.com/package/onigasm#light-it-up)
    // ... (see example code below)
}
// Fallback for rest 5%
else {
    await Promise.all([
        import('codemirror/mode/javascript/javascript'),
        import( 'codemirror/mode/htmlmixed/htmlmixed'),
    ])
}

const editor = CodeMirror.fromTextArea( /* ... */ )
// ... (go on as usual)

Usage

Install

$ npm i codemirror-textmate

# Install peer dependencies if you haven't already
npm i onigasm codemirror 

See ./demo/index.ts for instructions on how to light it up!

API

This package is written in TypeScript and is published with TS declaration files. Once you install the package see node_modules/codemirror-textmate/dist/typings/index.d.ts for available stuff along with expected data types.

VSCode's intellisense will also pick up the declaration files and guide you nicely with auto-complete and errors.

License

MIT

Keywords

FAQs

Package last updated on 13 Sep 2021

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