Class: Insta::SyntaxHighlight

Inherits:
Object
  • Object
show all
Defined in:
lib/insta/syntax_highlight.rb,
sig/insta/syntax_highlight.rbs

Class Method Summary collapse

Class Method Details

.highlight(code, colorable: true) ⇒ String

: (String, ?colorable: bool) -> String

Parameters:

  • (String)
  • colorable: (Boolean) (defaults to: true)

Returns:

  • (String)


12
13
14
15
16
17
18
# File 'lib/insta/syntax_highlight.rb', line 12

def self.highlight(code, colorable: true)
  return code unless colorable && defined?(IRB::Color)

  IRB::Color.colorize_code(code, complete: false, colorable: true)
rescue StandardError
  code
end