Class: ApiGuides::MarkdownHelper::HTMLwithHighlighting

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/api_guides/markdown_helper.rb

Instance Method Summary collapse

Instance Method Details

#bblock_code(code, language) ⇒ Object

Override the default so we can do syntax highlighting based on the language



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/api_guides/markdown_helper.rb', line 11

def bblock_code(code, language)
  # If there's a language, use the pygments webservice
  # to highlight for the language
  if language
    Net::HTTP.post_form(
      URI.parse('http://pygments.appspot.com/'),
      {'lang' => language, 'code' => code}
    ).body
  else
   %Q{<code class="#{language}"><pre>#{code}></pre></code>}
  end
end