Extract CodeMirror language package
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# decodal-codemirror
|
||||
|
||||
CodeMirror 6 language support for Decodal.
|
||||
|
||||
This package provides the Lezer parser metadata, highlighting tags, indentation rules, and block folding used by the Decodal Web playground.
|
||||
It does not include the Decodal runtime or WebAssembly evaluator.
|
||||
Use `decodal-wasm` when you want to evaluate Decodal in a browser.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install decodal-codemirror
|
||||
```
|
||||
|
||||
JSR:
|
||||
|
||||
```sh
|
||||
deno add jsr:@hare/decodal-codemirror
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { basicSetup } from 'codemirror';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
import { decodal } from 'decodal-codemirror';
|
||||
|
||||
new EditorView({
|
||||
doc: 'Server = { port = Int default 8080; };',
|
||||
extensions: [
|
||||
basicSetup,
|
||||
decodal(),
|
||||
],
|
||||
parent: document.querySelector('#editor'),
|
||||
});
|
||||
```
|
||||
|
||||
## Exports
|
||||
|
||||
```js
|
||||
import {
|
||||
decodal,
|
||||
decodalLanguage,
|
||||
decodalHighlightStyle,
|
||||
} from 'decodal-codemirror';
|
||||
```
|
||||
|
||||
`decodal()` accepts a small options object:
|
||||
|
||||
```js
|
||||
decodal({ highlight: false })
|
||||
```
|
||||
|
||||
Use this when you want the language support without the bundled highlight style.
|
||||
Reference in New Issue
Block a user