An open API service indexing awesome lists of open source software.

https://github.com/spencermountain/compromise-highlight

syntax-highlighting for natural language text
https://github.com/spencermountain/compromise-highlight

Last synced: about 1 month ago
JSON representation

syntax-highlighting for natural language text

Awesome Lists containing this project

README

        


compromise-highlight


demo







**work in progress**

this is an attempt to get custom syntax-highlighting for grammatical templates, using [compromise](https://github.com/spencermountain/compromise/) and [codemirror](https://codemirror.net).

`npm i compromise-highlight codemirror`

### Setup

this function accepts a codemirror editor object, that you've already setup.
read the [codemirror docs](https://codemirror.net/) on how to do this.

briefly:

```html




.person {
color: steelblue;
}





```

then in `setup.js`:

```js
const CodeMirror = require('codemirror')
const highlight = require('compromise-highlight')

//setup codemirror instance
let editor = CodeMirror.fromTextArea(document.getElementById('text'))

//pass it over, with your patterns
highlight(editor, { '#Person+': 'person' })

//run highlighting on init
CodeMirror.signal(editor, 'change', editor)
```

MIT