MKBlock
Description
The base class for all Markdown document blocks.
Properties
Name | Type | Read-Only |
---|---|---|
Characters() | MarkdownKit.MKCharacter |
|
Children() | MarkdownKit.MKBlock |
|
Document | MarkdownKit.MKDocument |
✔ |
EndPosition | Integer |
|
FirstChild | MarkdownKit.MKBlock |
✔ |
IsChildOfListItem | Boolean |
|
IsChildOfTightList | Boolean |
|
IsFirstChild | Boolean |
✔ |
IsLastChild | Boolean |
✔ |
IsLastLineBlank | Boolean |
|
IsOpen | Boolean |
|
LastChild | MarkdownKit.MKBlock |
✔ |
LineNumber | Integer |
|
mDocument | WeakRef |
|
mParent | WeakRef |
|
Parent | MarkdownKit.MKBlock |
|
Start | Integer |
|
Type | MarkdownKit.MKBlockTypes |
Methods
Name | Parameters | Returns |
---|---|---|
Accept | visitor As MKRenderer |
Variant |
AddLine | line As XUITextLine , startPos As Integer , phantomSpaces As Integer |
|
AdvanceToNextLineStart | pos As Integer |
|
Constructor | type As MKBlockTypes , parent As MKBlock , blockStart As Integer |
|
EndsWithBlankLine | Boolean |
|
Finalise | line As XUITextLine |
|
IsInlineContainer | Boolean |
|
MatchWhitespaceCharactersInArray | chars() As MKCharacter , pos As Integer |
Integer |
NextSibling | MKBlock |
|
ParseLinkReferenceDefinitions | ||
PreviousSibling | MKBlock |
|
RemoveChild | child As MKBlock |
Property Descriptions
Characters() As MarkdownKit.MKCharacter
The characters of this block. Only valid for inline containers (other block types use MKTextBlocks).
Children() As MarkdownKit.MKBlock
This block's children.
Document As MarkdownKit.MKDocument
The document that owns this block.
EndPosition As Integer
0-based position in the original source of the end of this block. Only valid for inline blocks and inline container blocks.
FirstChild As MarkdownKit.MKBlock
The first child of this block or Nil if there are no children.
IsChildOfListItem As Boolean
True if this block is a child of a list item.
IsChildOfTightList As Boolean
True if this block is a child of a tight list.
IsFirstChild As Boolean
True if this block is the first child of its parent.
IsLastChild As Boolean
True if this block is the last child of its parent.
IsLastLineBlank As Boolean
True if the last line of this container is blank.
IsOpen As Boolean
True if this block is open.
LastChild As MarkdownKit.MKBlock
The last child of this block or Nil if this block has no children.
LineNumber As Integer
The 1-based line number in the Markdown down that this block occurs on.
mDocument As WeakRef
A weak reference to the document that owns this block.
mParent As WeakRef
A weak reference to this block's parent. Will be Nil if this is a document block.
Parent As MarkdownKit.MKBlock
This block's parent or Nil if it unowned or is a document block.
Start As Integer
The 0-based position in the original Markdown source that this block begins at.
Type As MarkdownKit.MKBlockTypes
The type of block.
Method Descriptions
Accept(visitor As MKRenderer) As Variant
Accepts an AST renderer and redirects to the correct method.
AddLine(line As XUITextLine, startPos As Integer, phantomSpaces As Integer)
Adds text from line
beginning at startPos
to the end of the line.
AdvanceToNextLineStart(pos As Integer)
Starting at pos
, advances through Characters
to the start of the next line. If this is the last line
then pos
is set to Characters.LastIndex + 1
.
Constructor(type As MKBlockTypes, parent As MKBlock, blockStart As Integer)
Default constructor.
type
is this block's type.parent
is the parent of this block.blockStart
is the 0-based position in the original Markdown source that this block begins at.
EndsWithBlankLine() As Boolean
Returns True if this block ends with a blank line, descending if needed into lists and sublists.
Finalise(line As XUITextLine)
Closes this block and makes any final changes that may be required.
Subclasses can override this method if they have more complicated needs upon block closure.
line
is the line that triggered the Finalise
invocation.
IsInlineContainer() As Boolean
True if this block can contain inline blocks.
MatchWhitespaceCharactersInArray(chars() As MKCharacter, pos As Integer) As Integer
Matches whitespace in chars
beginning at pos
and returns how many characters were matched.
NextSibling() As MKBlock
Returns this block's next sibling or Nil if there isn't one.
ParseLinkReferenceDefinitions()
Parses any link reference definitions in this block, excises them, adds them to the document and adjust's this block's characters.
Assumes that this method is called during block parsing. Assumes this is only ever called by paragraph and STX blocks. At this point in the paragraph's life cycle, it consists of contiguous characters. That is: Characters(n + 1).Position = Characters(n).Position + 1`.
A link reference definition consists of a "link label", preceded by up to 3 spaces of indentation,
followed by a colon (:
), optional spaces or tabs (including up to one line ending),
a "link destination", optional spaces or tabs (including up to one line ending)
and an optional "link title" which, if present, must be separated from the "link destination" by
spaces or tabs. No further character may occur.
A "link label" begins with a left bracket ([
) and ends with the first right bracket (]
) that is not
backslash-escaped.
Between these brackets there must be at least one character that is not a space, tab, or line ending.
Unescaped square bracket characters are not allowed inside the opening and closing square brackets of
link labels. A link label can have at most 999 characters inside the square brackets.
A "link destination" consists of either:
= 0 characters between an opening
<
and a closing>
that contains no line endings or unescaped<
or>
characters, or0 characters that does not start with
<
, does not include ASCII control characters or space character, and includes parentheses only if: (a) they are backslash-escaped (b) they are part of a balanced pair of unescaped parentheses. At least 3 levels must be supported.
A "link title" consists of either:
= 0 characters between
"
characters, including a"
character only if it is backslash-escaped.= 0 characters between
'
characters, including a'
character only if it is backslash-escaped= 0 characters between matching parentheses, including a
(
or)
only if it's backslash-escaped.
PreviousSibling() As MKBlock
Returns this block's next sibling or Nil if there isn't one.
RemoveChild(child As MKBlock)
If child
is a top-level child of this block it is removed.