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
link(link, title, content)
click to toggle source
# File lib/documentation/markdown_renderer.rb, line 22 def link(link, title, content) if link =~ /\A\^/ case link when /\A\^\.\/(.*)/ # ^./pagename # Links to pages on the same level as the current page link = "{{docRoot}}/#{page.parents.map(&:permalink).join('/')}/#{$1}" when /\A\^\/(.*)/ # ^/full/path # Links to a page frmo the root of the docs link = "{{docRoot}}/#{$1}" when /\A\^(.*)/ # ^child/item # Links to a child of the current page link = "{{docRoot}}/#{page.full_permalink}/#{$1}" end end "<a href='#{link}' title='#{title}'>#{content}</a>" 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!(/ ([^ ]+)$/, ' \1') "<p class='#{klass.downcase}'>#{text}</p>" end