I am trying to write a ruby source code as a string (as part of real Ruby code) on a text editor with syntax highlighting for Ruby code, but want the Ruby syntax highlighting to work on the code inside the string. Using double or single quotes, percent notation, heredoc all make the text editor recognize that it is a string, so the whole chunk of code is colored in a single color as a string.
# blah blah
At least Atom, Sublime Text and RubyMine support syntax highlighting based on the heredoc identifier.
<<-RUBY is rendered as Ruby,
<<-SQL as SQL and so on.
Here's a screenshot from Atom: