Can be either an ordered or unordered list, this class is mainly used to factorize code.
markdown :: BlockList :: defaultinit
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
markdown :: Block :: defaultinit
markdown :: BlockList :: defaultinit
core :: Object :: defaultinit
markdown :: Block :: emit_blocks
Emit sub-blocks contained inblock
.
self
, lines or blocks.
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).markdown :: Block :: raw_content
The raw content of the block as a multi-line string.
# 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