Atom Packages Directory

a package directory for a text editor of the 21st Century

Regex Comments

Install with:
    apm install regex-comments
  

Oniguruma Comment Highlighting

Adds comment-highlighting for Oniguruma-style regex comments.

coffeescript patterns: longHairyRegEx: """(?x) (?# Breath of fresh air) ~line noise~ """ The above snippet would be rendered like this:

Geared toward authors of TextMate-compatible grammars.

Targeting CoffeeScript only

By default, this package affects any language where the (?#…) sequence is used inside a string. If you’d like to restrict it to specific languages only, just use your stylesheet:

less .string:not(.coffee) .oniguruma.comment{ color: inherit; }

“Probable” comment-lines

More basic comments are supported, but only under very specific circumstances:

  1. The # token is preceded by a whitespace character
  2. No ] characters are allowed to appear after the #. This avoids colouring stuff like [ #?@]
  3. Your theme’s stylesheet adds comment colour to .comment-ish

While this sounds a little counter-intuitive, remember there’s a high risk of misclassification here. Furthermore, these comments will stop at any quote character, irrespective of whether it was used to start the containing comment block. So this wouldn’t match the entire comment: coffee """(?x) (?=something-complex) # Yes, "complex" indeed """

TIP: Use directional quotes instead. Insert them into a “probable” comment-line with the following snippets:

coffee """(?x) # “That’s a decent compromise, I guess.” """

Keywords: oniguruma, textmate, regex, regular expression, comment, highlighting, grammar, syntax, language Suggest keywords
Fork me on GitHub