
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
codemirror-atom-modes
Advanced tools
Use Atom grammar files to apply syntax highlighting in a CodeMirror editor
Syntax highlighting in CodeMirror using Atom grammar files
This module allows any Atom grammar file to be used for syntax highlighting in a CodeMirror editor, a popular text editor that works in the browser. This module works by adapting first-mate, the source code tokenizing library used by Atom, to work with CodeMirror as a custom CodeMirror mode.
Disclaimer: In the browser, the first-mate module will use onigurumajs, a JavaScript implementation of the oniguruma Regular Expression library. The oniguruma library used by Atom has bindings to native C++ binaries that won't work in the browser (which may not be the case with WebAssembly in the future). onigurumajs depends on XRegExp and may not be perfect substitution in all situations. As a result, there may be edge cases that prevent this module from working correctly for all Atom grammars. If you find any issues, please open a Github issue.
Atom, Sublime Text, WebStorm and TextMate all support the TextMate approach to defining language grammars. CodeMirror and highlight.js, however, adopted their own unique approach to doing syntax highlighting. As a language author, it requires a lot of work to also support proper syntax highlighting and this is not work that you would want to repeat for every editor and syntax highlighting library. After creating a TextMate grammar file for the Marko templating language I did not want to have to create a new grammar file for CodeMirror. After looking at the CodeMirror API I found that CodeMirror works by tokenizing each line at a time. Fortunately, this was very similar to the approach used by first-mate (the tokenizer used by Atom). With a few tricks I was able to get the two to play nicely together.
This project is being successfully used on markojs.com (see: Try Marko Online!). On markojs.com we are using the Atom: language-marko grammar file to apply syntax highlighting in a CodeMirror editor.
The following code illustrates how to register multiple Atom grammar files for use with CodeMirror:
var CodeMirror = require('codemirror');
require('codemirror-atom-modes').registerGrammars([
require('./atom-grammars/css.cson'),
require('./atom-grammars/javascript.cson'),
{
grammar: require('./atom-grammars/marko.cson'),
options: {
scopeTranslations: {
'meta.section.marko-placeholder': 'strong',
'meta.section.marko-attribute': 'strong',
'support.function.marko-tag': 'strong tag',
'support.function.marko-attribute': 'strong attribute'
}
}
}
], CodeMirror);
CodeMirror module (optional, defaults to window.CodeMirror)The grammar argument should be an Atom grammar object (not a string). Typically, Atom grammar files are stored on disk as a CSON file (CoffeeScript Object Notation). For example: github.com/marko-js/atom-language-marko/grammars/marko.cson
You will need to pass the parsed grammar file as the first argument.
Supported options:
The grammars argument should be an array where each element is one of the following:
{ grammar: <grammar_object>, options: <options> } objectThe CodeMirror argument is optional and defaults to window.CodeMirror. See registerGrammar(grammar, options, CodeMirror) for more details.
Pull Requests welcome.
Please submit Github issues for any feature enhancements, bugs or documentation problems.
ISC
FAQs
Use Atom grammar files to apply syntax highlighting in a CodeMirror editor
The npm package codemirror-atom-modes receives a total of 4 weekly downloads. As such, codemirror-atom-modes popularity was classified as not popular.
We found that codemirror-atom-modes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.