jot

Types

pub type BulletStyle {
  BulletDash
  BulletStar
  BulletPlus
}

Constructors

  • BulletDash
  • BulletStar
  • BulletPlus
pub type Container {
  ThematicBreak
  Paragraph(
    attributes: dict.Dict(String, String),
    content: List(Inline),
  )
  Heading(
    attributes: dict.Dict(String, String),
    level: Int,
    content: List(Inline),
  )
  Codeblock(
    attributes: dict.Dict(String, String),
    language: option.Option(String),
    content: String,
  )
  RawBlock(content: String)
  BulletList(
    layout: ListLayout,
    style: BulletStyle,
    items: List(List(Container)),
  )
  OrderedList(
    layout: ListLayout,
    punctuation: OrdinalPunctuation,
    ordinal: OrdinalStyle,
    start: Int,
    items: List(List(Container)),
  )
  BlockQuote(
    attributes: dict.Dict(String, String),
    items: List(Container),
  )
  Div(
    class: option.Option(String),
    attributes: dict.Dict(String, String),
    items: List(Container),
  )
}

Constructors

  • ThematicBreak
  • Paragraph(
      attributes: dict.Dict(String, String),
      content: List(Inline),
    )
  • Heading(
      attributes: dict.Dict(String, String),
      level: Int,
      content: List(Inline),
    )
  • Codeblock(
      attributes: dict.Dict(String, String),
      language: option.Option(String),
      content: String,
    )
  • RawBlock(content: String)
  • BulletList(
      layout: ListLayout,
      style: BulletStyle,
      items: List(List(Container)),
    )
  • OrderedList(
      layout: ListLayout,
      punctuation: OrdinalPunctuation,
      ordinal: OrdinalStyle,
      start: Int,
      items: List(List(Container)),
    )
  • BlockQuote(
      attributes: dict.Dict(String, String),
      items: List(Container),
    )
  • Div(
      class: option.Option(String),
      attributes: dict.Dict(String, String),
      items: List(Container),
    )

    Arguments

    class

    The div syntax allows a single class to be given after the :::, like so:

    ::: my-class-here
    Hello, world!
    :::
    

    If a class was given then it is stored in this field so it can be pattern matched upon. The class is also present in the attributes dictionary, merged with any other attributes and classes given using the block attribute syntax ({key="value"}).

pub type Destination {
  Reference(String)
  Url(String)
}

Constructors

  • Reference(String)
  • Url(String)
pub type Document {
  Document(
    content: List(Container),
    references: dict.Dict(String, String),
    reference_attributes: dict.Dict(
      String,
      dict.Dict(String, String),
    ),
    footnotes: dict.Dict(String, List(Container)),
  )
}

Constructors

pub type Inline {
  Linebreak
  NonBreakingSpace
  Text(String)
  Link(
    attributes: dict.Dict(String, String),
    content: List(Inline),
    destination: Destination,
  )
  Image(
    attributes: dict.Dict(String, String),
    content: List(Inline),
    destination: Destination,
  )
  Span(
    attributes: dict.Dict(String, String),
    content: List(Inline),
  )
  Emphasis(content: List(Inline))
  Strong(content: List(Inline))
  Delete(content: List(Inline))
  Insert(content: List(Inline))
  Mark(content: List(Inline))
  Footnote(reference: String)
  Code(content: String)
  MathInline(content: String)
  MathDisplay(content: String)
  Symbol(content: String)
}

Constructors

  • Linebreak
  • NonBreakingSpace
  • Text(String)
  • Link(
      attributes: dict.Dict(String, String),
      content: List(Inline),
      destination: Destination,
    )
  • Image(
      attributes: dict.Dict(String, String),
      content: List(Inline),
      destination: Destination,
    )
  • Span(
      attributes: dict.Dict(String, String),
      content: List(Inline),
    )
  • Emphasis(content: List(Inline))
  • Strong(content: List(Inline))
  • Delete(content: List(Inline))
  • Insert(content: List(Inline))
  • Mark(content: List(Inline))
  • Footnote(reference: String)
  • Code(content: String)
  • MathInline(content: String)
  • MathDisplay(content: String)
  • Symbol(content: String)
pub type ListLayout {
  Tight
  Loose
}

Constructors

  • Tight
  • Loose
pub type OrdinalPunctuation {
  FullStop
  SingleParen
  DoubleParen
}

Constructors

  • FullStop
  • SingleParen
  • DoubleParen
pub type OrdinalStyle {
  NumericOrdinal
  LowerAlphaOrdinal
  UpperAlphaOrdinal
}

Constructors

  • NumericOrdinal
  • LowerAlphaOrdinal
  • UpperAlphaOrdinal

Values

pub fn document_to_html(document: Document) -> String

Convert a document tree into a string of HTML.

See to_html for further documentation.

pub fn inner_text(container: Container) -> String

Get the text from within a container.

Raw blocks, footnotes, and the ordinals and bullets from lists are not included.

pub fn parse(djot: String) -> Document

Convert a string of Djot into a tree of records.

This may be useful when you want more control over the HTML to be converted to, or you wish to convert Djot to some other format.

pub fn to_html(djot: String) -> String

Convert a string of Djot into a string of HTML.

If you want to have more control over the HTML generated you can use the parse function to convert Djot to a tree of records instead. You can then traverse this tree and turn it into HTML yourself.

Security

This does not escape the content of raw blocks! If you use this with user-input you likely need to escape raw blocks to prevent cross-site-scripting (XSS) attacks.

Search Document