Property definitions

markdown $ BlockHeadline :: defaultinit
# A markdown headline.
class BlockHeadline
	super Block

	redef fun emit(v) do
		var loc = block.location.copy
		loc.column_start += start
		v.push_loc(loc)
		v.decorator.add_headline(v, self)
		v.pop_loc
	end

	private var start = 0

	# Depth of the headline used to determine the headline level.
	var depth = 0

	# Remove healine marks from lines contained in `self`.
	private fun transform_headline(block: MDBlock) do
		if depth > 0 then return
		var level = 0
		var line = block.first_line
		if line == null then return
		if line.is_empty then return
		var start = line.leading
		while start < line.value.length and line.value[start] == '#' do
			level += 1
			start += 1
		end
		while start < line.value.length and line.value[start] == ' ' do
			start += 1
		end
		if start >= line.value.length then
			line.is_empty = true
		else
			var nend = line.value.length - line.trailing - 1
			while line.value[nend] == '#' do nend -= 1
			while line.value[nend] == ' ' do nend -= 1
			line.value = line.value.substring(start, nend - start + 1)
			line.leading = 0
			line.trailing = 0
		end
		self.start = start
		depth = level.min(6)
	end
end
lib/markdown/markdown.nit:1275,1--1320,3