Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

syntastica

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syntastica

Modern and easy syntax highlighting using tree-sitter

latest
Source
npmnpm
Version
0.3.6
Version published
Maintainers
1
Created
Source

syntastica-js

Modern and easy syntax highlighting using tree-sitter; use syntastica from JavaScript/TypeScript.

The full JavaScript/TypeScript API docs can be found here.

Basic Usage

import syntastica from 'syntastica'

// load some languages
await syntastica.init(['rust', 'javascript'])

// highlight a piece of code once
const rustInput = `fn main() {\n    println!("Hello, World!");\n}`
const rustOutput = syntastica.highlight(rustInput, 'rust', 'one::dark')
document.getElementById('rust-code').innerHTML = rustOutput

// highlight a piece of code multiple times
const jsInput = `console.log('Hello, World!')`
syntastica.process(jsInput, 'javascript')

// - first to HTML again
const jsOutput1 = syntastica.render('gruvbox::dark')
document.getElementById('js-code').innerHTML = jsOutput1

// - then for terminals (e.g. for usage in nodejs CLIs)
const jsOutput2 = syntastica.render('one::deep', 'terminal')
console.log(jsOutput2)

Keywords

tree-sitter

FAQs

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