class Documentation::MarkdownRenderer

Attributes

page[RW]

Public Instance Methods

block_code(code, language) click to toggle source
# File lib/documentation/markdown_renderer.rb, line 11
def block_code(code, language)
  title = nil
  code.gsub!(/\A\:\:(.*)$/) { title = $1 ; nil }
  String.new.tap do |s|
    s << "<p class='codeTitle'>#{title}</p>" if title
    s << Pygments.highlight(code, :lexer => language)
  end
rescue 
  "<div class='highlight'><pre>#{code}</pre></div>"
end
image(src, title, alt) click to toggle source
# File lib/documentation/markdown_renderer.rb, line 42
def image(src, title, alt)
  if alt.gsub!(/\*([\w\-\s]+)\z/, '')
    klass = "imgcontainer #{$1}"
  else
    klass = nil
  end
  content_tag :span, tag(:img, :src => src, :title => title, :alt => alt), :class => klass
end
paragraph(text) click to toggle source
# File lib/documentation/markdown_renderer.rb, line 51
def paragraph(text)
  klass = ''
  text.gsub!(/\A(\w+)\:/) do
    klass = $1
    nil
  end
  text.sub!(/ ([^ ]+)$/, '&nbsp;\1')
  "<p class='#{klass.downcase}'>#{text}</p>"
end