markdown.Node
type pub enum NodeA node in a Markdown AST.
Constructors
AutoLink
AutoLink(String)An automatic link without any child nodes.
Block
Block(String, Array[Node])A custom block/div/container.
The String argument is the tag/class of the block.
CodeBlock
CodeBlock(Option[String], String)A code block with an optional info string.
CodeSpan
CodeSpan(String)An inline code span.
Comment
Comment(String)A block comment.
Emphasis
Emphasis(Array[Node])A regular emphasis node.
Footnote
Footnote(String)A footnote.
The first argument is the name of the footnote.
Heading
Heading(Int, Array[Node])A heading.
The first argument is the heading level, in a range from 1 to 6. The second argument is the list of child nodes.
Image
Image(Link, String)An image.
The second argument is the image text.
LineBreak
LineBreak()A hard line break.
Link
Link(Link, Array[Node])A link with an optional body.
ListItem
ListItem(Array[Node])A single list item.
OrderedList
OrderedList(Array[Node])An ordered list.
Paragraph
Paragraph(Array[Node])A paragraph node.
Quote
Quote(Array[Node])A block quote.
Span
Span(String, Array[Node])A custom span with a tag.
The String argument is the tag/class of the span.
Strong
Strong(Array[Node])A strong emphasis node.
Subscript
Subscript(Array[Node])A subscript node.
Superscript
Superscript(Array[Node])A superscript node.
Table
Table(Array[Array[Array[Node]]], Array[Array[Array[Node]]], Array[Array[Array[Node]]])A table.
The arguments are (in this order): the header rows, the body rows, and the footer rows. Each value is an array of rows, containing an array of columns, containing an array of markup nodes.
Text
Text(String)Regular text.
The String argument is the text value.
ThematicBreak
ThematicBreak()A thematic break/horizontal ruler.
UnorderedList
UnorderedList(Array[Node])An unordered list.
Instance methods
!=
Show source codeHide source code
fn pub !=(other: ref Self) -> Bool {
!(self == other)
}fn pub !=(other: ref Self) -> BoolReturns true if self and the given object are not equal to each other.
==
Show source codeHide source code
fn pub ==(other: ref Node) -> Bool {
match (self, other) {
case (Block(a1, a2), Block(b1, b2)) -> a1 == b1 and a2 == b2
case (Span(a1, a2), Span(b1, b2)) -> a1 == b1 and a2 == b2
case (Quote(a), Quote(b)) -> a == b
case (Emphasis(a), Emphasis(b)) -> a == b
case (Paragraph(a), Paragraph(b)) -> a == b
case (Strong(a), Strong(b)) -> a == b
case (CodeSpan(a), CodeSpan(b)) -> a == b
case (CodeBlock(a1, a2), CodeBlock(b1, b2)) -> a1 == b1 and a2 == b2
case (Text(a), Text(b)) -> a == b
case (AutoLink(a), AutoLink(b)) -> a == b
case (Link(a1, a2), Link(b1, b2)) -> a1 == b1 and a2 == b2
case (Image(a1, a2), Image(b1, b2)) -> a1 == b1 and a2 == b2
case (Heading(a1, a2), Heading(b1, b2)) -> a1 == b1 and a2 == b2
case (Footnote(a), Footnote(b)) -> a == b
case (UnorderedList(a), UnorderedList(b)) -> a == b
case (OrderedList(a), OrderedList(b)) -> a == b
case (ListItem(a), ListItem(b)) -> a == b
case (ThematicBreak, ThematicBreak) -> true
case (Superscript(a), Superscript(b)) -> a == b
case (Subscript(a), Subscript(b)) -> a == b
case (Table(a1, a2, a3), Table(b1, b2, b3)) -> {
a1 == b1 and a2 == b2 and a3 == b3
}
case (LineBreak, LineBreak) -> true
case (Comment(a), Comment(b)) -> a == b
case _ -> false
}
}fn pub ==(other: ref Node) -> BoolReturns true if self and the given object are equal to each other.
This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.
clone
Show source codeHide source code
fn pub clone -> Node {
match self {
case Block(a, b) -> Node.Block(a, b.clone)
case Span(a, b) -> Node.Span(a, b.clone)
case Quote(v) -> Node.Quote(v.clone)
case Emphasis(v) -> Node.Emphasis(v.clone)
case Paragraph(v) -> Node.Paragraph(v.clone)
case Strong(v) -> Node.Strong(v.clone)
case CodeSpan(v) -> Node.CodeSpan(v)
case CodeBlock(a, b) -> Node.CodeBlock(a.clone, b)
case Text(v) -> Node.Text(v)
case AutoLink(v) -> Node.AutoLink(v)
case Link(a, b) -> Node.Link(a.clone, b.clone)
case Image(a, b) -> Node.Image(a.clone, b)
case Heading(a, b) -> Node.Heading(a, b.clone)
case Footnote(v) -> Node.Footnote(v)
case UnorderedList(v) -> Node.UnorderedList(v.clone)
case OrderedList(v) -> Node.OrderedList(v.clone)
case ListItem(v) -> Node.ListItem(v.clone)
case ThematicBreak -> Node.ThematicBreak
case Superscript(v) -> Node.Superscript(v.clone)
case Subscript(v) -> Node.Subscript(v.clone)
case Table(a, b, c) -> Node.Table(a.clone, b.clone, c.clone)
case LineBreak -> Node.LineBreak
case Comment(v) -> Node.Comment(v)
}
}fn pub clone -> NodeCreates a clone of self.
The returned value is an owned value that is the same type as the receiver
of this method. For example, cloning a ref Array[Int] results in a
Array[Int], not another ref Array[Int].
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
match self {
case Block(tag, nodes) -> {
formatter.tuple('Block').field(tag).field(nodes).finish
}
case Span(tag, nodes) -> {
formatter.tuple('Span').field(tag).field(nodes).finish
}
case Quote(nodes) -> formatter.tuple('Quote').field(nodes).finish
case Emphasis(nodes) -> formatter.tuple('Emphasis').field(nodes).finish
case Paragraph(nodes) -> formatter.tuple('Paragraph').field(nodes).finish
case Strong(nodes) -> formatter.tuple('Strong').field(nodes).finish
case CodeSpan(nodes) -> formatter.tuple('CodeSpan').field(nodes).finish
case CodeBlock(info, nodes) -> {
formatter.tuple('CodeBlock').field(info).field(nodes).finish
}
case Text(v) -> formatter.tuple('Text').field(v).finish
case AutoLink(v) -> formatter.tuple('AutoLink').field(v).finish
case Link(url, nodes) -> {
formatter.tuple('Link').field(url).field(nodes).finish
}
case Image(url, text) -> {
formatter.tuple('Image').field(url).field(text).finish
}
case Heading(level, nodes) -> {
formatter.tuple('Heading').field(level).field(nodes).finish
}
case Footnote(name) -> formatter.tuple('Footnote').field(name).finish
case UnorderedList(n) -> formatter.tuple('UnorderedList').field(n).finish
case OrderedList(n) -> formatter.tuple('OrderedList').field(n).finish
case ListItem(nodes) -> formatter.tuple('ListItem').field(nodes).finish
case ThematicBreak -> formatter.tuple('ThematicBreak').finish
case Superscript(n) -> formatter.tuple('Superscript').field(n).finish
case Subscript(n) -> formatter.tuple('Subscript').field(n).finish
case Table(head, body, foot) -> {
formatter.tuple('Table').field(head).field(body).field(foot).finish
}
case LineBreak -> formatter.tuple('LineBreak').finish
case Comment(t) -> formatter.tuple('Comment').field(t).finish
}
}fn pub fmt(formatter: mut Formatter)Formats self in a human-readable format for debugging purposes.
Implemented traits
Clone
impl Clone for NodeEqual
impl Equal for NodeFormat
impl Format for Node