self
creating a new sub-block having line
has last_line
.
# Split `self` creating a new sub-block having `line` has `last_line`.
fun split(line: MDLine): MDBlock do
# location for new block
var new_loc = new MDLocation(
first_line.as(not null).location.line_start,
first_line.as(not null).location.column_start,
line.location.line_end,
line.location.column_end)
# create block
var block = new MDBlock(new_loc)
block.first_line = first_line
block.last_line = line
first_line = line.next
line.next = null
if first_line == null then
last_line = null
else
first_line.as(not null).prev = null
# update current block loc
location.line_start = first_line.as(not null).location.line_start
location.column_start = first_line.as(not null).location.column_start
end
if first_block == null then
first_block = block
last_block = block
else
last_block.as(not null).next = block
last_block = block
end
return block
end
lib/markdown/markdown.nit:1001,2--1031,4