glemtext

Types

A Document is a list of Gemtext elements. As Gemtext “elements” are not nested, there is no need for a nested structure here, either.

As such, Document is a type alias to List(GemElement)

pub type Document =
  List(GemElement)

GemElement is an element, or possible line type for Gemtext.

pub type GemElement {
  Text(String)
  Link(to: String, label: Option(String))
  Heading(level: Int, text: String)
  ListItem(String)
  Blockquote(String)
  Preformatted(alt: Option(String), text: String)
}

Constructors

  • Text(String)

    Text is any text that doesn’t have specific syntax for creating an element. Note that empty lines are Text("")

  • Link(to: String, label: Option(String))

    A link to another document, both Gemini and non-Gemini, and optionally, a label.

  • Heading(level: Int, text: String)
  • ListItem(String)
  • Blockquote(String)
  • Preformatted(alt: Option(String), text: String)

Functions

pub fn parse(text: String) -> List(GemElement)

parse parses a string into a Gemtext Document. It will always return a valid document, and does not panic.

Search Document