class Mdoc::Processor::SmartCodeBlock
Public Instance Methods
process!(doc)
click to toggle source
# File lib/mdoc/processor/smart_code_block.rb, line 7 def process!(doc) odd, last, hold = false, false, 0 new_body = '' doc.body.split(/\n/).each do |line| if line =~ /^\s*~{3,}\s*\w*\s*/ hold = 0 if odd odd = odd ? false : true last = true else next if last && odd && (line =~ /^\s*$/) if line =~ /^\s*$/ hold += 1 # hold the line next end last = false end hold.times { new_body << "\n" } hold = 0 new_body << line << "\n" end doc.body = new_body.chomp # puts doc.body end