Class: Polytrix::Documentation::Helpers::CodeHelper::MarkdownHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/polytrix/documentation/helpers/code_helper.rb

Class Method Summary collapse

Class Method Details

.code_block(source, language) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/polytrix/documentation/helpers/code_helper.rb', line 20

def self.code_block(source, language)
  buffer = StringIO.new
  buffer.puts # I've seen lots of rendering issues without a dividing newline
  buffer.puts "```#{language}"
  buffer.puts source
  buffer.puts '```'
  buffer.puts # Put a dividing newline after as well, to be safe...
  buffer.string
end