0.0.1 • Published 4 years ago

compromise-highlight v0.0.1

Weekly downloads
3
License
-
Repository
-
Last release
4 years ago

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