markdown :: BlockHeadline :: defaultinit
markdown :: BlockHeadline :: depth
Depth of the headline used to determine the headline level.markdown :: BlockHeadline :: depth=
Depth of the headline used to determine the headline level.markdown $ BlockHeadline :: SELF
Type of this instance, automatically specialized in every classmarkdown $ BlockHeadline :: emit
Outputself
using v.decorator
.
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
markdown :: BlockHeadline :: defaultinit
markdown :: Block :: defaultinit
markdown :: BlockHeadline :: depth
Depth of the headline used to determine the headline level.markdown :: BlockHeadline :: depth=
Depth of the headline used to determine the headline level.markdown :: Block :: emit_blocks
Emit sub-blocks contained inblock
.
self
, lines or blocks.
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).markdown :: Block :: raw_content
The raw content of the block as a multi-line string.
# 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