module Haml::Filters::CodeRay
CodeRay filter for Haml. Specify which language to highlight with a shebang followed by the language name.
@example Ruby
:coderay #!ruby if true puts "hello" end
@see Haml::Filters::CodeRay_raw @see rubydoc.info/gems/haml/Haml/Filters @see rubydoc.info/gems/coderay/CodeRay/Scanners
Constants
- ENCODER
- ENCODER_OPTIONS
- VERSION
Attributes
encoder[RW]
Encoder (default: {ENCODER}).
encoder_options[RW]
Encoder options (default: {ENCODER_OPTIONS}).
Public Instance Methods
prepare(text)
click to toggle source
Prepares the text for passing to `::CodeRay.scan`.
@param [String] text @return [Array<String, Symbol>] code and language
# File lib/haml-coderay.rb, line 42 def prepare(text) [ text.sub(/\A\s*#!(\S+)\s*\n+/, ""), $1.downcase.to_sym ] end
render(text)
click to toggle source
@param [String] text text to render @return [String] rendered text
@see rubydoc.info/gems/coderay/CodeRay.scan
# File lib/haml-coderay.rb, line 50 def render(text) ::CodeRay.scan(*prepare(text)).send(encoder, encoder_options) end