0.3.6 • Published 2 years ago

syntastica v0.3.6

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
2 years ago

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)
0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago