markdown2 $ MdFencedCodeBlockParserFactory :: SELF
Type of this instance, automatically specialized in every classmarkdown2 $ MdFencedCodeBlockParserFactory :: try_start
Can the associated block parser can start at the current line inparser
?
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
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).markdown2 :: MdBlockParserFactory :: try_start
Can the associated block parser can start at the current line inparser
?
markdown2 :: MdBlockParserFactory
Block parser factory for a block node for determining when a block starts
# Fenced code blocks parser factory
class MdFencedCodeBlockParserFactory
super MdBlockQuoteParserFactory
redef fun try_start(state, matched_block_parser) do
var next_non_space = state.next_non_space_index
var line = state.line_string
if state.indent >= 4 then return null
var match = line.substring(next_non_space, line.length - next_non_space).search(re_opening_fence)
if match == null then return null
var fence_length
var fence_char
var sub0 = match.subs[0]
if sub0 != null then
fence_length = sub0.length
fence_char = sub0.to_s.chars.first
else
fence_length = match.subs[2].as(not null).length
fence_char = match.subs[2].as(not null).to_s.chars.first
end
if fence_char == '`' and match.to_s.has("[^`]+`".to_re) then
return null
else if match.to_s.has("[^~]+~".to_re) then
return null
end
return (new MdBlockStart(
[new MdFencedCodeBlockParser(
state.line,
state.column + 1,
state.column,
fence_char,
fence_length,
state.indent)]
)).at_index(next_non_space + fence_length)
end
end
lib/markdown2/markdown_block_parsing.nit:919,1--957,3