Skip to content

MKInlineScanner

Description

Used internally during parsing to scan inlines.

Methods

Name Parameters Returns
CanContainSoftBreaks container As MKBlock Boolean
ComputeInlineStart container As MKBlock Integer
Constructor
CreateInlineLinkData linkTextChars() As MKCharacter, destinationData As MarkdownKit.MKLinkDestination, titleData As MarkdownKit.MKLinkTitle, containerEndPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter MKInlineLinkData
CreateReferenceLinkData container As MKBlock, linkLabel As String, chars() As MKCharacter, containerEndPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter, linkType As MKLinkTypes, optionalDestination As MarkdownKit.MKLinkDestination MKInlineLinkData
FinaliseBuffer buffer As MKInlineText, container As MKBlock
FinaliseInlineContainer container As MKBlock
FullReferenceLinkData container As MKBlock, chars() As MKCharacter, linkTextChars() As MKCharacter, charsStartPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter MKInlineLinkData
HandleBackticks parent As MKBlock, chars() As MKCharacter, startPos As Integer MKCodeSpan
HandleLeftAngleBracket parent As MKBlock, chars() As MarkdownKit.MKCharacter, startPos As Integer MKInlineHTML
InlineLinkData openerChar As MKCharacter, closingBracketChar As MKCharacter, chars() As MarkdownKit.MKCharacter, linkTextChars() As MKCharacter, parenthStartPos As Integer, isInlineImage As Boolean MKInlineLinkData
LookForLinkOrImage container As MarkdownKit.MKBlock, delimiterStack() As MKDelimiterStackNode, pos As Integer Boolean
ParseInlines block As MKBlock, delimiterStack() As MKDelimiterStackNode
Peek chars() As MKCharacter, pos As Integer, char As String Boolean
ProcessEmphasis container As MKBlock, delimiterStack() As MKDelimiterStackNode, stackBottom As Integer
ScanDelimiterRun chars() As MKCharacter, pos As Integer, delimiter As String MKDelimiterStackNode
ScanForInlineImage container As MKBlock, startPos As Integer, closerCharPos As Integer MKInlineLinkData
ScanForInlineLink container As MKBlock, startPos As Integer, closerCharPos As Integer MKInlineLinkData
ScanInlineLinkDestination chars() As MKCharacter, pos As Integer String
ScanInlineLinkTitle chars() As MKCharacter, pos As Integer String

Method Descriptions

CanContainSoftBreaks(container As MKBlock) As Boolean This method is shared.

True if container can contain soft breaks.


ComputeInlineStart(container As MKBlock) As Integer This method is shared.

Computes the absolute start position of inline elements in this container.

The start of inline elements is not always the same as the start position of the container. For example:

  012
  Foo
  ^
Versus
  01234
  # Foo
    ^

Constructor()

Private to prevent instantiation.


CreateInlineLinkData(linkTextChars() As MKCharacter, destinationData As MarkdownKit.MKLinkDestination, titleData As MarkdownKit.MKLinkTitle, containerEndPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter) As MKInlineLinkData This method is shared.

Convenience method for creating a new MKInlineLinkData object.

containerEndPos is the position in the inline link's container's Characters array of the closing ")". The contents of linkTextChars are used as the link's text and need to be parsed as inlines.

openerChar is the opening [ character (for links) or ! character (for images). closerChar is the closing ] character.


CreateReferenceLinkData(container As MKBlock, linkLabel As String, chars() As MKCharacter, containerEndPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter, linkType As MKLinkTypes, optionalDestination As MarkdownKit.MKLinkDestination) As MKInlineLinkData This method is shared.

Gets the data for a validated reference link named linkLabel from the document's reference map storing the link's end position and character data.

containerEndPos is the position in container.Characters of the closing "]". If this is an inline link, the contents of chars are used as the link's text. If this is an inline image, the contents of chars are used as the images's alt attrubute chars will be parsed as inlines.

openerChar is the opening [ character (for links) or ! character (for images). closerChar is the closing ] character.


FinaliseBuffer(buffer As MKInlineText, container As MKBlock) This method is shared.

Finalises the current inline parsing buffer.

As we parse inlines, we perodically keep an open inline text buffer to add characters to until we hit a different type of inline element (e.g. a backtick for a code span). This method is called when we need to close / finalise that open buffer.


FinaliseInlineContainer(container As MKBlock) This method is shared.

Finalises container after parsing all of its inline children.


FullReferenceLinkData(container As MKBlock, chars() As MKCharacter, linkTextChars() As MKCharacter, charsStartPos As Integer, isInlineImage As Boolean, openerChar As MKCharacter, closerChar As MKCharacter) As MKInlineLinkData This method is shared.

