Class: Kramdown::Converter::Includey

Inherits:
Kramdown
  • Object
show all
Defined in:
lib/kramdown/converter/includey.rb

Instance Method Summary collapse

Instance Method Details

#convert_codeblock(el, indent) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/kramdown/converter/includey.rb', line 4

def convert_codeblock(el, indent)
if el.attr.include?('include')
	file_path = File.expand_path(Dir.pwd + '/' + el.attr['include'])
	el.value  = IO.read(file_path) if File.exists?(file_path)
end

attr = el.attr.dup
lang = extract_code_language!(attr)  
"~~~ #{lang}\n" + el.value.split(/\n/).map {|l| l.empty? ? "" : "#{l}"}.join("\n") + "\n~~~\n"
end