compromise-highlight

0.0.1 • Public • Published
compromise-highlight

work in progress

this is an attempt to get custom syntax-highlighting for grammatical templates, using compromise and codemirror.

npm i compromise-highlight codemirror

Setup

this function accepts a codemirror editor object, that you've already setup. read the codemirror docs on how to do this.

briefly:

<html>
  <head>
    <link rel="stylesheet" href="./path/to/codemirror.css" />
    <style>
      .person {
        color: steelblue;
      }
    </style> 
  </head>
  <body>
    <textarea id="text"></textarea>
  </body>
  <script src="./setup.js"></script> 
</html>

then in setup.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

Readme

Keywords

none

Package Sidebar

Install

npm i compromise-highlight

Weekly Downloads

3

Version

0.0.1

License

none

Unpacked Size

2.8 MB

Total Files

15

Last publish

Collaborators

  • spencermountain