Custom Markdown processor able to process doc commands

Introduced properties

private var _filter: nullable ModelFilter

nitc :: CmdDecorator :: _filter

Filter to apply if any
private var _model: Model

nitc :: CmdDecorator :: _model

Model used by wikilink commands to find entities
init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: CmdDecorator :: defaultinit

fun filter: nullable ModelFilter

nitc :: CmdDecorator :: filter

Filter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: CmdDecorator :: filter=

Filter to apply if any
fun model: Model

nitc :: CmdDecorator :: model

Model used by wikilink commands to find entities
protected fun model=(model: Model)

nitc :: CmdDecorator :: model=

Model used by wikilink commands to find entities
private fun try_find_mentity(text: String): nullable MEntity

nitc :: CmdDecorator :: try_find_mentity

Redefined properties

redef type PROCESSOR: CmdMarkdownProcessor

nitc $ CmdDecorator :: PROCESSOR

Kind of processor used
redef type SELF: CmdDecorator

nitc $ CmdDecorator :: SELF

Type of this instance, automatically specialized in every class
redef fun add_span_code(v: PROCESSOR, buffer: Text, from: Int, to: Int)

nitc $ CmdDecorator :: add_span_code

Render a code span reading from a buffer.

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 PROCESSOR: MarkdownProcessor

markdown :: Decorator :: PROCESSOR

Kind of processor used
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _catalog: Catalog

nitc :: NitdocDecorator :: _catalog

The registered catalog
private var _current_mdoc: nullable MDoc

nitc :: NitdocDecorator :: _current_mdoc

The currently processed mdoc.
private var _filter: nullable ModelFilter

nitc :: CmdDecorator :: _filter

Filter to apply if any
private var _model: Model

nitc :: CmdDecorator :: _model

Model used by wikilink commands to find entities
abstract fun add_abbr(v: PROCESSOR, name: Text, comment: Text)

markdown :: Decorator :: add_abbr

Render an abbreviation.
abstract fun add_blockquote(v: PROCESSOR, block: BlockQuote)

markdown :: Decorator :: add_blockquote

Render a blockquote.
fun add_char(v: PROCESSOR, c: Char)

markdown :: Decorator :: add_char

Render a single plain char.
abstract fun add_code(v: PROCESSOR, block: BlockCode)

markdown :: Decorator :: add_code

Render a code or fence block.
abstract fun add_em(v: PROCESSOR, text: Text)

markdown :: Decorator :: add_em

Render an emphasis text.
abstract fun add_headline(v: PROCESSOR, block: BlockHeadline)

markdown :: Decorator :: add_headline

Render a headline block with corresponding level.
abstract fun add_image(v: PROCESSOR, link: Text, name: Text, comment: nullable Text)

markdown :: Decorator :: add_image

Render an image.
abstract fun add_line_break(v: PROCESSOR)

markdown :: Decorator :: add_line_break

Render a line break
abstract fun add_listitem(v: PROCESSOR, block: BlockListItem)

markdown :: Decorator :: add_listitem

Render a list item.
abstract fun add_orderedlist(v: PROCESSOR, block: BlockOrderedList)

markdown :: Decorator :: add_orderedlist

Render an ordered list.
abstract fun add_paragraph(v: PROCESSOR, block: BlockParagraph)

markdown :: Decorator :: add_paragraph

Render a paragraph block.
abstract fun add_ruler(v: PROCESSOR, block: BlockRuler)

markdown :: Decorator :: add_ruler

Render a ruler block.
abstract fun add_span_code(v: PROCESSOR, buffer: Text, from: Int, to: Int)

markdown :: Decorator :: add_span_code

Render a code span reading from a buffer.
abstract fun add_strike(v: PROCESSOR, text: Text)

markdown :: Decorator :: add_strike

Render a strike text.
abstract fun add_strong(v: PROCESSOR, text: Text)

markdown :: Decorator :: add_strong

Render a strong text.
abstract fun add_unorderedlist(v: PROCESSOR, block: BlockUnorderedList)

markdown :: Decorator :: add_unorderedlist

Render an unordered list.
private fun allowed_id_chars=(allowed_id_chars: Array[Char])

