Class: Rote::Filters::Syntax

Inherits:
MacroFilter show all
Defined in:
lib/rote/filters/syntax.rb

Overview

Page filter that supports syntax highlighting for Ruby code via the Syntax library. Code is expected to be in the following format:

#:code#ruby#
  def amethod(arg)
    puts arg
  end
#:code#

Instance Attribute Summary

Attributes inherited from MacroFilter

#handler_blk, #names

Instance Method Summary collapse

Methods inherited from MacroFilter

#filter, #handler

Constructor Details

#initialize(macro_re = MACRO_RE) ⇒ Syntax

Returns a new instance of Syntax.



28
29
30
# File 'lib/rote/filters/syntax.rb', line 28

def initialize(macro_re = MACRO_RE)
  super([],macro_re)
end

Instance Method Details

#macro_code(lang, body, raw) ⇒ Object



32
33
34
35
# File 'lib/rote/filters/syntax.rb', line 32

def macro_code(lang,body,raw)
  converter = ::Syntax::Convertors::HTML.for_syntax(lang)
  "<pre class='#{lang}'><code>#{converter.convert(body,false)}</code></pre>"
end