input
string into MDLines
and create a parent MDBlock
with it.
# Split `input` string into `MDLines` and create a parent `MDBlock` with it.
private fun read_lines(input: String): MDBlock do
var block = new MDBlock(new MDLocation(1, 1, 1, 1))
var value = new FlatBuffer
var i = 0
var line_pos = 0
var col_pos = 0
while i < input.length do
value.clear
var pos = 0
var eol = false
while not eol and i < input.length do
col_pos += 1
var c = input[i]
if c == '\n' then
eol = true
else if c == '\r' then
else if c == '\t' then
var np = pos + (4 - (pos & 3))
while pos < np do
value.add ' '
pos += 1
end
else
pos += 1
value.add c
end
i += 1
end
line_pos += 1
var loc = new MDLocation(line_pos, 1, line_pos, col_pos)
var line = new MDLine(loc, value.write_to_string)
var is_link_ref = check_link_ref(line)
# Skip link refs
if not is_link_ref then block.add_line line
col_pos = 0
end
return block
end
lib/markdown/markdown.nit:157,2--198,4