class Hamdown::MdRegs::UList

class with logic of markdown's unordered lists TODO: add nested lists support

Constants

REGS

TODO: add '?:' to unuseful group /learn(?:bydoing)/

Private Instance Methods

text_handler(text, scan_res) click to toggle source
   # File lib/hamdown/md_regs/u_list.rb
13 def text_handler(text, scan_res)
14   # crazy manipulation
15   scan_res = scan_res.map { |i| i[0] }
16   html_scan = scan_res
17               .map { |i| i.gsub(/^ */, '') }
18               .map { |i| i.gsub(/\n( )*/, "\n")}
19               .map { |i| md_to_html(i) }
20 
21   html_scan = html_scan
22               .map { |i| i.split(/\n */).join('') }
23               .map { |i| "#{i}\n" }
24   scan_res.each_with_index do |str, index|
25     space_size = 0
26     if (str.scan(/^\n? */)[0].size - 2) > 0
27       space_size = str.scan(/^\n? */)[0].size - 1
28     end
29     html = html_scan[index].split(/\n/).join("\n#{' ' * space_size}")
30     html = "#{' ' * space_size}#{html}\n"
31     text.gsub!(str, html)
32   end
33   text
34 end