Debian Codegraph @

codemirror-legacy-modes/mode/README.md

raw
1 <!-- NOTE: README.md is generated from mode/README.md -->
2
3 # @codemirror/legacy-modes [![NPM version](https://img.shields.io/npm/v/@codemirror/legacy-modes.svg)](https://www.npmjs.org/package/@codemirror/legacy-modes)
4
5 [ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/legacy-modes/blob/main/CHANGELOG.md) ]
6
7 This package implements a collection of ported [stream
8 language](https://codemirror.net/docs/ref#language.StreamParser) modes for
9 the [CodeMirror](https://codemirror.net/) code editor. Each mode is
10 available as a separate script file, under
11 `"@codemirror/legacy-modes/mode/[name]"`, and exports the values
12 listed below.
13
14 The [project page](https://codemirror.net/) has more information, a
15 number of [examples](https://codemirror.net/examples/) and the
16 [documentation](https://codemirror.net/docs/).
17
18 This code is released under an
19 [MIT license](https://github.com/codemirror/legacy-modes/tree/main/LICENSE).
20
21 We aim to be an inclusive, welcoming community. To make that explicit,
22 we have a [code of
23 conduct](http://contributor-covenant.org/version/1/1/0/) that applies
24 to communication around the project.
25
26 ## Usage
27
28 Using modes from this package works like this:
29
30 - Install this package and the
31 [`@codemirror/language`](https://codemirror.net/docs/ref/#language)
32 package.
33
34 - Find the `StreamParser` instance you need in the reference below.
35
36 - Add `StreamLanguage.define(theParser)` to your editor's
37 configuration.
38
39 For example, to load the Lua mode, you'd do something like...
40
41 ```javascript
42 import {StreamLanguage} from "@codemirror/language"
43 import {lua} from "@codemirror/legacy-modes/mode/lua"
44
45 import {EditorView, basicSetup} from "codemirror"
46
47 let view = new EditorView({
48 extensions: [basicSetup, StreamLanguage.define(lua)]
49 })
50 ```
51
52 ## API Reference