Sha256: 723da453204bc5692b977dc99cd8dcc257affe098ae948acdb9db2360c05091e
Contents?: true
Size: 833 Bytes
Versions: 16
Compression:
Stored size: 833 Bytes
Contents
module Ecrire::Markdown::Parsers class List < Base UL = /^(-\s)(.+)?$/i OL = /^(\d+\.\s)(.+)?$/i def parse! unless @node.instance_of?(Ecrire::Markdown::Node) return @node end if match = UL.match(@node.content) list! match, Ecrire::Markdown::Nodes::UnorderedList elsif match = OL.match(@node.content) list! match, Ecrire::Markdown::Nodes::OrderedList end return @node end def list!(match, tag) previous_node = @document.nodes[@index - 1] if previous_node.nil? || !previous_node.instance_of?(tag) @node = tag.new(match[2]) @document.nodes[@index] = @node else @index -= 1 @document.nodes.delete(@node) previous_node.append(match[2]) @node = previous_node end end end end
Version data entries
16 entries across 16 versions & 1 rubygems