Highlight any ruby as ruby inside #{} interpolations. Also show example in test.rb

#79 Declined
Repository
erikformella
Branch
default
Repository
birkenfeld
Branch
default
Author
  1. Erik Formella
Reviewers
Description

Very few code highlighters get this correct, but in Ruby you can put any valid ruby code in #{} string interpolations. Even more strings with #{} interpolations!

With my changes, the #{ and } are colored the same as strings and their contents are highlighted as normal ruby. I guess a better way for this to work would be to have the #{ and } highlighted uniquely, I just do not know how to do it.

I added two (poorly formatted) lines to tests/examplefiles/test.rb to show what is happening.

Where I first saw this in the wild (other than my text editor): https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#transient-attributes

Comments (2)

  1. Georg Brandl repo owner

    Hmm, this patch only highlights the interpolation borders differently.

    The #{ } contents should already be highlighted as Ruby, this patch doesn't change it.