Returns either an inline link or Nil if a valid full reference link cannot be constructed.

linkTextChars are the raw characters representing this link's "link text". They are to be parsed as inlines. charsStartPos is the index of the "[" immediately after the closing linkText "]". openerChar is the opening [ character (for links) or ! character (for images). closerChar is the closing ] character.


HandleBackticks(parent As MKBlock, chars() As MKCharacter, startPos As Integer) As MKCodeSpan This method is shared.

If the character at startPos in chars begins a valid inline code span then one is created and returned, otherwise Nil is returned.

Assumes startPos in chars is a backtick.


HandleLeftAngleBracket(parent As MKBlock, chars() As MarkdownKit.MKCharacter, startPos As Integer) As MKInlineHTML This method is shared.

If the character at startPos in chars begins a valid inline HTML span then one is created and returned, otherwise Nil is returned.

Assumes chars(startPos) = "<".


InlineLinkData(openerChar As MKCharacter, closingBracketChar As MKCharacter, chars() As MarkdownKit.MKCharacter, linkTextChars() As MKCharacter, parenthStartPos As Integer, isInlineImage As Boolean) As MKInlineLinkData This method is shared.

Returns either an inline link or Nil if a valid inline link cannot be constructed.

linkTextChars are the raw characters representing this link's text. They are to be parsed as inlines. parenthStartPos points to the index of the "(" immediately after the closing linkText "]". openerChar is the opening [ character (for links) or ! character (for images). closingBracketChar is the closing ] character.

Inline link: linkText, "(", optional whitespace, optional link destination, optional linkTitle, optional whitespace, ")"

The contents of linkText are parsed as inlines and used as the link's text.


LookForLinkOrImage(container As MarkdownKit.MKBlock, delimiterStack() As MKDelimiterStackNode, pos As Integer) As Boolean This method is shared.

Having hit a "]", returns True if a link or image precedes it. If True, the link or image is added to container and pos is mutated.


ParseInlines(block As MKBlock, delimiterStack() As MKDelimiterStackNode) This method is shared.

Steps through the contents of the inline container block, handling any inline elements it encounters.

Assumes block is an inline container block (i.e: a paragraph, ATX heading or setext heading).


Peek(chars() As MKCharacter, pos As Integer, char As String) As Boolean This method is shared.

Returns True if the character at chars(pos) is char.


ProcessEmphasis(container As MKBlock, delimiterStack() As MKDelimiterStackNode, stackBottom As Integer) This method is shared.

Process any emphasis in container's inline blocks.

stackBottom sets a lower bound to how far we descend in the delimiter stack. If it's -1, then we can go all the way to the bottom. Otherwise, we stop before visiting stackBottom.


ScanDelimiterRun(chars() As MKCharacter, pos As Integer, delimiter As String) As MKDelimiterStackNode This method is shared.

Scans chars from pos for a run of emphasis. Returns a delimiter stack node with information about the run.

Assumes chars(pos) points to the begining of the emphasis run. delimiter is either "*" or "_".


ScanForInlineImage(container As MKBlock, startPos As Integer, closerCharPos As Integer) As MKInlineLinkData This method is shared.

Scans container.Characters from the beginning of the array for an inline image. Returns the image data if found or Nil if not.

Assumes container.Characters(startPos) = "!" and container.Characters(startPos + 1) = "[". Assumes container.Characters(closerCharPos) is the index of a "]" character.


ScanForInlineLink(container As MKBlock, startPos As Integer, closerCharPos As Integer) As MKInlineLinkData This method is shared.

Scans container.Characters from the beginning of the array for an inline link. Returns the link data if found or Nil if not.

Assumes container.Characters(startPos) = "[". Assumes container.Characters(closerCharPos) is the index of a "]" character.


ScanInlineLinkDestination(chars() As MKCharacter, pos As Integer) As String This method is shared.

Starting at pos, scans the chars for a valid link URL. Returns the URL or "" if there is none. Mutates pos.

If the URL is flanked by "<>" (scenario 1) they are removed from the URL before returning.


ScanInlineLinkTitle(chars() As MKCharacter, pos As Integer) As String This method is shared.

Scans chars, starting at pos, for a valid link title. Returns the title or " if there is none. Mutates pos to the position after the closing title delimiter.

There are 3 valid types of link title:

  1. = 0 characters between straight " characters including a " character only if it is backslash-escaped.

  2. = 0 characters between ' characters, including a ' character only if it is backslash-escaped.

  3. = 0 characters between matching parentheses ((...)), including a ( or ) character only if it's backslash-escaped.