# Macaulay2 Language for CodeMirror

[![npm version](https://badge.fury.io/js/codemirror-lang-macaulay2.svg)](https://badge.fury.io/js/codemirror-lang-macaulay2)
[![tests](https://github.com/d-torrance/codemirror-lang-macaulay2/actions/workflows/test.yml/badge.svg)](https://github.com/d-torrance/codemirror-lang-macaulay2/actions/workflows/test.yml)

This package provides [Macaulay2](https://macaulay2.com) language support for
[CodeMirror](https://codemirror.net/).

## Installation

```bash
npm install codemirror-lang-macaulay2
```

## Usage

### CodeMirror 6

```js
import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { basicSetup } from "codemirror";
import { macaulay2 } from "codemirror-lang-macaulay2";

new EditorView({
  state: EditorState.create({
    doc: "R = QQ[x,y,z,w]\nI = monomialCurveIdeal(R, {1,2,3})",
    extensions: [basicSetup, macaulay2()],
  }),
  parent: document.getElementById("editor"),
});
```

### CodeMirror 5 (legacy)

Import the legacy subpath to automatically register the `macaulay2` mode with
CodeMirror.

```js
import CodeMirror from "codemirror";
import "codemirror/addon/mode/simple";
import "codemirror-lang-macaulay2/legacy";

const editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
  mode: "macaulay2",
});
```
