markdown2 :: MdParagraphParser :: block=
markdown2 :: MdParagraphParser :: content=
Paragraph contentmarkdown2 $ MdParagraphParser :: BLOCK
Kind of block under constructionmarkdown2 $ MdParagraphParser :: SELF
Type of this instance, automatically specialized in every classmarkdown2 $ MdParagraphParser :: add_line
Addline
to the current block
markdown2 $ MdParagraphParser :: finalize
Finalize the currentblock
markdown2 $ MdParagraphParser :: parse_inlines
Parseblock
lines
markdown2 $ MdParagraphParser :: try_continue
Canself
continue from the current index
in parser
?
markdown2 :: MdParagraphParser :: block=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
markdown2 :: MdBlockParser :: column_start=
Column startmarkdown2 :: MdParagraphParser :: content=
Paragraph contentmarkdown2 :: MdBlockParser :: content_offset
Column where the content startsmarkdown2 :: MdBlockParser :: content_offset=
Column where the content startscore :: Object :: defaultinit
markdown2 :: MdBlockParser :: initialize
Initialize the currentblock
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.
markdown2 :: MdBlockParser :: location=
Location at startcore :: Object :: output_class_name
Display class name on stdout (debug only).markdown2 :: MdBlockParser :: parse_inlines
Parseblock
lines
markdown2 :: MdBlockParser :: try_continue
Canself
continue from the current index
in parser
?
# Paragraphs parser
class MdParagraphParser
super MdBlockParser
redef type BLOCK: MdParagraph
redef var block = new MdParagraph(location) is lazy
# Paragraph content
var content: nullable Buffer = new Buffer
redef fun try_continue(state) do
if state.is_blank then return null
return new MdBlockContinue.at_index(state.index)
end
redef fun add_line(line) do
var content = self.content
if content == null then return
if not content.is_empty then
content.add('\n')
end
content.append(line)
end
redef fun finalize(parser) do
super
var inline_parser = parser.inline_parser
var content = self.content
if content == null then return
var content_string = content.to_s
var has_reference_defs = false
var pos = inline_parser.parse_reference(content_string)
# try parsing the beginning as link reference definitions
while content_string.length > 3 and content_string.chars[0] == '[' and pos != 0 do
content_string = content_string.substring(pos, content_string.length - pos)
has_reference_defs = true
pos = inline_parser.parse_reference(content_string)
end
if has_reference_defs and content_string.is_blank then
block.unlink
self.content = null
else
self.content = new Buffer.from_text(content_string)
end
end
redef fun parse_inlines(inline_parser) do
var content = self.content
if content == null then return
inline_parser.parse(content.to_s, content_offset, block)
var last_child = block.last_child
if last_child != null then
location.line_end = last_child.location.line_end
location.column_end = last_child.location.column_end
end
end
end
lib/markdown2/markdown_block_parsing.nit:1220,1--1282,3