Crystal::SyntaxHighlighter::Colorize
Inherits Crystal::SyntaxHighlighter / Reference / Object
A syntax highlighter that renders Crystal source code with ANSI escape codes suitable for terminal highlighting.
NOTE: To use Crystal::SyntaxHighlighter::Colorize, you must explicitly import it with require "crystal/syntax_highlighter/colorize"
require "crystal/syntax_highlighter/colorize"
code = %(foo = bar("baz\#{PI + 1}") # comment)
colorized = Crystal::SyntaxHighlighter::Colorize.highlight(code)
colorized # => "foo \e[91m=\e[0m bar(\e[93m\"baz\#{\e[0;36mPI\e[0;93m \e[0;91m+\e[0;93m \e[0;35m1\e[0;93m}\"\e[0m) \e[90m# comment\e[0m"
Constructors
Creates a new instance of a Colorize syntax highlighter.
Appends highlighted output (when calling #highlight) to io.
Class methods
Instance methods
colors
Source