# List blocks parser
class MdListBlockParser
super MdBlockParser
redef type BLOCK: MdListBlock
redef var block is lazy do
if is_ordered then
return new MdOrderedList(location, digit.as(not null), delim.as(not null))
else
return new MdUnorderedList(location, bullet.as(not null))
end
end
# Is this list ordered
var is_ordered: Bool
# List bullet if unordered
var bullet: nullable Char
# List digit if ordered
var digit: nullable Int
# List delimiter if ordered
var delim: nullable Char
redef fun try_continue(state) do return new MdBlockContinue.at_index(state.index)
redef fun finalize(parser) do
super
var item = block.first_child
while item != null do
# check for non-final list item ending with blank line
if parser.ends_with_blank_line(item) and item.next != null then
block.is_tight = false
break
end
# recurse into children of list item to see if there are spaces between any of them
var sub_item = item.first_child
while sub_item != null do
if parser.ends_with_blank_line(sub_item) and
(item.next != null or sub_item.next != null) then
block.is_tight = false
break
end
sub_item = sub_item.next
end
item = item.next
end
end
redef fun parse_inlines(inline_parser) do
var last_child = block.last_child
if last_child != null then
location.line_end = last_child.location.line_end
location.column_end = last_child.location.column_end
end
end
end
lib/markdown2/markdown_block_parsing.nit:959,1--1018,3