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
- Host: GitHub
- URL: https://github.com/spencermountain/compromise-highlight
- Owner: spencermountain
- Created: 2020-01-13T21:45:14.000Z (over 5 years ago)
- Default Branch: gh-pages
- Last Pushed: 2023-01-06T02:26:01.000Z (over 2 years ago)
- Last Synced: 2025-03-18T11:11:47.843Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://spencermounta.in/compromise-highlight/
- Size: 1.76 MB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**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