markdown2 $ MdHtmlBlockParserFactory :: SELF
Type of this instance, automatically specialized in every classmarkdown2 $ MdHtmlBlockParserFactory :: 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
# Html blocks parser factory
class MdHtmlBlockParserFactory
super MdBlockParserFactory
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 or line.chars[next_non_space] != '<' then return null
for block_type in [0..6] do
# type 7 can not interrupt a paragraph
if block_type == 6 and matched_block_parser.block isa MdParagraph then continue
var opener = re_html_blocks[block_type].first
var closer = re_html_blocks[block_type].last
if line.substring(next_non_space, line.length - next_non_space).has(opener.as(not null)) then
return (new MdBlockStart(
[new MdHtmlBlockParser(
state.line,
state.column + 1,
next_non_space,
closer)])
).at_index(state.index)
end
end
return null
end
end
lib/markdown2/markdown_block_parsing.nit:1334,1--1361,3