Heading parser factory

Introduced properties

Redefined properties

redef type SELF: MdHeadingParserFactory

markdown2 $ MdHeadingParserFactory :: SELF

Type of this instance, automatically specialized in every class
redef fun try_start(state: MdParser, matched_block_parser: MdBlockParser): nullable MdBlockStart

markdown2 $ MdHeadingParserFactory :: try_start

Can the associated block parser can start at the current line in parser?

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
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 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 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.
abstract fun try_start(parser: MdParser, matched_block_parser: MdBlockParser): nullable MdBlockStart

markdown2 :: MdBlockParserFactory :: try_start

Can the associated block parser can start at the current line in parser?
package_diagram markdown2::MdHeadingParserFactory MdHeadingParserFactory markdown2::MdBlockParserFactory MdBlockParserFactory markdown2::MdHeadingParserFactory->markdown2::MdBlockParserFactory core::Object Object markdown2::MdBlockParserFactory->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class MdBlockParserFactory

markdown2 :: MdBlockParserFactory

Block parser factory for a block node for determining when a block starts

Class definitions

markdown2 $ MdHeadingParserFactory
# Heading parser factory
class MdHeadingParserFactory
	super MdBlockParserFactory

	redef fun try_start(state, matched_block_parser) do
		if state.indent >= 4 then return null

		var next_non_space = state.next_non_space_index
		var line = state.line_string
		var paragraph = null
		if matched_block_parser isa MdParagraphParser then
			paragraph = matched_block_parser.content
		end

		var line_content = line.substring(next_non_space, line.length - next_non_space)
		var match = line_content.search(re_atx_heading)
		if match != null then
			# ATX heading
			var new_offset = next_non_space + match.subs.first.as(not null).length
			var level = match.subs.first.as(not null).to_s.trim.length
			# remove trailing ###s
			var after_leading = line.substring(new_offset, line.length - new_offset)
			var trailing = after_leading.search(re_atx_trailing)
			var has_trailing = trailing != null
			var trailing_length = if trailing != null then trailing.length else 0
			var content = after_leading.replace(re_atx_trailing, "")
			return (new MdBlockStart(
				[new MdHeadingParser(
					state.line,
					next_non_space + 1,
					new_offset + 1,
					state.line,
					new_offset + content.length + trailing_length,
					level,
					content,
					has_trailing, false)])
				).at_index(line.length)
		end

		if paragraph ==  null then return null

		match = line_content.search(re_setext_heading)
		if match == null then return null
		var level = 2
		if match.subs.first.as(not null).to_s.chars.first == '=' then level = 1
		var content = paragraph.to_s
		return (new MdBlockStart(
			[new MdHeadingParser(
				state.line - 1,
				next_non_space + 1,
				0,
				state.line,
				state.column + match.length,
				level,
				content,
				false, true)])
			).at_index(line.length).replacing_active_block_parser
	end
end
lib/markdown2/markdown_block_parsing.nit:660,1--718,3