Representation of a markdown block in the AST.

Each Block is linked to a MDBlock that contains mardown code.

Introduced properties

fun block: MDBlock

markdown :: Block :: block

The markdown block self is related to.
protected fun block=(block: MDBlock)

markdown :: Block :: block=

The markdown block self is related to.
fun emit(v: MarkdownProcessor)

markdown :: Block :: emit

Output self using v.decorator.
fun emit_blocks(v: MarkdownProcessor)

markdown :: Block :: emit_blocks

Emit sub-blocks contained in block.
fun emit_in(v: MarkdownProcessor)

markdown :: Block :: emit_in

Emit the containts of self, lines or blocks.
fun emit_lines(v: MarkdownProcessor)

markdown :: Block :: emit_lines

Emit lines contained in block.
fun raw_content: String

markdown :: Block :: raw_content

The raw content of the block as a multi-line string.

Redefined properties

redef type SELF: Block

markdown $ Block :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun block: MDBlock

markdown :: Block :: block

The markdown block self is related to.
protected fun block=(block: MDBlock)

markdown :: Block :: block=

The markdown block self is related to.
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun emit(v: MarkdownProcessor)

markdown :: Block :: emit

Output self using v.decorator.
fun emit_blocks(v: MarkdownProcessor)

markdown :: Block :: emit_blocks

Emit sub-blocks contained in block.
fun emit_in(v: MarkdownProcessor)

markdown :: Block :: emit_in

Emit the containts of self, lines or blocks.
fun emit_lines(v: MarkdownProcessor)

markdown :: Block :: emit_lines

Emit lines contained in block.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun raw_content: String

markdown :: Block :: raw_content

The raw content of the block as a multi-line string.
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram markdown::Block Block core::Object Object markdown::Block->core::Object markdown::BlockNone BlockNone markdown::BlockNone->markdown::Block markdown::BlockQuote BlockQuote markdown::BlockQuote->markdown::Block markdown::BlockCode BlockCode markdown::BlockCode->markdown::Block markdown::BlockHeadline BlockHeadline markdown::BlockHeadline->markdown::Block markdown::BlockListItem BlockListItem markdown::BlockListItem->markdown::Block markdown::BlockList BlockList markdown::BlockList->markdown::Block markdown::BlockParagraph BlockParagraph markdown::BlockParagraph->markdown::Block markdown::BlockRuler BlockRuler markdown::BlockRuler->markdown::Block markdown::BlockXML BlockXML markdown::BlockXML->markdown::Block markdown::BlockFence BlockFence markdown::BlockFence->markdown::BlockCode markdown::BlockFence... ... markdown::BlockFence...->markdown::BlockFence markdown::BlockOrderedList BlockOrderedList markdown::BlockOrderedList->markdown::BlockList markdown::BlockUnorderedList BlockUnorderedList markdown::BlockUnorderedList->markdown::BlockList markdown::BlockOrderedList... ... markdown::BlockOrderedList...->markdown::BlockOrderedList markdown::BlockUnorderedList... ... markdown::BlockUnorderedList...->markdown::BlockUnorderedList

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

class BlockCode

markdown :: BlockCode

A markdown code block.
class BlockHeadline

markdown :: BlockHeadline

A markdown headline.
abstract class BlockList

markdown :: BlockList

A markdown list block.
class BlockListItem

markdown :: BlockListItem

A markdown list item block.
class BlockNone

markdown :: BlockNone

A block without any markdown specificities.
class BlockParagraph

markdown :: BlockParagraph

A markdown paragraph block.
class BlockQuote

markdown :: BlockQuote

A markdown blockquote.
class BlockRuler

markdown :: BlockRuler

A markdown ruler.
class BlockXML

markdown :: BlockXML

Xml blocks that can be found in markdown markup.

Descendants

class BlockFence

markdown :: BlockFence

A markdown code-fence block.
class BlockOrderedList

markdown :: BlockOrderedList

A markdown ordered list.
class BlockUnorderedList

markdown :: BlockUnorderedList

A markdown unordred list.

Class definitions

markdown $ Block
# Representation of a markdown block in the AST.
# Each `Block` is linked to a `MDBlock` that contains mardown code.
abstract class Block

	# The markdown block `self` is related to.
	var block: MDBlock

	# Output `self` using `v.decorator`.
	fun emit(v: MarkdownProcessor) do v.emit_in(self)

	# Emit the containts of `self`, lines or blocks.
	fun emit_in(v: MarkdownProcessor) do
		block.remove_surrounding_empty_lines
		if block.has_lines then
			emit_lines(v)
		else
			emit_blocks(v)
		end
	end

	# Emit lines contained in `block`.
	fun emit_lines(v: MarkdownProcessor) do
		var tpl = v.push_buffer
		var line = block.first_line
		while line != null do
			if not line.is_empty then
				v.add line.value.substring(line.leading, line.value.length - line.trailing)
				if line.trailing >= 2 then v.decorator.add_line_break(v)
			end
			if line.next != null then
				v.addn
			end
			line = line.next
		end
		v.pop_buffer
		v.emit_text(tpl)
	end

	# Emit sub-blocks contained in `block`.
	fun emit_blocks(v: MarkdownProcessor) do
		var block = self.block.first_block
		while block != null do
			v.push_loc(block.location)
			block.kind.emit(v)
			v.pop_loc
			block = block.next
		end
	end

	# The raw content of the block as a multi-line string.
	fun raw_content: String do
		var infence = self isa BlockFence
		var text = new FlatBuffer
		var line = self.block.first_line
		while line != null do
			if not line.is_empty then
				var str = line.value
				if not infence and str.has_prefix("    ") then
					text.append str.substring(4, str.length - line.trailing)
				else
					text.append str
				end
			end
			text.append "\n"
			line = line.next
		end
		return text.write_to_string
	end
end
lib/markdown/markdown.nit:1134,1--1202,3