Search results

There are no results.

markdown.Document

class pub Document

A parsed document.

Fields

children

let pub @children: Array[Node]

The markup nodes in this document.

references

let pub @references: Map[String, String]

The link references defined in this document.

The keys are the names of the references, and the values the links they point to.

footnotes

let pub @footnotes: Map[String, Array[Node]]

The footnotes defined in this document.

The keys of this map are the footnote names. The value are the nodes acting as the footnote's text/body.

Static methods

new

Show source code
Hide source code
fn pub static new -> Document {
  Document(children: [], references: Map.new, footnotes: Map.new)
}
fn pub static new -> Document

Returns a new empty Markdown document.

Examples

import markdown (Document)

Document.new

parse

Show source code
Hide source code
fn pub static parse[T: Bytes](input: T) -> Result[Document, Error] {
  Parser.new(input).parse
}
fn pub static parse[T: Bytes](input: T) -> Result[Document, Error]

Parses markup into a document.

Examples

import markdown (Document)

Document.parse('*hello*')

Instance methods

!=

Show source code
Hide source code
fn pub !=(other: T) -> Bool {
  (self == other).false?
}
fn pub !=(other: T) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide source code
fn pub ==(other: ref Document) -> Bool {
  @children == other.children
    and @references == other.references
    and @footnotes == other.footnotes
}
fn pub ==(other: ref Document) -> Bool

Returns 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 code
Hide source code
fn pub clone -> Document {
  Document(
    children: @children.clone,
    references: @references.clone,
    footnotes: @footnotes.clone,
  )
}
fn pub clone -> Document

Creates a clone of self.

to_html

Show source code
Hide source code
fn pub to_html -> html.Document {
  Generator.new(self).generate
}
fn pub to_html -> Document

Generates an HTML document from self.

If you need more control over how the document is generated (e.g. by disabling footnotes), you should use markdown.generator.Html directly.

Examples

import markdown (Document)

Document
  .parse('*hello*')
  .expect('the markup must be valid')
  .to_html
  .to_string # => '<p><strong>hello</strong></p>'

Implemented traits

std.clone.

Clone

impl Clone[Document] for Document
std.cmp.

Equal

impl Equal[ref Document] for Document