self
continue from the current index
in parser
?Return a new MdBlockContinue
if self
can continue parsing.
Return null otherwise.
# Can `self` continue from the current `index` in `parser`?
#
# Return a new `MdBlockContinue` if `self` can continue parsing.
# Return null otherwise.
fun try_continue(state: MdParser): nullable MdBlockContinue is abstract
lib/markdown2/markdown_block_parsing.nit:505,2--509,72
# Always continue at current indent
redef fun try_continue(state) do return new MdBlockContinue.at_index(state.index)
lib/markdown2/markdown_block_parsing.nit:607,2--608,82
# Never continue parsing as an heading is a one liner
redef fun try_continue(state) do return null
lib/markdown2/markdown_block_parsing.nit:651,2--652,45
redef fun try_continue(state) do
var next_non_space = state.next_non_space_index
var indent = state.indent
var line = state.line_string
if indent >= 4 then return null
if next_non_space >= line.length then return null
if line.chars[next_non_space] != '>' then return null
var new_column = state.column + state.indent + 1
# optional following space or tab
if state.line_string.is_space_or_tab(next_non_space + 1) then
new_column += 1
end
return new MdBlockContinue.at_column(new_column)
end
lib/markdown2/markdown_block_parsing.nit:727,2--742,4
redef fun try_continue(state) do
var next_non_space = state.next_non_space_index
var new_index = state.index
var line = state.line_string
if state.indent <= 3 and next_non_space < line.length and
line.chars[next_non_space] == fence_char then
var match = line.substring(next_non_space, line.length - next_non_space).
search(re_closing_fence)
if match != null and match.subs[0].as(not null).length >= fence_length then
# closing fence - we're at end of line, so we can finalize now
return new MdBlockContinue.finished
end
end
# skip optional spaces of fence indent
var i = fence_indent
while i > 0 and new_index < line.length and line.chars[new_index] == ' ' do
new_index += 1
i -= 1
end
return new MdBlockContinue.at_index(new_index)
end
lib/markdown2/markdown_block_parsing.nit:865,2--889,4
redef fun try_continue(state) do return new MdBlockContinue.at_index(state.index)
lib/markdown2/markdown_block_parsing.nit:985,2--82
redef fun try_continue(state) do
if state.is_blank then
if block.first_child == null then
# blank line after empty list item
return null
end
return new MdBlockContinue.at_index(state.next_non_space_index)
end
if state.indent >= content_indent then
return new MdBlockContinue.at_column(state.column + content_indent)
end
return null
end
lib/markdown2/markdown_block_parsing.nit:1154,2--1166,4
redef fun try_continue(state) do return null
lib/markdown2/markdown_block_parsing.nit:1187,2--45
redef fun try_continue(state) do
if state.is_blank then return null
return new MdBlockContinue.at_index(state.index)
end
lib/markdown2/markdown_block_parsing.nit:1231,2--1234,4
redef fun try_continue(state) do
if finished then return null
# blank lin ends type 6 and 7 blocks
if state.is_blank and closing_pattern == null then return null
return new MdBlockContinue.at_index(state.index)
end
lib/markdown2/markdown_block_parsing.nit:1302,2--1309,4