class Hamdown::MdRegs::OList
class with logic of markdown's ordered 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/o_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 = str.scan(/^ */)[0].size 26 html = html_scan[index].split(/\n/).join("\n#{' ' * space_size}") 27 html = "#{' ' * space_size}#{html}\n" 28 text.gsub!(str, html) 29 end 30 text 31 end