Sublime Forum

Ruby #{} highlighting

#1

I’m a fairly newcomer to SublimeText2 and I’ve searched high and low for this answer and couldn’t find a concrete solution. I prefer SublimeText2 over TextMate and would like to include #{} syntax highlighting for Ruby.

Any help appreciated!!

0 Likes

#2

[pre=#0C1021]
name
Embedded Ruby Punctuation
scope
string punctuation.section.embedded.ruby
settings

foreground
#F92672

[/pre]
You could add a section like the above to the Packages/Color Scheme - Default/Monokai.tmTheme file, adjusting color to taste.

[pre=#272822]“Then the punctuation should be highlighted #{ 2 + 2 }”[/pre]

[pre=#272822]“And without any #{ 2 + 2 }”[/pre]

0 Likes

#3

@castles, how long did it take you to add all that highlighting? Be honest :smile:

0 Likes

#4

[pre=#0C1021]settings = sublime.load_settings(‘html-export.sublime-settings’)

defaults = {
“open_html_in_editor” : False,
“open_html_in_browser” : True,
“copy_css_to_clipboard” : False,
“copy_html_to_clipboard” : True,
“encode_as” : “utf-8”,
“add_line_numbers” : False,
“root_node” : “pre”,
‘use_style’ : True,
‘bulletin_board’ : True,
}
[/pre]

[pre=#0C1021]def memoize(func):
“Implementation taken from python test suite”
saved = {}
def call(*args):
try:
return saved[args]
except KeyError:
res = func(*args)
saved[args] = res
return res
except TypeError:
# Unhashable argument
return func(*args)
call.func_name = func.func_name
return call[/pre]

A few milliseconds, it uses memoization.

0 Likes

#5

Oh, and stop giving me shit and apply for the Google Summer of Code already you young upstart.

0 Likes

#6

hahahahaha :smile: alright already…

0 Likes