patrick-steele-idem / codemirror-atom-modes

Use Atom grammar files to apply syntax highlighting in a CodeMirror editor
16 stars 3 forks source link

fountain grammar doesn't seem to work #1

Open toddself opened 7 years ago

toddself commented 7 years ago

HI!

We're trying to use the atom fountain grammar, but all the text seems to be receiving the same CSS class attribute regardless. (cm-source-fountain and cm-meta).

atom screenshot: image

CodeMirror screenshot: image

Would love to help figure out what is going on here -- tried changing the name attributes in the grammar file to see if it just a matter of matching the names correctly against the list of tokens in codemirror, but that doesn't seem to change.

If I remove the section that defines meta in the grammar it does make a difference -- nothing gets the cm-meta class, but they still don't receive the proper classes based on their tokens.

I know fountain requires some lookahead functionality, so perhaps this is due to the regex engine for the browser?

toddself commented 7 years ago

Here is a gist of our grammar file (converted to JSON with season)

And this is how we're loading it:

const codemirror = require('codemirror')
const atomGrammer = require('codemirror-atom-modes')

const fountain = require('./fountain-grammar.json')
atomGrammer.registerGrammars([fountain], codemirror)
codemirror('#editor', {mode: 'Fountain'})