markdown :: BlockList :: defaultinit
# A markdown list block.
# Can be either an ordered or unordered list, this class is mainly used to factorize code.
abstract class BlockList
super Block
# Split list block into list items sub-blocks.
private fun init_block(v: MarkdownProcessor) do
var line = block.first_line
if line == null then return
line = line.next
while line != null do
var t = v.line_kind(line)
if t isa LineList or
(not line.is_empty and (line.prev_empty and line.leading == 0 and
not (t isa LineList))) then
var sblock = block.split(line.prev.as(not null))
sblock.kind = new BlockListItem(sblock)
end
line = line.next
end
var sblock = block.split(block.last_line.as(not null))
sblock.kind = new BlockListItem(sblock)
end
# Expand list items as paragraphs if needed.
private fun expand_paragraphs(block: MDBlock) do
var outer = block.first_block
var inner: nullable MDBlock
var has_paragraph = false
while outer != null and not has_paragraph do
if outer.kind isa BlockListItem then
inner = outer.first_block
while inner != null and not has_paragraph do
if inner.kind isa BlockParagraph then
has_paragraph = true
end
inner = inner.next
end
end
outer = outer.next
end
if has_paragraph then
outer = block.first_block
while outer != null do
if outer.kind isa BlockListItem then
inner = outer.first_block
while inner != null do
if inner.kind isa BlockNone then
inner.kind = new BlockParagraph(inner)
end
inner = inner.next
end
end
outer = outer.next
end
end
end
end
lib/markdown/markdown.nit:1329,1--1386,3