Skip to content

Method parse

Brad Sharp edited this page Jan 17, 2021 · 1 revision

Type: iterator Markdown.parse(string document)

Used to parse a markdown document. The iterator returned provides the BlockType and information about the text that is in that block.

Usage

for blockType, block in Markdown.parse(md) do
  if blockType == BlockType.Heading then
    createHeading(block.Text)
  elseif blockType == BlockType.Paragraph then
    createParagraph(block.Text)
  elseif blockType == BlockType.Code then
    createCode(block.Syntax, block.Code)
  else
    ...
  end
end

Block Types

For each block type, a table of information is returned. That information is as follows:

None

Never returned by the iterator

Paragraph

{
  int: Indent
  string: Text
}

Heading

{
  int: Indent
  int: Level
  string: Text
}

Code

{
  int: Indent
  string: Syntax
  string: Code
}

List

{
  int: Indent
  list<string>: Lines
}

Ruler

{
  int: Indent
}

Quote

{
  int: Indent
  iterator: Iterator (Allows the quote to be iterated and rendered)
  string: RawText
}

Clone this wiki locally