Grammar regex for brackets doesn't work?


I am working on a grammar language package for Denizen.

I got most of it working without any issues. However, for some reason I cannot seem to get a regex working for square brackets [ ]

I’ve tried a ton of different solutions. But it refuses to color those in my styling.

In the meantime I am having no issues styling my tags < >

Is there something special about brackets in the .cson grammar files?

And yes, I have double checked that the class names match up. I also tried changing it to some jibberish in case it was another package overriding it. And I tried marking it as !important. But nothing seems to let me color my brackets.


It would be easier to help if we could see the code.


I have tried a ton of different options which should work. And seems to work perfectly fine if I replace ‘[]’ with ‘<>’ So I didn’t think it was the code.

But here’s the last attempt I made from tonight:

in denizen.cson (grammar)
‘begin’: ‘\[’ #there are 2 \ here, it just gets escaped by the text editor
’end’: ‘\]’ #there are 2 \ here, it just gets escaped by the text editor
’name’: ‘brackets.denizen’

in denizen.less (styles)

.brackets {
color: hsl( 29, 54%, 61%);


You should wrap your code in backticks (you can highlight your code and click the </> symbol in the editor to spawn the markdown necessary; this is context-sensitive, so it will create a block or inline tags based on your selection). Github has a great reference for this (as does the developer, but the code used here has some of the GFM additions, like code fencing, which is frankly a lot less work than indenting every line).

It would also be much easier to help you if you shared the whole package. If you posted a link to a github repo, I could clone it, apm link to drop a symlink into my .atom/packages directory, reload a currently open Atom window, and be testing your grammar in less time than it takes to type this paragraph. With just two rules, I have no ability to observe the whole functioning of the package. I have to trust that you copied it correctly, and it’s not even preformatted. In order to figure out a solution, I would have to create a package and set it up as if I’m making a new language, or go and edit an existing language.

I went and tested it anyway, and I can’t find the solution to your problem because I haven’t been able to replicate it. I did find an error in my notes (regarding beginCaptures and endCaptures) and have fixed that.


  begin: '\\['
  end: '\\]'
  name: 'code-string.mux'

successfully matches this

[ Should be code ]

and this

  begin: '\\['
  end: '\\]'
  contentName: 'code-string.mux'
  name: 'matched'
      name: 'open.code-bracket.mux'
      name: 'close.code-bracket.mux'

results in

<span class="source mux">
  <span class="matched">
    <span class="open code-bracket mux">[</span>
    <span class="code-string mux"> Should be code </span>
    <span class="close code-bracket mux">]</span>