class Hamdown::MdRegs::Code

class with logic of markdown's code block

Constants

REGS

Private Instance Methods

text_handler(text, scan_res) click to toggle source
   # File lib/hamdown/md_regs/code.rb
11 def text_handler(text, scan_res)
12   html_scan = scan_res.map do |i|
13     # delete spaces before last '```'
14     # and other unused symbols
15     s = md_to_html(i.gsub(/ *```$/, '```'))
16     s[0..s.size - 2].gsub(/\~*\n/, "\n")
17   end
18   scan_res.each_with_index do |str, index|
19     # replace \n by html symbol
20     text.gsub!(str, html_scan[index].gsub("\n", '
'))
21   end
22 
23   text
24 end