markdown :: HTMLDecorator :: allowed_id_chars=

abstract fun append_code(v: PROCESSOR, buffer: Text, from: Int, to: Int)

markdown :: Decorator :: append_code

Render code text from buffer and escape it.
abstract fun append_value(v: PROCESSOR, value: Text)

markdown :: Decorator :: append_value

Render a text and escape it.
fun catalog: Catalog

nitc :: NitdocDecorator :: catalog

The registered catalog
protected fun catalog=(catalog: Catalog)

nitc :: NitdocDecorator :: catalog=

The registered catalog
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.
private fun code_from_text(buffer: Text, from: Int, to: Int): String

nitc :: NitdocDecorator :: code_from_text

fun current_mdoc: nullable MDoc

nitc :: NitdocDecorator :: current_mdoc

The currently processed mdoc.
protected fun current_mdoc=(current_mdoc: nullable MDoc)

nitc :: NitdocDecorator :: current_mdoc=

The currently processed mdoc.
init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: CmdDecorator :: defaultinit

abstract fun escape_char(v: PROCESSOR, char: Char)

markdown :: Decorator :: escape_char

Render a character escape.
fun filter: nullable ModelFilter

nitc :: CmdDecorator :: filter

Filter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: CmdDecorator :: filter=

Filter to apply if any
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.
abstract fun headlines: ArrayMap[String, HeadLine]

markdown :: Decorator :: headlines

Found headlines during the processing labeled by their ids.
protected fun headlines=(headlines: ArrayMap[String, HeadLine])

markdown :: HTMLDecorator :: headlines=

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.
fun model: Model

nitc :: CmdDecorator :: model

Model used by wikilink commands to find entities
protected fun model=(model: Model)

nitc :: CmdDecorator :: model=

Model used by wikilink commands to find entities
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
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
abstract fun strip_id(txt: String): String

markdown :: Decorator :: strip_id

Generate a new html valid id from a String.
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.
private fun toolcontext=(toolcontext: ToolContext)

nitc :: NitdocDecorator :: toolcontext=

private fun try_find_mentity(text: String): nullable MEntity

nitc :: CmdDecorator :: try_find_mentity

package_diagram nitc::CmdDecorator CmdDecorator nitc::NitdocDecorator NitdocDecorator nitc::CmdDecorator->nitc::NitdocDecorator markdown::HTMLDecorator HTMLDecorator nitc::NitdocDecorator->markdown::HTMLDecorator ...markdown::HTMLDecorator ... ...markdown::HTMLDecorator->markdown::HTMLDecorator

Ancestors

interface Decorator

markdown :: Decorator

A Decorator is used to emit mardown into a specific format.
class HTMLDecorator

markdown :: HTMLDecorator

Decorator that outputs HTML.
interface Object

core :: Object

The root of the class hierarchy.

Parents

class NitdocDecorator

nitc :: NitdocDecorator

The specific markdown decorator used internally to process MDoc object.

Class definitions

nitc $ CmdDecorator
# Custom Markdown processor able to process doc commands
class CmdDecorator
	super NitdocDecorator

	redef type PROCESSOR: CmdMarkdownProcessor

	# Model used by wikilink commands to find entities
	var model: Model

	# Filter to apply if any
	var filter: nullable ModelFilter

	redef fun add_span_code(v, buffer, from, to) do
		var text = new FlatBuffer
		buffer.read(text, from, to)
		var name = text.write_to_string
		name = name.replace("nullable ", "")
		var mentity = try_find_mentity(name)
		if mentity == null then
			super
		else
			v.add "<code>"
			v.emit_text mentity.html_link.write_to_string
			v.add "</code>"
		end
	end

	private fun try_find_mentity(text: String): nullable MEntity do
		var mentity = model.mentity_by_full_name(text, filter)
		if mentity != null then return mentity

		var mentities = model.mentities_by_name(text, filter)
		if mentities.is_empty then
			return null
		else if mentities.length > 1 then
			# TODO smart resolve conflicts
		end
		return mentities.first
	end

	redef fun add_wikilink(v, token) do
		v.render_wikilink(token, model)
	end
end
src/doc/templates/html_commands.nit:361,1--404,3