Finalize the current block

Deactivate self from parser and call close_block.

Property definitions

markdown2 $ MdBlockParser :: finalize
	# Finalize the current `block`
	#
	# Deactivate `self` from `parser` and call `close_block`.
	fun finalize(parser: MdParser) do
		if parser.active_block_parser == self then
			parser.deactivate_block_parser
		end
	end
lib/markdown2/markdown_block_parsing.nit:514,2--521,4

markdown2 $ MdDocumentBlockParser :: finalize
	redef fun finalize(parser) do
	end
lib/markdown2/markdown_block_parsing.nit:610,2--611,4

markdown2 $ MdIndentedCodeBlockParser :: finalize
	redef fun finalize(parser) do
		super

		add_line(" ")
		var content = self.content.to_s
		var literal = content.replace_first(re_trailing_blank_lines, "\n")
		block.literal = literal

		var lines = literal.split("\n")
		location.line_end = location.line_start + lines.length - 2
		location.column_end = content_offset + lines[lines.length - 2].length + 4
	end
lib/markdown2/markdown_block_parsing.nit:809,2--820,4

markdown2 $ MdFencedCodeBlockParser :: finalize
	redef fun finalize(parser) do
		super

		# first line become info string
		var first_line = self.first_line
		if first_line != null then
			var info = first_line.trim.unescape_string
			if not info.is_empty then block.info = info
		end

		var content = other_lines.to_s
		block.literal =  content

		var lines = content.split("\n")
		location.line_end = location.line_start + lines.length
		location.column_end = content_offset + fence_indent + fence_length
	end
lib/markdown2/markdown_block_parsing.nit:900,2--916,4

markdown2 $ MdListBlockParser :: finalize
	redef fun finalize(parser) do
		super

		var item = block.first_child
		while item != null do
			# check for non-final list item ending with blank line
			if parser.ends_with_blank_line(item) and item.next != null then
				block.is_tight = false
				break
			end
			# recurse into children of list item to see if there are spaces between any of them
			var sub_item = item.first_child
			while sub_item != null do
				if parser.ends_with_blank_line(sub_item) and
				   (item.next != null or sub_item.next != null) then
					block.is_tight = false
					break
				end
				sub_item = sub_item.next
			end
			item = item.next
		end
	end
lib/markdown2/markdown_block_parsing.nit:987,2--1009,4

markdown2 $ MdThematicBreakParser :: finalize
	redef fun finalize(parser) do
		super

		location.line_end = line_start
		location.column_end = column_start + pattern.length - 1
	end
lib/markdown2/markdown_block_parsing.nit:1189,2--1194,4

markdown2 $ MdParagraphParser :: finalize
	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
lib/markdown2/markdown_block_parsing.nit:1245,2--1269,4

markdown2 $ MdHtmlBlockParser :: finalize
	redef fun finalize(parser) do
		super

		var content = self.content.to_s
		block.literal = content

		var lines = content.split("\n")
		location.line_end = location.line_start + lines.length - 1
		location.column_end = lines.last.length
	end
lib/markdown2/markdown_block_parsing.nit:1322,2--1331,4