` to include syntax-highlighted code blocks. Example:
class Foo
def bar
"abcde"
end
end
This uses the Ruby [Syntax](http://syntax.rubyforge.org/) module. Options:
* **lang**. Sets the programming language. Currently supported languages are
`ruby`, `yaml`, and `xml`. Other languages will format correctly but will not
have syntax highlighting.
* **linenumber**. Turns on line numbering. Use `linenumber="true"` to enable.
* **title**. Adds a title block to the top of the code block.
* **class**. Adds a new CSS class to the wrapper around the code block.
}
end
def self.macrofilter(blog,content,attrib,params,text="")
lang = attrib['lang'] || 'default'
title = attrib['title']
cssclass = attrib['class']
linenumber = attrib['linenumber']
text = text.to_s.gsub(/\r/,'').gsub(/\A\n/,'').chomp
convertor = Syntax::Convertors::HTML.for_syntax lang
text = convertor.convert(text)
text.gsub!(//,"")
text.gsub!(/<\/pre>/,"
")
if(linenumber)
lines = text.split(/\n/).size
linenumbers = (1..lines).to_a.collect{|line| line.to_s}.join("\n")
text = "
\n\n#{linenumbers}\n \n | #{text} |
"
end
if(title)
titlecode="#{title}
"
else
titlecode=''
end
"#{titlecode}#{text}
"
end
end
end
end